Skip to content
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

Replace .ds with immutable DatasetView #99

Merged
merged 59 commits into from
Jun 16, 2022

Conversation

TomNicholas
Copy link
Member

@TomNicholas TomNicholas commented May 24, 2022

Initial attempt to change .ds to instead return an immutable view onto the node's data, instead of a mutable dataset.

This closes the part (1) of #80:

No mutation allowed

That immutability also closes #38.

This PR builds on top of #41.

@malmans2
Copy link
Member

malmans2 commented May 25, 2022

@TomNicholas let us know when this is ready for testing - we're also happy to help out with the documentation/example notebooks if that's helpful!

cc: @aurghs

@TomNicholas
Copy link
Member Author

TomNicholas commented Jun 6, 2022

I think this PR is mostly ready to merge, but I want to pin it to the upcoming pre-release of xarray so that the indexing internals are in a well-defined state. This PR also of course depends on #41.

@TomNicholas TomNicholas changed the base branch from initial_integration_refactor to main June 16, 2022 14:46
@TomNicholas TomNicholas merged commit 9a6f674 into xarray-contrib:main Jun 16, 2022
@TomNicholas TomNicholas deleted the datasetview2 branch June 16, 2022 15:27
flamingbear pushed a commit to flamingbear/rewritten-datatree that referenced this pull request Jan 19, 2024
* sketching out changes needed to integrate variables into DataTree

* fixed some other basic conflicts

* fix mypy errors

* can create basic datatree node objects again

* child-variable name collisions dectected correctly

* in-progres

* add _replace method

* updated tests to assert identical instead of check .ds is expected_ds

* refactor .ds setter to use _replace

* refactor init to use _replace

* refactor test tree to avoid init

* attempt at copy methods

* rewrote implementation of .copy method

* xfailing test for deepcopying

* pseudocode implementation of DatasetView

* Revert "pseudocode implementation of DatasetView"

This reverts commit 52ef23baaa4b6892cad2d69c61b43db831044630.

* pseudocode implementation of DatasetView

* removed duplicated implementation of copy

* reorganise API docs

* expose data_vars, coords etc. properties

* try except with calculate_dimensions private import

* add keys/values/items methods

* don't use has_data when .variables would do

* change asserts to not fail just because of differing types

* full sketch of how DatasetView could work

* added tests for DatasetView

* remove commented pseudocode

* explanation of basic properties

* add data structures page to index

* revert adding documentation in favour of that going in a different PR

* correct deepcopy tests

* use .data_vars in copy tests

* add test for arithmetic with .ds

* remove reference to wrapping node in DatasetView

* clarify type through renaming variables

* remove test for out-of-node access

* make imports depend on most recent version of xarray

Co-authored-by: Mattia Almansi <m.almansi@bopen.eu>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove try except for internal import

* depend on latest pre-release of xarray

* correct name of version

* xarray pre-release under pip in ci envs

* correct methods

* whatsnews

* fix fixture in test

* whatsnew

* improve docstrings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: Mattia Almansi <m.almansi@bopen.eu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Name collisions between Dataset variables and child tree nodes
3 participants