Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Attribute-like access and ipython autocomplete #98

Merged
merged 44 commits into from
Jan 25, 2023

Conversation

TomNicholas
Copy link
Member

@TomNicholas TomNicholas commented May 24, 2022

Uses xarray's AttrAccessMixin to add attribute-like access to child nodes, data and attrs. Also adds all those items + methods to ipython autocomplete.

@TomNicholas TomNicholas added the enhancement New feature or request label May 24, 2022
@@ -87,6 +91,7 @@ class DataTree(
MappedDatasetMethodsMixin,
MappedDataWithCoords,
DataTreeArithmeticMixin,
AttrAccessMixin,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to inherit from xarray's DataWithCoords here instead, which also inherits from AttrAccessMixin.

I'm guilty of building a heavy dependency on xarray's internals here, but this whole package has that problem so 🤷‍♂️

@TomNicholas TomNicholas deleted the branch xarray-contrib:main June 16, 2022 15:27
@TomNicholas TomNicholas reopened this Jun 16, 2022
@TomNicholas TomNicholas changed the base branch from initial_integration_refactor to main June 16, 2022 15:28
Comment on lines 26 to 27
#elif cls.__module__.startswith("datatree."): # TODO reinstate this once integrated upstream
# raise AttributeError(f"{cls.__name__} must explicitly define __slots__")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire file is here just so I can get rid of this erorr/warning below...

@TomNicholas TomNicholas merged commit eb562be into xarray-contrib:main Jan 25, 2023
@TomNicholas TomNicholas deleted the attraccess branch January 25, 2023 20:16
flamingbear pushed a commit to flamingbear/rewritten-datatree that referenced this pull request Jan 19, 2024
…e#98

* 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

* attribute-like access

* test for accessing attrs

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

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

* pseudocode implementation of DatasetView

* Revert "pseudocode implementation of DatasetView"

This reverts commit 52ef23baaa4b6892cad2d69c61b43db831044630.

* removed duplicated implementation of copy

* reorganise API docs

* expose data_vars, coords etc. properties

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

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

* try except with calculate_dimensions private import

* add keys/values/items methods

* don't use has_data when .variables would do

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

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

* attribute-like access now working

* include attribute-like access in docs

* silence warning about slots

* should have been in last commit

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

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

* whatsnew

* make typing compatible with 3.8

* got string file path completion working

* test ipython key completions

* note about supporting auto-completion of relative paths in future

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant