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_with on the grid field, mirroring what deserialize_fixed already
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 with InterpDataNDBase.
- Document RON as unsupported and leave it.
Worth deciding alongside whether tests/serde_formats.rs should cover a third,
self-describing format at all.
InterpDataNDBaseround-trips through RON. Every fixed-Ntype fails, in both theplain and
Nestedserialization formats: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
(...), butdeserialize_fixedasks for asequence and RON's deserializer then requires
[...].InterpDataNDBaseis unaffectedbecause its grid is a
Vec<ArrayBase<D, Ix1>>, which serializes as a sequence either way.The
Nestedpath fails for the same reason:GridArrWrapperalso wraps the fixed-sizearray.
Repro
Add
ronas a dev-dependency, then:Scope
Pre-existing, not a regression: reproduces identically on
mainand on every releasedversion that has the fixed-
Ngrid. JSON and bincode are unaffected, since neitherdistinguishes tuples from sequences on the wire. Not currently covered by
tests/serde_formats.rs, which tests JSON and bincode only.Possible fixes
serialize_withon thegridfield, mirroring whatdeserialize_fixedalreadyexpects). Changes the RON output shape; leaves JSON and bincode output identical.
deserialize_fixed, leaving the output shapealone. Fixes reading but leaves RON output asymmetric with
InterpDataNDBase.Worth deciding alongside whether
tests/serde_formats.rsshould cover a third,self-describing format at all.