fix(tools): h5rs dump shows NUL padding in nested strings, like h5dump
A null-padded fixed string inside a compound or an array member printed
trimmed ("" for three NULs, "a" for "a\0b"), where h5dump prints every
byte ("\000\000\000", "a\000b"); only top-level strings were shown in
full. DATA blocks now render elements through one function that keeps
the padding at any depth.
The README now lists the remaining known differences from h5dump:
nested compounds print inline, and long double values are printed as
errors (exit 1) with the datatype as an H5T_FLOAT block.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -149,6 +149,15 @@ for name, t in (("target1.h5", "/a"), ("target2.h5", "/b")):
|
||||
f["s"] = h5py.SoftLink(t)
|
||||
f["rel"] = h5py.SoftLink("a")
|
||||
|
||||
# Null-padded fixed strings with NULs, at the top level and nested in a
|
||||
# compound and in an array member.
|
||||
with h5py.File(os.path.join(out, "nulstrings.h5"), "w") as f:
|
||||
f["top"] = np.array([b"", b"ab", b"a\x00b"], dtype="S3")
|
||||
f["cmp"] = np.array(
|
||||
[(b"", 1), (b"ab", 2), (b"a\x00b", 3)], dtype=[("s", "S3"), ("i", "i4")]
|
||||
)
|
||||
f["arr"] = np.array([([b"", b"x"],)], dtype=[("v", "(2,)S2")])
|
||||
|
||||
with h5py.File(os.path.join(out, "userblock.h5"), "w", userblock_size=1024) as f:
|
||||
f["d"] = np.arange(10)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user