1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Tue, 11 Mar 2025 07:39:17 +0000
Subject: Fix compatibility with zarr3
Origin: https://github.com/astropy/reproject/pull/487
Forwarded: not-needed
---
reproject/common.py | 2 +-
reproject/utils.py | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/reproject/common.py b/reproject/common.py
index e4f2967..5f4cf5d 100644
--- a/reproject/common.py
+++ b/reproject/common.py
@@ -300,7 +300,7 @@ def _reproject_dispatcher(
reproject_single_block,
array_out_dask,
array_in_or_path,
- dtype=float,
+ dtype="<f8",
new_axis=0,
chunks=(2,) + array_out_dask.chunksize,
)
diff --git a/reproject/utils.py b/reproject/utils.py
index b542885..91cc7d7 100644
--- a/reproject/utils.py
+++ b/reproject/utils.py
@@ -31,6 +31,11 @@ def _dask_to_numpy_memmap(dask_array, tmp_dir):
if isinstance(dask_array.ravel()[0].compute(), da.Array):
dask_array = dask_array.compute()
+ # Cast the dask array to regular float for two reasons - first, zarr 3.0.0
+ # and later doesn't support big-endian arrays, and also we need to anyway
+ # make a native float memory mapped array below.
+ dask_array = dask_array.astype("<f8", copy=False)
+
# NOTE: here we use a new TemporaryDirectory context manager for the zarr
# array because we can remove the temporary directory straight away after
# converting the input to a Numpy memory mapped array.
@@ -53,7 +58,7 @@ def _dask_to_numpy_memmap(dask_array, tmp_dir):
memmapped_array = np.memmap(
memmap_path,
- dtype=zarr_array.dtype,
+ dtype=float,
shape=zarr_array.shape,
mode="w+",
)
|