Repository navigation
Write multidimensional arrays as nested sequences - #264
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #264 +/- ##
==========================================
+ Coverage 92.35% 92.40% +0.04%
==========================================
Files 15 15
Lines 1767 1778 +11
==========================================
+ Hits 1632 1643 +11
Misses 135 135 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
quinnj-bot
Bot
force-pushed
the
claude/write-multidim-arrays
branch
from
November 18, 2026 07:11
5a99679 to
ad54e87
Compare
This was referenced Nov 18, 2026
YAML.write prints a matrix with Julia's string syntax, so loading the output gives a one-element list holding a string. The test asserts that matrices and higher-dimensional arrays load back as nested lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Arrays with two or more dimensions had no writer method, so they fell through to the generic fallback, which prints Julia's string syntax such as `[1 2; 3 4]`. That loads back as a list holding one string. Write such an array as a sequence of its slices along the last dimension, so a matrix becomes a sequence of its columns. This matches how JSON.jl writes arrays, and `reduce(hcat, ...)` rebuilds the matrix. The mapping and sequence writers now treat any nonempty array as a block collection. Fixes #135 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A zero-dimensional array has no last dimension to slice along, so the multidimensional writer threw a BoundsError for values such as fill(1). Write the one value it holds instead, as JSON.jl does, and decide inline-or-block layout from that value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj-bot
Bot
force-pushed
the
claude/write-multidim-arrays
branch
from
November 22, 2026 03:35
ad54e87 to
3758e16
Compare
Unwrap scalar array keys before deciding how to quote them. Cover multiline and quoted text, symbols, and matrix keys in the round-trip tests.
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.
Why
YAML.writeandYAML.write_fileprint a matrix in Julia syntax, such as[1 2; 3 4]. Loading that output gives a list that holds one string, so the matrix data is lost. Fixes #135.What changed
reduce(hcat, ...)on the loaded value rebuilds the matrix.YAML.writedocstring states the layout.Sequencetype list now includes everyAbstractArray, so a matrix inside a list, as a mapping value, or as a key starts on its own lines.Scope
YAML.loadstill returns nested vectors, because YAML has no matrix type.Float32NaN/Infstill go through the genericstringfallback. Those are separate fixes.fill(1), is written as the one value it holds, as JSON.jl does. Before, it was written as the stringfill(1).Tradeoffs
Rows were the other choice (
[[1, 2], [3, 4]], as NumPy'stolistgives). Columns match JSON.jl and Julia's column-major storage, andreduce(hcat, ...)rebuilds the matrix without a transpose.Verification
issue #135testset has 4 failures on master and passes with the fix. It covers a matrix as a mapping value, a matrix inside a list, a 3-D array, an empty0×3matrix, and zero-dimensional arrays at the top level, as mapping values, and as list elements.[], so the caller's inline-or-block choice matches the output.axeskeeps offset-indexed arrays correct. Vectors and ranges still use the vector method.Rebased on master, which added
Sequenceandstarts_blockto the writer. The conflict is resolved by wideningSequencetoAbstractArray.🤖 Generated with Claude Code