Skip to content

Commit

Permalink
Fix Array.__array__ for numpy 2.1 (#2106)
Browse files Browse the repository at this point in the history
* Fix Array.__array__ for numpy 2.1

* Add changelog

* Depend on np.array for array coercions
  • Loading branch information
dstansby authored Aug 23, 2024
1 parent c5c4698 commit 35e8106
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 10 additions & 1 deletion docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ Release notes
2.18.3
------

Enhancements
~~~~~~~~~~~~
* Added support for creating a copy of data when converting a `zarr.Array`
to a numpy array.
By :user:`David Stansby <dstansby>`

Maintenance
~~~~~~~~~~~
* Removed support for Python 3.9.
By :user:`David Stansby <dstansby>`

* Fix a regression when using orthogonal indexing with a scalar.
By :user:`Deepak Cherian <dcherian>` :issue:`1931`

* Added compatibility with numpy 2.1.
By :user:`David Stansby <dstansby>`


.. _release_2.18.2:

Expand Down
7 changes: 2 additions & 5 deletions zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,8 @@ def __eq__(self, other):
# store comparison
)

def __array__(self, *args):
a = self[...]
if args:
a = a.astype(args[0])
return a
def __array__(self, dtype=None, copy=None):
return np.array(self[...], dtype=dtype, copy=copy)

def islice(self, start=None, end=None):
"""
Expand Down

0 comments on commit 35e8106

Please sign in to comment.