diff --git a/changes/3648.misc.md b/changes/3648.misc.md new file mode 100644 index 0000000000..156f8671de --- /dev/null +++ b/changes/3648.misc.md @@ -0,0 +1 @@ +Fix deprecation of setting a shape on an array directly in ``numpy`` 2.5+. diff --git a/src/zarr/codecs/vlen_utf8.py b/src/zarr/codecs/vlen_utf8.py index fa1a229855..d8e6072333 100644 --- a/src/zarr/codecs/vlen_utf8.py +++ b/src/zarr/codecs/vlen_utf8.py @@ -50,7 +50,7 @@ async def _decode_single( raw_bytes = chunk_bytes.as_array_like() decoded = _vlen_utf8_codec.decode(raw_bytes) assert decoded.dtype == np.object_ - decoded.shape = chunk_spec.shape + decoded = decoded.reshape(chunk_spec.shape) as_string_dtype = decoded.astype(chunk_spec.dtype.to_native_dtype(), copy=False) return chunk_spec.prototype.nd_buffer.from_numpy_array(as_string_dtype) @@ -95,7 +95,7 @@ async def _decode_single( raw_bytes = chunk_bytes.as_array_like() decoded = _vlen_bytes_codec.decode(raw_bytes) assert decoded.dtype == np.object_ - decoded.shape = chunk_spec.shape + decoded = decoded.reshape(chunk_spec.shape) return chunk_spec.prototype.nd_buffer.from_numpy_array(decoded) async def _encode_single(