-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
New properties Dataset.sizes
and DataArray.sizes
#1076
Conversation
numpy.squeeze | ||
""" | ||
if dim is None: | ||
dim = [d for d, s in self.sizes.item() if s == 1] |
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 think items
?
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.
Oops indeed
@@ -110,6 +111,31 @@ def __setitem__(self, key, value): | |||
self.data_array[pos_indexers] = value | |||
|
|||
|
|||
class DataArraySizes(collections.Mapping, formatting.ReprMixin): |
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.
Does this need a separate class that holds the array?
Could it be a dict
of dim-name to dim-size?
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.
Probably not -- could just generate an object on the fly, e.g., Frozen(OrderedDict(zip(self.dims, self.shape)))
. Let me do a quick micro benchmark to see if that has appreciably different performance.
This allows for consistent access to dimension lengths on ``Dataset`` and ``DataArray`` xref pydata#921 (doesn't resolve it 100%, but should help significantly)
Updated to remove the custom class. It makes accessing a single dimension length from |
This allows for consistent access to dimension lengths on
Dataset
andDataArray
xref #921 (doesn't resolve it 100%, but should help significantly)