Skip to content

Commit e67935a

Browse files
authored
Fix deprecation of setting shape on a numpy array in 2.5+ (#3648)
* fix deprecation * add changelog entry
1 parent acdd892 commit e67935a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

changes/3648.misc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix deprecation of setting a shape on an array directly in ``numpy`` 2.5+.

src/zarr/codecs/vlen_utf8.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def _decode_single(
5050
raw_bytes = chunk_bytes.as_array_like()
5151
decoded = _vlen_utf8_codec.decode(raw_bytes)
5252
assert decoded.dtype == np.object_
53-
decoded.shape = chunk_spec.shape
53+
decoded = decoded.reshape(chunk_spec.shape)
5454
as_string_dtype = decoded.astype(chunk_spec.dtype.to_native_dtype(), copy=False)
5555
return chunk_spec.prototype.nd_buffer.from_numpy_array(as_string_dtype)
5656

@@ -95,7 +95,7 @@ async def _decode_single(
9595
raw_bytes = chunk_bytes.as_array_like()
9696
decoded = _vlen_bytes_codec.decode(raw_bytes)
9797
assert decoded.dtype == np.object_
98-
decoded.shape = chunk_spec.shape
98+
decoded = decoded.reshape(chunk_spec.shape)
9999
return chunk_spec.prototype.nd_buffer.from_numpy_array(decoded)
100100

101101
async def _encode_single(

0 commit comments

Comments
 (0)