-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix axes configuration when adding existing zarr arrays (#1204)
* Change default behaviour for axes when creating zarrita array. * add typehint. * Update changelog. * Add test. * Fix type annotations for added test.
- Loading branch information
Showing
5 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
from zarrita import Array | ||
|
||
import webknossos as wk | ||
|
||
|
||
def test_add_mag_from_zarrarray(tmp_path: Path) -> None: | ||
dataset = wk.Dataset( | ||
tmp_path / "test_add_mag_from_zarrarray", voxel_size=(10, 10, 10) | ||
) | ||
layer = dataset.add_layer( | ||
"color", | ||
wk.COLOR_CATEGORY, | ||
data_format="zarr3", | ||
bounding_box=wk.BoundingBox((0, 0, 0), (16, 16, 16)), | ||
) | ||
zarr_mag_path = tmp_path / "zarr_data" / "mag1.zarr" | ||
zarr_data = np.random.randint(0, 255, (16, 16, 16), dtype="uint8") | ||
zarr_mag = Array.create( | ||
store=zarr_mag_path, shape=(16, 16, 16), chunk_shape=(8, 8, 8), dtype="uint8" | ||
) | ||
zarr_mag[:] = zarr_data | ||
|
||
layer.add_mag_from_zarrarray("1", zarr_mag_path, extend_layer_bounding_box=False) | ||
|
||
assert layer.get_mag("1").read().shape == (1, 16, 16, 16) | ||
assert layer.get_mag("1").info.num_channels == 1 | ||
assert layer.get_mag("1").info.dimension_names == ("c", "x", "y", "z") | ||
assert (layer.get_mag("1").read()[0] == zarr_data).all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters