-
Notifications
You must be signed in to change notification settings - Fork 8
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
ImageArray Initialization #261
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -310,20 +310,28 @@ def close(self): | |||||||
class ImageArray(zarr.Array): | ||||||||
"""Container object for image stored as a zarr array (up to 5D)""" | ||||||||
|
||||||||
def __init__(self, zarray: zarr.Array): | ||||||||
super().__init__( | ||||||||
store=zarray._store, | ||||||||
path=zarray._path, | ||||||||
read_only=zarray._read_only, | ||||||||
chunk_store=zarray._chunk_store, | ||||||||
synchronizer=zarray._synchronizer, | ||||||||
cache_metadata=zarray._cache_metadata, | ||||||||
cache_attrs=zarray._attrs.cache, | ||||||||
partial_decompress=zarray._partial_decompress, | ||||||||
write_empty_chunks=zarray._write_empty_chunks, | ||||||||
zarr_version=zarray._version, | ||||||||
meta_array=zarray._meta_array, | ||||||||
) | ||||||||
def __init__(self, zarray: zarr.Array = None, **kwargs): | ||||||||
"""Keyword arguments are passed to the zarr.Array constructor. | ||||||||
If a zarr.Array is provided, the constructor will use its attributes | ||||||||
to initialize the ImageArray. | ||||||||
""" | ||||||||
if zarray is not None: | ||||||||
kwargs.update( | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
{ | ||||||||
"store": zarray._store, | ||||||||
"path": zarray._path, | ||||||||
"read_only": zarray._read_only, | ||||||||
"chunk_store": zarray._chunk_store, | ||||||||
"synchronizer": zarray._synchronizer, | ||||||||
"cache_metadata": zarray._cache_metadata, | ||||||||
"cache_attrs": zarray._attrs.cache, | ||||||||
"partial_decompress": zarray._partial_decompress, | ||||||||
"write_empty_chunks": zarray._write_empty_chunks, | ||||||||
"zarr_version": zarray._version, | ||||||||
"meta_array": zarray._meta_array, | ||||||||
} | ||||||||
) | ||||||||
super().__init__(**kwargs) | ||||||||
self._get_dims() | ||||||||
|
||||||||
def _get_dims(self): | ||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain when this method should be called without a argument? It is an internal wrapper, and if you don't need the wrapper, just doing
Position.zgroup["0"]
would give you the plainzarr.Array
object.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dask may expect exactly
zarr.Array
and not a wrapped subclass for some of their internal logic. I think it's safer to match their advertised API than hacking our own wrapper.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an example use case at the top and a short docstring to the
__init__
function:I think this is a common enough use case, such that we should make iohub arrays work with the dask arrays in multiprocessing applications