NatLabRockies / NatLabRockies/ninterp
RON serde does not round-trip fixed-`N` interpolator data
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 17
- Forks
- 13
- Avg merge
- 44m
- Merged PRs (30d)
- 2
Description
InterpDataNDBase round-trips through RON. Every fixed-N type fails, in both the
plain and Nested serialization formats:
Data1D derived FAIL 2:11: Expected opening `[`
Data1D nested FAIL 2:11: Expected opening `[`
DataND derived OK
DataND nested FAIL 2:11: Expected opening `[`
Interp1D derived FAIL 3:15: Expected opening `[`
Interp1D nested FAIL 3:15: Expected opening `[`
Cause
InterpDataBase<D, N> stores its grid as [ArrayBase<D, Ix1>; N], a fixed-size array.
Serde treats that as a tuple, so RON writes (...), but deserialize_fixed asks for a
sequence and RON's deserializer then requires [...]. InterpDataNDBase is unaffected
because its grid is a Vec<ArrayBase<D, Ix1>>, which serializes as a sequence either way.
The Nested path fails for the same reason: GridArrWrapper also wraps the fixed-size
array.
Repro
Add ron as a dev-dependency, then:
let data = Interp1D::new(
array![0., 1., 2.],
array![0.0, 0.4, 0.8],
strategy::Linear,
Extrapolate::Error,
)
.unwrap()
.data;
let s = ron::to_string(&data).unwrap();
ron::from_str::<ninterp::data::InterpData1D<f64>>(&s).unwrap(); // panics
Scope
Pre-existing, not a regression: reproduces identically on main and on every released
version that has the fixed-N grid. JSON and bincode are unaffected, since neither
distinguishes tuples from sequences on the wire. Not currently covered by
tests/serde_formats.rs, which tests JSON and bincode only.
Possible fixes
- Serialize the fixed-size grid as a sequence rather than a tuple (a custom
serialize_withon thegridfield, mirroring whatdeserialize_fixedalready
expects). Changes the RON output shape; leaves JSON and bincode output identical. - Accept both tuple and sequence input in
deserialize_fixed, leaving the output shape
alone. Fixes reading but leaves RON output asymmetric withInterpDataNDBase. - Document RON as unsupported and leave it.
Worth deciding alongside whether tests/serde_formats.rs should cover a third,
self-describing format at all.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with InterpDataBase<D, N>, deserialize_fixed, and GridArrWrapper to trace how fixed-size grids are serialized and read. Review tests/serde_formats.rs and add RON round-trip coverage for the plain and Nested fixed-N types. Done means the affected fixed-N cases round-trip through RON without changing JSON or bincode behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100