From 0ae89d513be6a4ed3174b2b6ff70f963ab826c00 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 11 Aug 2024 09:38:41 +0100 Subject: [PATCH] Fix doctests with numpy 2.0 --- pyproject.toml | 4 ++++ zarr/core.py | 22 +++++++++++----------- zarr/creation.py | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dacd45ec2c..a5668d0d90 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] diff --git a/zarr/core.py b/zarr/core.py index b1ccd203db..4f3080e46c 100644 --- a/zarr/core.py +++ b/zarr/core.py @@ -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: @@ -679,7 +679,7 @@ def __getitem__(self, selection): Retrieve a single item:: >>> z[5] - 5 + np.int64(5) Retrieve a region via slicing:: @@ -706,7 +706,7 @@ def __getitem__(self, selection): Retrieve an item:: >>> z[2, 2] - 22 + np.int64(22) Retrieve a region via slicing:: @@ -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:: @@ -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:: @@ -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 @@ -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: diff --git a/zarr/creation.py b/zarr/creation.py index 9b2b1d6d4c..f7f3d5a094 100644 --- a/zarr/creation.py +++ b/zarr/creation.py @@ -569,7 +569,7 @@ def open_array( >>> z2 >>> np.all(z1[:] == z2[:]) - True + np.True_ Notes -----