fix(tools): h5rs diff compares integers exactly under -d/-p
With a tolerance, integers were converted to f64 before comparing, so int64/uint64 values above 2^53 that differ compared equal: -d 0 on 2^60 and 2^60 + 1 exited 0, where h5diff exits 1. Integer pairs are now compared in i128 (the delta against floor(D), the relative quotient from an exact difference), and the report prints the exact difference. h5diff compares exactly when -p is below the f64 epsilon (2^60 and 2^60 + 1 differ at -p 1e-18, and nextafter(2, 0) and 2 at -p 1.5e-16); h5rs now does the same. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -126,6 +126,12 @@ for name, last in (("copied.h5", 1), ("copied_changed.h5", 9)):
|
||||
g["d"] = np.arange(3)
|
||||
g.create_group("s")["e"] = np.array([0, last if gname == "h" else 1])
|
||||
|
||||
# 64-bit integers one apart, beyond f64's 2^53 integer precision.
|
||||
for name, d in (("big1.h5", 0), ("big2.h5", 1)):
|
||||
with h5py.File(os.path.join(out, name), "w") as f:
|
||||
f["i"] = np.array([2**60 + d, -(2**62) - d], dtype="i8")
|
||||
f["u"] = np.array([2**64 - 1 - d], dtype="u8")
|
||||
|
||||
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