Skip to content

Commit 683ec5f

Browse files
bojidar-bgd-v-b
andcommitted
Use bit patterns for comparing zeroes instead of signbit
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
1 parent 1cc3250 commit 683ec5f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/zarr/core/buffer/core.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,8 @@ def all_equal(self, other: Any, equal_nan: bool = True) -> bool:
524524
# Handle None fill_value for Zarr V2
525525
return False
526526
if other == 0.0 and self._data.dtype.kind not in ("U", "S", "T", "O", "V"):
527-
# Handle positive and negative zero
528-
if np.any(self._data): # Check for any truthy value
529-
return False
530-
# Check signs:
531-
return np.array_equiv(np.signbit(self._data), np.signbit(other))
527+
# Handle positive and negative zero by comparing bit patterns:
528+
return np.array_equiv(np.array(self._data).view("V"), np.array(other).view("V"))
532529
# use array_equal to obtain equal_nan=True functionality
533530
# Since fill-value is a scalar, isn't there a faster path than allocating a new array for fill value
534531
# every single time we have to write data?

0 commit comments

Comments
 (0)