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

Add an attrs keyword argument to the constructor: DataTree(attrs={}) #333

Closed
eschalkargans opened this issue May 16, 2024 · 1 comment
Closed

Comments

@eschalkargans
Copy link

Motive

Possibility to add attrs on DataTree instanciation. It is feasible with DataArray and Dataset.

Examples:

print(xr.DataArray([], attrs={"my_attr": 1}))

<xarray.DataArray (dim_0: 0)>
array([], dtype=float64)
Dimensions without coordinates: dim_0
Attributes:
    my_attr:  1

print(xr.Dataset({}, attrs={"my_attr": 1}))

<xarray.Dataset>
Dimensions:  ()
Data variables:
    *empty*
Attributes:
    my_attr:  1

print(dt.DataTree({}, attrs={"my_attr": 1}))

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[21], [line 1](vscode-notebook-cell:?execution_count=21&line=1)
----> [1](vscode-notebook-cell:?execution_count=21&line=1) print(dt.DataTree({}, attrs={"my_attr": 1}))

TypeError: DataTree.__init__() got an unexpected keyword argument 'attrs'
@eschalkargans
Copy link
Author

Closing ; reason: pydata/xarray#9242 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant