Store SSMC text without char-matrix padding - #27
Merged
Conversation
The SSMC "notes" field is a MATLAB char matrix, whose rows are blank
padded to a uniform width. Writing each row as a separate JSON string
exposed that padding in the file, giving an array of fixed-width strings
with trailing whitespace instead of a text block.
Join the rows into a single string separated by newlines, with trailing
blanks stripped. Readers rebuild the char matrix with char(), which
pads to the longest line, so the original width is only recoverable if
some line reaches it. When no line does, the widest line keeps just
enough padding to preserve the width; at most one line in a block ends
up with trailing whitespace, and the round trip stays exact. This keeps
the strict isequal comparison in ssexport's check passing without any
change on the SuiteSparse side.
On the read side, split embedded line terminators out of every element
and never deblank, so both the new single string and the padded row
arrays in existing files produce the same char matrix.
Verified with ssexport(ids, 'check', '', {'MM','RB','BSP'}) on
Mycielski/mycielskian2 and LPnetlib/lp_blend, whose widest note lines
are blank padded, plus HB/ash219, Pajek/football, and HB/bcsstk01.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Aux text was written to its HDF5 string dataset row by row with the blank padding of the source char matrix intact, while sstextwrite deblanks the same data for the MM and RB formats. Strip it here too, reusing the rule already used for notes: rows lose their trailing blanks, except that the widest row keeps just enough padding for a char() rebuild to recover the original width. Single rows and the elements of cell and string arrays carry no matrix padding, so a single row is left alone and cell elements are simply stripped. Aux text now round trips exactly even when the widest row is blank padded, which is more than MM and RB manage: for aux.padded = ['alpha ';'beta '], BSP returns the 2-by-6 original while MM and RB both return a 2-by-5 matrix, so ssexport's check would fail on them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
notesis now a single\n-joined string instead of a JSON array of blank-padded rows; aux text datasets are stripped row by row, assstextwritealready does for MM and RB.char(). The round trip stays exact, sossexport'sisequalcheck keeps passing and nothing in SuiteSparse needs to change.binsparse_write_ssmc_problem.m: newstrip_text_rows(replaceschar_rows), used by bothtext_blockandwrite_string_dataset.binsparse_to_ssmc_problem.m:text_rowssplits embedded line terminators and never deblanks; old files with padded row arrays still read identically.Mycielski/mycielskian*,Schenk/nlpkkt*,Cylshell/*,GHS_psdef/s3dk*,LPnetlib/lp_blend,lp_finnis,lp_perold,McRae/ecology1,Luong/photogrammetry).ssexport(ids, 'check', '', {'MM','RB','BSP'})passes on[2758 603 7 1474 23].Not fixed here: MM and RB lose a column from aux text whose widest row is padded (
sstextwritedeblanks,sstextreadrebuilds narrower). Latent — no collection matrix has such aux today — and the fix belongs in SuiteSparse.