diff --git a/docs/release.rst b/docs/release.rst index fcd3422f..b9de7569 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -17,6 +17,13 @@ Release notes Unreleased ---------- + +Fixes +~~~~~ + +* Fix Zarr serialization with ZFP when array is a view. + By :user:`Altay Sansal `, :issue:`812` + .. _release_0.16.5: 0.16.5 diff --git a/numcodecs/zfpy.py b/numcodecs/zfpy.py index 80a1e78a..ab84d5f2 100644 --- a/numcodecs/zfpy.py +++ b/numcodecs/zfpy.py @@ -77,13 +77,16 @@ def encode(self, buf): "The zfp codec does not support none numpy arrays." f" Your buffers were {type(buf)}." ) - if buf.flags.c_contiguous: - flatten = False - else: + if buf.flags.f_contiguous: raise ValueError( "The zfp codec does not support F order arrays. " f"Your arrays flags were {buf.flags}." ) + # Force C-contiguous if needed (copies only if not already C-contiguous) + buf = np.ascontiguousarray(buf) + + # No flattening needed for C-order + flatten = False buf = ensure_contiguous_ndarray(buf, flatten=flatten) # do compression