Skip to content

Commit 18f195a

Browse files
authored
replace np.NaN with np.nan in preparation for numpy 2.0 (#138)
1 parent dc62090 commit 18f195a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

virtualizarr/tests/test_kerchunk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_dataset_from_df_refs():
4040

4141
assert da.data.zarray.compressor is None
4242
assert da.data.zarray.filters is None
43-
assert da.data.zarray.fill_value is np.NaN
43+
assert da.data.zarray.fill_value is np.nan
4444
assert da.data.zarray.order == "C"
4545

4646
assert da.data.manifest.dict() == {
@@ -76,7 +76,7 @@ def test_accessor_to_kerchunk_dict(self):
7676
chunks=(2, 3),
7777
compressor=None,
7878
filters=None,
79-
fill_value=np.NaN,
79+
fill_value=np.nan,
8080
order="C",
8181
),
8282
)
@@ -105,7 +105,7 @@ def test_accessor_to_kerchunk_json(self, tmp_path):
105105
chunks=(2, 3),
106106
compressor=None,
107107
filters=None,
108-
fill_value=np.NaN,
108+
fill_value=np.nan,
109109
order="C",
110110
),
111111
)
@@ -186,7 +186,7 @@ def test_kerchunk_roundtrip_in_memory_no_concat():
186186
chunks=(2, 2),
187187
compressor=None,
188188
filters=None,
189-
fill_value=np.NaN,
189+
fill_value=np.nan,
190190
order="C",
191191
),
192192
chunkmanifest=manifest,

virtualizarr/tests/test_manifests/test_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_create_manifestarray_from_kerchunk_refs(self):
4646
assert marr.chunks == (2, 3)
4747
assert marr.dtype == np.dtype("int64")
4848
assert marr.zarray.compressor is None
49-
assert marr.zarray.fill_value is np.NaN
49+
assert marr.zarray.fill_value is np.nan
5050
assert marr.zarray.filters is None
5151
assert marr.zarray.order == "C"
5252

virtualizarr/tests/test_zarr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_zarr_v3_roundtrip(tmpdir):
1515
chunks=(2, 3),
1616
compressor=None,
1717
filters=None,
18-
fill_value=np.NaN,
18+
fill_value=np.nan,
1919
order="C",
2020
zarr_format=3,
2121
),

virtualizarr/zarr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ZArray(BaseModel):
4343
chunks: tuple[int, ...]
4444
compressor: str | None = None
4545
dtype: np.dtype
46-
fill_value: float | int | None = np.NaN # float or int?
46+
fill_value: float | int | None = np.nan # float or int?
4747
filters: list[dict] | None = None
4848
order: Literal["C", "F"]
4949
shape: tuple[int, ...]
@@ -76,7 +76,7 @@ def from_kerchunk_refs(cls, decoded_arr_refs_zarray) -> "ZArray":
7676
# coerce type of fill_value as kerchunk can be inconsistent with this
7777
fill_value = decoded_arr_refs_zarray["fill_value"]
7878
if fill_value is None or fill_value == "NaN":
79-
fill_value = np.NaN
79+
fill_value = np.nan
8080

8181
return ZArray(
8282
chunks=tuple(decoded_arr_refs_zarray["chunks"]),
@@ -94,7 +94,7 @@ def dict(self) -> dict[str, Any]:
9494

9595
zarray_dict["dtype"] = encode_dtype(zarray_dict["dtype"])
9696

97-
if zarray_dict["fill_value"] is np.NaN:
97+
if zarray_dict["fill_value"] is np.nan:
9898
zarray_dict["fill_value"] = None
9999

100100
return zarray_dict
@@ -247,7 +247,7 @@ def metadata_from_zarr_json(filepath: Path) -> tuple[ZArray, list[str], dict]:
247247
chunk_shape = metadata["chunk_grid"]["configuration"]["chunk_shape"]
248248

249249
if metadata["fill_value"] is None:
250-
fill_value = np.NaN
250+
fill_value = np.nan
251251
else:
252252
fill_value = metadata["fill_value"]
253253

0 commit comments

Comments
 (0)