Skip to content

Commit 0a596eb

Browse files
committed
fixup: Make sure we don't copy arrays as we check for zeroes
(Passing copy=False to np.array would have worked as well)
1 parent c65774c commit 0a596eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/zarr/core/buffer/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,11 +525,12 @@ def all_equal(self, other: Any, equal_nan: bool = True) -> bool:
525525
return False
526526
# Handle positive and negative zero by comparing bit patterns:
527527
if (
528-
np.array(other).dtype.kind == "f"
528+
np.array(other, copy=False).dtype.kind == "f"
529529
and other == 0.0
530530
and self._data.dtype.kind not in ("U", "S", "T", "O", "V")
531531
):
532-
return np.array_equiv(np.array(self._data).view("V"), np.array(other).view("V"))
532+
_data, other = np.broadcast_arrays(self._data, other)
533+
return np.array_equiv(_data.view("V"), other.view("V"))
533534
# use array_equal to obtain equal_nan=True functionality
534535
# Since fill-value is a scalar, isn't there a faster path than allocating a new array for fill value
535536
# every single time we have to write data?

0 commit comments

Comments
 (0)