Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zarr Sink addTile when no samples axis is specified #1805

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sources/zarr/large_image_source_zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ def _validateNewTile(self, tile, mask, placement, axes):
axes = [x.lower() for x in axes]
if axes[-1] != 's':
axes.append('s')
tile = tile[..., np.newaxis]
if mask is not None and len(axes) - 1 == len(mask.shape):
mask = mask[:, :, np.newaxis]
if 'x' not in axes or 'y' not in axes:
Expand Down
9 changes: 9 additions & 0 deletions test/test_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ def testAddTileWithLevel():
assert arrays.get('1') is None


def testNoSamplesAxis(tmp_path):
output_file = tmp_path / 'test.tiff'
sink = large_image_source_zarr.new()
data = np.zeros((4, 1040, 1388))
sink.addTile(data, 0, 0, axes=['c', 'y', 'x'])
sink.write(output_file)
assert sink.metadata.get('bandCount') == 1


def testExtraAxis():
sink = large_image_source_zarr.new()
sink.addTile(np.random.random((256, 256)), 0, 0, z=1)
Expand Down