Skip to content

Comments

fix: xarray 2024.09.0 compatility#227

Merged
nicrie merged 1 commit intodevelopfrom
fix-datatree-changes
Sep 12, 2024
Merged

fix: xarray 2024.09.0 compatility#227
nicrie merged 1 commit intodevelopfrom
fix-datatree-changes

Conversation

@slevang
Copy link
Contributor

@slevang slevang commented Sep 12, 2024

closes #226

Lot's of changes to datatree on xarray main since the latest release. These 3 all tripped us up:

pydata/xarray#9297
pydata/xarray#9444
pydata/xarray#9476

Maybe it was a little early to enable using the migrated datatree since it's not technically public API yet but I suppose it let's us fix these issues quickly.

# Create a root node for this object with its params as attrs
ds_root = xr.Dataset(attrs=dict(params=self.get_params()))
dt = DataTree(data=ds_root, name=type(self).__name__)
dt = DataTree(ds_root, name=type(self).__name__)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To maintain compatibility with prior versions I changed all cases of data= to be the first positional arg, since the kwarg is now dataset.

dt_transformer = transformer_obj.serialize()
# Place the serialized transformer in the tree
dt[name] = dt_transformer
dt[name].parent = dt
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why I had this here anyways

@slevang slevang requested a review from nicrie September 12, 2024 14:53
@slevang
Copy link
Contributor Author

slevang commented Sep 12, 2024

@nicrie feel free to redirect this to develop if you want to package together with #225

Copy link
Contributor

@nicrie nicrie left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for the quick fix @slevang !

@nicrie nicrie changed the base branch from main to develop September 12, 2024 22:23
@nicrie nicrie merged commit 5ed9753 into develop Sep 12, 2024
@nicrie nicrie deleted the fix-datatree-changes branch September 12, 2024 22:40
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.

TypeError: DataTree.__init__() got an unexpected keyword argument 'data'

2 participants