Skip to content

Commit c65774c

Browse files
committed
fixup: Make sure fill value is a float before checking if it's == 0
1 parent 683ec5f commit c65774c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/zarr/core/buffer/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,12 @@ def all_equal(self, other: Any, equal_nan: bool = True) -> bool:
523523
if other is None:
524524
# Handle None fill_value for Zarr V2
525525
return False
526-
if other == 0.0 and self._data.dtype.kind not in ("U", "S", "T", "O", "V"):
527-
# Handle positive and negative zero by comparing bit patterns:
526+
# Handle positive and negative zero by comparing bit patterns:
527+
if (
528+
np.array(other).dtype.kind == "f"
529+
and other == 0.0
530+
and self._data.dtype.kind not in ("U", "S", "T", "O", "V")
531+
):
528532
return np.array_equiv(np.array(self._data).view("V"), np.array(other).view("V"))
529533
# use array_equal to obtain equal_nan=True functionality
530534
# Since fill-value is a scalar, isn't there a faster path than allocating a new array for fill value

0 commit comments

Comments
 (0)