Skip to content

Commit

Permalink
catch ValueError in np.equal that happens with vlen data
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey committed May 14, 2024
1 parent 362357e commit 0d1a0ff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion h5pyd/_apps/utillib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,16 @@ def write_dataset(src, tgt, ctx):
empty_arr = np.zeros(arr.shape, dtype=arr.dtype)
if fillvalue:
empty_arr.fill(fillvalue)
if np.array_equal(arr, empty_arr):

try:
is_equal = np.array_equal(arr, empty_arr)
except ValueError as ve:
msg = "ValueError on np.array_equal check - assuming not equal"
logging.warning(f"{msg}: {ve}")
if ctx["verbose"]:
print(msg)
is_equal = False
if is_equal:
msg = f"skipping chunk for slice: {src_s}"
else:
msg = f"writing dataset data for slice: {src_s}"
Expand Down

0 comments on commit 0d1a0ff

Please sign in to comment.