Skip to content
Snippets Groups Projects
Commit 83ac2288 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Fix comparison of strings in HDF5 files

parent 4328915b
No related branches found
No related tags found
1 merge request!933[Tests] clearer comparison of HDF5 files
......@@ -89,15 +89,19 @@ def validate_file(
elif out_ds.dtype != ref_ds.dtype:
changed.append((dsname, f"Dtype: {ref_ds.dtype} -> {out_ds.dtype}")) # noqa
else:
nanable = np.issubdtype(ref_ds.dtype, np.floating) \
or np.issubdtype(ref_ds.dtype, np.complexfloating)
floaty = np.issubdtype(ref_ds.dtype, np.floating) \
or np.issubdtype(ref_ds.dtype, np.complexfloating)
# Compare data incrementally rather than loading it all at once;
# read in blocks of ~64 MB (arbitrary limit) along first axis.
for chunk_slice in iter_sized_chunks(ref_ds, 64 * 1024 * 1024):
ref_chunk = ref_ds[chunk_slice]
out_chunk = out_ds[chunk_slice]
if not np.allclose(ref_chunk, out_chunk, equal_nan=nanable): # noqa
if floaty:
eq = np.allclose(ref_chunk, out_chunk, equal_nan=True)
else:
eq = np.array_equal(ref_chunk, out_chunk)
if not eq:
# If just 1 entry, show the values
if ref_ds.size == 1:
r, o = np.squeeze(ref_chunk), np.squeeze(out_chunk)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment