Skip to content

Commit a6e3f0b

Browse files
authored
fix issue with add_mag() using wrong shard shape for zarr2 (#1315)
* fix issue with add_mag() using wrong shard shape for zarr2 * lint and update changelog. * update changelog.
1 parent d3bc88f commit a6e3f0b

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1919
### Changed
2020

2121
### Fixed
22+
- Fixed an issue that creates an Error when `add_mag()` was called just with a `chunk_shape`. [#1315](https://github.com/scalableminds/webknossos-libs/pull/1315)
2223

2324

2425
## [2.3.8](https://github.com/scalableminds/webknossos-libs/releases/tag/v2.3.8) - 2025-05-28

webknossos/tests/dataset/test_layer.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import tensorstore
55

66
import webknossos as wk
7+
from webknossos.dataset.data_format import DataFormat
78

89

910
def test_add_mag_from_zarrarray(tmp_path: Path) -> None:
@@ -62,3 +63,18 @@ def test_add_mag_from_zarrarray(tmp_path: Path) -> None:
6263
assert layer.get_mag("1").info.num_channels == 1
6364
assert layer.get_mag("1").info.dimension_names == ("c", "x", "y", "z")
6465
assert (layer.get_mag("1").read()[0] == zarr_data).all()
66+
67+
68+
def test_add_mag_with_chunk_shape_zarr2(tmp_path: Path) -> None:
69+
dataset = wk.Dataset(
70+
tmp_path / "test_add_mag_with_chunk_shape_zarr2", voxel_size=(10, 10, 10)
71+
)
72+
layer = dataset.add_layer(
73+
"color",
74+
wk.COLOR_CATEGORY,
75+
data_format=DataFormat.Zarr,
76+
bounding_box=wk.BoundingBox((0, 0, 0), (16, 16, 16)),
77+
)
78+
mag = layer.add_mag("1", chunk_shape=(8, 8, 8))
79+
80+
assert mag.info.chunk_shape == (8, 8, 8)

webknossos/webknossos/dataset/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .layer_categories import COLOR_CATEGORY, SEGMENTATION_CATEGORY, LayerCategoryType
2323
from .length_unit import LengthUnit
2424
from .mag_view import MagView
25+
from .properties import VoxelSize
2526
from .remote_folder import RemoteFolder
2627
from .sampling_modes import SamplingModes
2728
from .view import View

webknossos/webknossos/dataset/layer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ def add_mag(
619619
)
620620
if shard_shape is None:
621621
if self.data_format == DataFormat.Zarr:
622-
shard_shape = DEFAULT_CHUNK_SHAPE
622+
shard_shape = chunk_shape
623623
else:
624624
shard_shape = DEFAULT_SHARD_SHAPE
625625

0 commit comments

Comments
 (0)