Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/zarr/core/buffer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,10 @@ def __repr__(self) -> str:
return f"<NDBuffer shape={self.shape} dtype={self.dtype} {self._data!r}>"

def all_equal(self, other: Any) -> bool:
return bool((self._data == other).all())
# use array_equal to obtain equal_nan=True functionality
data, other = np.broadcast_arrays(self._data, other)
result = np.array_equal(self._data, other, equal_nan=True)
return result

def fill(self, value: Any) -> None:
self._data.fill(value)
Expand Down
19 changes: 19 additions & 0 deletions tests/v3/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,22 @@ def test_array_v3_fill_value(store: MemoryStore, fill_value: int, dtype_str: str

assert arr.fill_value == np.dtype(dtype_str).type(fill_value)
assert arr.fill_value.dtype == arr.dtype


@pytest.mark.parametrize("store", ["memory"], indirect=True)
async def test_array_v3_nan_fill_value(store: MemoryStore) -> None:
shape = (10,)
arr = Array.create(
store=store,
shape=shape,
dtype=np.float64,
zarr_format=3,
chunk_shape=shape,
fill_value=np.nan,
)
arr[:] = np.nan

assert np.isnan(arr.fill_value)
assert arr.fill_value.dtype == arr.dtype
# all fill value chunk is an empty chunk, and should not be written
assert not [a async for a in store.list_prefix("/")]