-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add ._copy
method and _bounds
attr to DataArrayBoundsAccessor
#98
Conversation
Codecov Report
@@ Coverage Diff @@
## main #98 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 180 163 -17
=========================================
- Hits 180 163 -17
Continue to review full report at Codecov.
|
- Add `.copy()` method to DataArrayBoundsAccessor Add `copy_variable` function
f359dd5
to
4d40673
Compare
# A Dataset container to store the bounds from the parent Dataset. | ||
# A Dataset is used instead of a dictionary so that it is interoperable | ||
# with cf_xarray and the DatasetBoundsAccessor class. This allows for | ||
# the dynamic generation of a bounds dict that is name-agnostic (e.g., | ||
# "lat", "latitude", "Y" for latitude bounds). Refer to the ``bounds`` | ||
# class property below for more information. | ||
self._bounds = xr.Dataset() |
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.
Added this comment for developers in case this confuses them on why a Dataset is being stored inside a DataArray accessor class (think of it as just a container, like a dict).
@tomvothecoder - looks good to me! I noticed that within |
Description
This PR removes adding the bounds dimension and bounds variables (as coordinates) to the DataArray in
DataArrayBoundsAccessor
. Instead, a separate_bounds
dataset stores the bounds. The advantage of using a dataset is that we can leverage methods ofcf_xarray
andDatasetBoundsAccessor
.To retain the attributes of an accessor class when copying a variable, each class must have a
.copy()
method to return a copy of the xarray data structure with cached attributes. There is also acopy_variable()
function to handle this for the user so they don't have to invoke each of the individual.copy()
methods themself.Checklist
If applicable: