Skip to content

Commit

Permalink
Merge pull request #1808 from girder/zarr-sink-multi-frame-axes
Browse files Browse the repository at this point in the history
Fix Zarr Sink adding multiple frame axes
  • Loading branch information
annehaley authored Feb 5, 2025
2 parents 1c4e834 + 5f85660 commit 27e4963
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 27e4963

Please sign in to comment.