Skip to content

Commit 4396c74

Browse files
committed
fix: Made Patchly Zarr 3 compatible
1 parent 5fecf9d commit 4396c74

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

patchly/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.18"
1+
__version__ = "0.0.19"
22

33
from patchly.sampler import GridSampler, SamplingMode
44
from patchly.aggregator import Aggregator

patchly/aggregator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

1414
try:
1515
import zarr
16+
TYPE_ZARR_ARRAY = zarr.core.Array if hasattr(zarr.core, "Array") else zarr.core.array.Array
1617
except:
1718
zarr = None
19+
TYPE_ZARR_ARRAY = None
1820

1921

2022
class PatchStatus(Enum):
@@ -427,7 +429,7 @@ def append(self, patch_h: npt.ArrayLike, patch_bbox_s: Union[Tuple, npt.ArrayLik
427429
for chunk_id in self.patch_chunk_dict[str(np.asarray(patch_bbox_s))]["chunks"]:
428430
self.chunk_patch_dict[chunk_id][str(np.asarray(patch_bbox_s))]["status"] = PatchStatus.FILLED
429431
if self.is_chunk_complete(chunk_id):
430-
if zarr is not None and isinstance(self.output_h.data, zarr.core.Array):
432+
if zarr is not None and isinstance(self.output_h.data, TYPE_ZARR_ARRAY):
431433
warnings.warn("Ouput is a Zarr array. Switching to single threading for chunk processing. See issue #39 for more information.") # If issue is solved remove zarr and warnings import statements
432434
self.process_chunk(chunk_id)
433435
else:

patchly/array_like.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99

1010
try:
1111
import zarr
12+
TYPE_ZARR_ARRAY = zarr.core.Array if hasattr(zarr.core, "Array") else zarr.core.array.Array
1213
except:
1314
zarr = None
15+
TYPE_ZARR_ARRAY = None
1416

1517

1618
def create_array_like(array_type, data, device=None):
1719
if array_type == np.ndarray or array_type is None:
1820
return NumpyArray(data, device)
19-
elif zarr is not None and array_type == zarr.core.Array:
21+
elif zarr is not None and array_type == TYPE_ZARR_ARRAY:
2022
return NumpyArray(data, device)
2123
elif torch is not None and array_type == torch.Tensor:
2224
if data is not None:

0 commit comments

Comments
 (0)