-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
DataTree.coords.__setitem__
by adding DataTreeCoordinates
cla…
…ss (#9451) * add a DataTreeCoordinates class * passing read-only properties tests * tests for modifying in-place * WIP making the modification test pass * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * get to the delete tests * test * improve error message * implement delitem * test KeyError * subclass Coordinates instead of DatasetCoordinates * use Frozen(self._data._coord_variables) * Simplify when to raise KeyError Co-authored-by: Stephan Hoyer <[email protected]> * correct bug in suggestion * Update xarray/core/coordinates.py Co-authored-by: Stephan Hoyer <[email protected]> * simplify _update_coords by creating new node data first * update indexes correctly * passes test * update ._drop_indexed_coords * some mypy fixes * remove the apparently-unused _drop_indexed_coords method * fix import error * test that Dataset and DataArray constructors can handle being passed a DataTreeCoordinates object * test dt.coords can be passed to DataTree constructor * improve readability of inline comment * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * initial tests with inherited coords * ignore typeerror indicating dodgy inheritance * try to avoid Unbound type error * cast return value correctly * cehck that .coords works with inherited coords * fix data->dataset * fix return type of __getitem__ * Use .dataset instead of .to_dataset() Co-authored-by: Stephan Hoyer <[email protected]> * _check_alignment -> check_alignment * remove dict comprehension Co-authored-by: Stephan Hoyer <[email protected]> * KeyError message formatting Co-authored-by: Stephan Hoyer <[email protected]> * keep generic types for .dims and .sizes * test verifying you cant delete inherited coord * fix mypy complaint * type hint as accepting objects * update note about .dims returning all dims --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Stephan Hoyer <[email protected]>
- Loading branch information
1 parent
fac2c89
commit 781877c
Showing
3 changed files
with
293 additions
and
30 deletions.
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
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
Oops, something went wrong.