Skip to content

Store SSMC text without char-matrix padding - #27

Merged
BenBrock merged 2 commits into
mainfrom
ssmc-notes-text-block
Jul 28, 2026
Merged

Store SSMC text without char-matrix padding#27
BenBrock merged 2 commits into
mainfrom
ssmc-notes-text-block

Conversation

@BenBrock

Copy link
Copy Markdown
Contributor
  • notes is now a single \n-joined string instead of a JSON array of blank-padded rows; aux text datasets are stripped row by row, as sstextwrite already does for MM and RB.
  • Trailing blanks are stripped except on the widest row when that row is what carries the char matrix width, since readers rebuild with char(). The round trip stays exact, so ssexport's isequal check keeps passing and nothing in SuiteSparse needs to change.
  • binsparse_write_ssmc_problem.m: new strip_text_rows (replaces char_rows), used by both text_block and write_string_dataset.
  • binsparse_to_ssmc_problem.m: text_rows splits embedded line terminators and never deblanks; old files with padded row arrays still read identically.
  • Of the 1863 matrices with notes, 1825 come out with no trailing blanks at all; the other 38 keep padding on one line (Mycielski/mycielskian*, Schenk/nlpkkt*, Cylshell/*, GHS_psdef/s3dk*, LPnetlib/lp_blend, lp_finnis, lp_perold, McRae/ecology1, Luong/photogrammetry).
  • All binding tests pass, plus new assertions for both cases; 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 (sstextwrite deblanks, sstextread rebuilds narrower). Latent — no collection matrix has such aux today — and the fix belongs in SuiteSparse.

BenBrock and others added 2 commits July 27, 2026 18:28
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>
@BenBrock
BenBrock merged commit ed29d37 into main Jul 28, 2026
3 checks passed
@BenBrock
BenBrock deleted the ssmc-notes-text-block branch July 28, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant