feat: attrs() reports every attribute; unsigned arrays stay unsigned
attrs() silently omitted any attribute whose datatype had no AttrValue variant
— including every Python bool, which h5py stores as an enum — plus complex,
compound and reference attributes, and cast unsigned 64-bit arrays to
I64Array so values above i64::MAX came back negative.
- numpy/h5py-style booleans (an enum of exactly FALSE=0 / TRUE=1 over an
integer base) decode as I64 / I64Array of 0/1.
- AttrValue::U64Array keeps unsigned arrays unsigned. Behaviour change: an
unsigned array attribute no longer arrives as I64Array; the netCDF-4 CF
helpers (_FillValue, valid_range) and the Python bindings handle it.
- AttrValue::Raw { datatype, shape, data } carries any other attribute
verbatim (also used when a value fails to decode as its declared type), so
the attribute list is always complete. Decodable with data_read against the
datatype; Python receives {"dtype", "shape", "data"}.
- Both new variants are writable, so attributes round-trip between files.
h5py interop tests cover reading 13 attribute kinds and h5py reading back a
compound and a u64 attribute written by clawhdf5.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
5dd95a6cf8
commit
97ab658c11
@@ -41,6 +41,20 @@
|
||||
object_path }` (was `PathNotFound`), and a dataset whose raw data lives in
|
||||
external files (message 0x0007, now a known `MessageType`) is
|
||||
`ExternalDataFilesUnsupported` (it would otherwise read as fill values).
|
||||
- **`attrs()` no longer drops attributes.** Any attribute whose datatype had
|
||||
no `AttrValue` variant was omitted with no error — including every Python
|
||||
`bool` (h5py stores `attrs["flag"] = True` as an enum), complex numbers,
|
||||
compound values and object references. Now:
|
||||
- numpy/h5py-style booleans (an enum of exactly `FALSE`=0 / `TRUE`=1) decode
|
||||
as `I64` / `I64Array` of 0/1;
|
||||
- new `AttrValue::U64Array` keeps unsigned arrays unsigned (they were cast to
|
||||
`I64Array`, so values above `i64::MAX` came back negative). **Behaviour
|
||||
change:** code matching `I64Array` for an unsigned attribute must also
|
||||
match `U64Array` (the netCDF-4 CF helpers and Python bindings do);
|
||||
- new `AttrValue::Raw { datatype, shape, data }` carries everything else
|
||||
verbatim, decodable with `clawhdf5_format::data_read` against `datatype`.
|
||||
Both new variants are writable, so an attribute can be copied between files
|
||||
unchanged. Python receives `Raw` as `{"dtype", "shape", "data"}`.
|
||||
- All of the above are covered by h5py interop tests under both default and
|
||||
`libver='latest'` bounds, compared against h5py's own readback.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user