Skip to content

Commit c72d0e2

Browse files
authored
[v2] Fix doctests with numpy 2.0 (#2073)
1 parent 6888c59 commit c72d0e2

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ filterwarnings = [
145145
"ignore:The .* is deprecated and will be removed in a Zarr-Python version 3*:FutureWarning",
146146
"ignore:The experimental Zarr V3 implementation in this version .*:FutureWarning",
147147
]
148+
doctest_subpackage_requires =[
149+
"zarr/core.py = numpy>=2",
150+
"zarr/creation.py = numpy>=2"
151+
]
148152

149153

150154
[tool.codespell]

zarr/core.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,11 @@ def islice(self, start=None, end=None):
609609
610610
Iterate over part of the array:
611611
>>> for value in z.islice(25, 30): value;
612-
25
613-
26
614-
27
615-
28
616-
29
612+
np.int64(25)
613+
np.int64(26)
614+
np.int64(27)
615+
np.int64(28)
616+
np.int64(29)
617617
"""
618618

619619
if len(self.shape) == 0:
@@ -679,7 +679,7 @@ def __getitem__(self, selection):
679679
Retrieve a single item::
680680
681681
>>> z[5]
682-
5
682+
np.int64(5)
683683
684684
Retrieve a region via slicing::
685685
@@ -706,7 +706,7 @@ def __getitem__(self, selection):
706706
Retrieve an item::
707707
708708
>>> z[2, 2]
709-
22
709+
np.int64(22)
710710
711711
Retrieve a region via slicing::
712712
@@ -830,7 +830,7 @@ def get_basic_selection(self, selection=Ellipsis, out=None, fields=None):
830830
Retrieve a single item::
831831
832832
>>> z.get_basic_selection(5)
833-
5
833+
np.int64(5)
834834
835835
Retrieve a region via slicing::
836836
@@ -852,7 +852,7 @@ def get_basic_selection(self, selection=Ellipsis, out=None, fields=None):
852852
Retrieve an item::
853853
854854
>>> z.get_basic_selection((2, 2))
855-
22
855+
np.int64(22)
856856
857857
Retrieve a region via slicing::
858858
@@ -2819,7 +2819,7 @@ def view(
28192819
>>> v[:]
28202820
array([False, False, True, ..., True, False, False])
28212821
>>> np.all(a[:].view(dtype=bool) == v[:])
2822-
True
2822+
np.True_
28232823
28242824
An array can be viewed with a dtype with a different item size, however
28252825
some care is needed to adjust the shape and chunk shape so that chunk
@@ -2833,7 +2833,7 @@ def view(
28332833
>>> v[:10]
28342834
array([0, 0, 1, 0, 2, 0, 3, 0, 4, 0], dtype=uint8)
28352835
>>> np.all(a[:].view('u1') == v[:])
2836-
True
2836+
np.True_
28372837
28382838
Change fill value for uninitialized chunks:
28392839

zarr/creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def open_array(
569569
>>> z2
570570
<zarr.core.Array (10000, 10000) float64 read-only>
571571
>>> np.all(z1[:] == z2[:])
572-
True
572+
np.True_
573573
574574
Notes
575575
-----

0 commit comments

Comments
 (0)