Skip to content

Commit

Permalink
[v2] Fix doctests with numpy 2.0 (zarr-developers#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby authored Aug 14, 2024
1 parent 6888c59 commit c72d0e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ filterwarnings = [
"ignore:The .* is deprecated and will be removed in a Zarr-Python version 3*:FutureWarning",
"ignore:The experimental Zarr V3 implementation in this version .*:FutureWarning",
]
doctest_subpackage_requires =[
"zarr/core.py = numpy>=2",
"zarr/creation.py = numpy>=2"
]


[tool.codespell]
Expand Down
22 changes: 11 additions & 11 deletions zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,11 @@ def islice(self, start=None, end=None):
Iterate over part of the array:
>>> for value in z.islice(25, 30): value;
25
26
27
28
29
np.int64(25)
np.int64(26)
np.int64(27)
np.int64(28)
np.int64(29)
"""

if len(self.shape) == 0:
Expand Down Expand Up @@ -679,7 +679,7 @@ def __getitem__(self, selection):
Retrieve a single item::
>>> z[5]
5
np.int64(5)
Retrieve a region via slicing::
Expand All @@ -706,7 +706,7 @@ def __getitem__(self, selection):
Retrieve an item::
>>> z[2, 2]
22
np.int64(22)
Retrieve a region via slicing::
Expand Down Expand Up @@ -830,7 +830,7 @@ def get_basic_selection(self, selection=Ellipsis, out=None, fields=None):
Retrieve a single item::
>>> z.get_basic_selection(5)
5
np.int64(5)
Retrieve a region via slicing::
Expand All @@ -852,7 +852,7 @@ def get_basic_selection(self, selection=Ellipsis, out=None, fields=None):
Retrieve an item::
>>> z.get_basic_selection((2, 2))
22
np.int64(22)
Retrieve a region via slicing::
Expand Down Expand Up @@ -2819,7 +2819,7 @@ def view(
>>> v[:]
array([False, False, True, ..., True, False, False])
>>> np.all(a[:].view(dtype=bool) == v[:])
True
np.True_
An array can be viewed with a dtype with a different item size, however
some care is needed to adjust the shape and chunk shape so that chunk
Expand All @@ -2833,7 +2833,7 @@ def view(
>>> v[:10]
array([0, 0, 1, 0, 2, 0, 3, 0, 4, 0], dtype=uint8)
>>> np.all(a[:].view('u1') == v[:])
True
np.True_
Change fill value for uninitialized chunks:
Expand Down
2 changes: 1 addition & 1 deletion zarr/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def open_array(
>>> z2
<zarr.core.Array (10000, 10000) float64 read-only>
>>> np.all(z1[:] == z2[:])
True
np.True_
Notes
-----
Expand Down

0 comments on commit c72d0e2

Please sign in to comment.