-
Notifications
You must be signed in to change notification settings - Fork 41
add_bounds
uses keys
rather than dims
#221
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #221 +/- ##
=======================================
Coverage 96.45% 96.46%
=======================================
Files 12 12
Lines 1551 1555 +4
=======================================
+ Hits 1496 1500 +4
Misses 55 55
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Thanks @malmans2 looks OK, just one minor suggestion. Can you add a whats-new note.
cf_xarray/accessor.py
Outdated
dimensions = set() | ||
for key in keys: | ||
dimensions |= set( | ||
apply_mapper(_get_dims, self._obj, key, error=False, default=[key]) | ||
) |
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.
A set comprehension is cleaner here
dimensions = set() | |
for key in keys: | |
dimensions |= set( | |
apply_mapper(_get_dims, self._obj, key, error=False, default=[key]) | |
) | |
dimensions = { | |
apply_mapper(_get_dims, self._obj, key, error=False, default=[key]) | |
for key in keys | |
) |
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.
Actually shouldn't the default be key
instead of [key]
given that you're doing set subttraction 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.
apply_mapper
returns a list of dimension names, shouldn't default
do the same?
Regarding the set comprehension, this wouldn't work: {["dim1", "dim2"], ["dim3"]}
.
How about this?
dimensions = {dim for key in keys for dim in apply_mapper(_get_dims, self._obj, key, error=False, default=[key])}
Or we could use update:
dimensions = set()
for key in keys:
dimensions.update(apply_mapper(_get_dims, self._obj, key, error=False, default=[key]))
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 like update
* upstream/main: Update README.rst Add earthcube 2021 notebook link to readme v0.5.2 Some CMIP6 support Add pooch to binder environment (xarray-contrib#223) `add_bounds` uses `keys` rather than `dims` (xarray-contrib#221)
* main: (57 commits) Add CITATION.cff, tributors, zenodo.json (xarray-contrib#231) Add zenodo badge Improve `rename_like` (xarray-contrib#222) Don't apply mappers to DataArrays (xarray-contrib#227) Add unit support to cf-xarray (xarray-contrib#197) Update README.rst Add earthcube 2021 notebook link to readme v0.5.2 Some CMIP6 support Add pooch to binder environment (xarray-contrib#223) `add_bounds` uses `keys` rather than `dims` (xarray-contrib#221) Add .cf.formula_terms (xarray-contrib#213) Update whats-new.rst (xarray-contrib#217) add bounds property (xarray-contrib#214) Update some tests. Compile regexes Fix black Add __version__ (xarray-contrib#208) add skip to rename_like (xarray-contrib#206) Refactor out coordinate criteria to criteria.py (xarray-contrib#205) ...
No description provided.