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 adding multiple frame axes #1808

Merged
merged 1 commit into from
Feb 5, 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
2 changes: 1 addition & 1 deletion sources/zarr/large_image_source_zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False, **kwargs):

def _validateNewTile(self, tile, mask, placement, axes):
if not isinstance(tile, np.ndarray) or axes is None:
axes = 'yxs'
axes = self._axes if hasattr(self, '_axes') else 'yxs'
tile, mode = _imageToNumpy(tile)
elif not isinstance(axes, str) and not isinstance(axes, list):
err = 'Invalid type for axes. Must be str or list[str].'
Expand Down
8 changes: 8 additions & 0 deletions test/test_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ def testXYAxis():
assert metadata['IndexStride']['IndexXY'] == 1


def testMultiFrameAxes():
sink = large_image_source_zarr.new()
sink.addTile(np.random.random((256, 256)), 0, 0, q=1)
assert sink.metadata.get('IndexRange') == dict(IndexQ=2)
sink.addTile(np.random.random((256, 256)), 0, 0, r=1)
assert sink.metadata.get('IndexRange') == dict(IndexQ=2, IndexR=2)


@pytest.mark.parametrize('file_type', FILE_TYPES)
def testCrop(file_type, tmp_path):
output_file = tmp_path / f'test.{file_type}'
Expand Down