-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Accessors are recreated on every access #3205
Comments
Yes, I believe this is the case. |
So I guess the questions are:
|
I'm leaning towards (1), unfortunately. Xarray's data model doesn't keep around the |
MCVE Code Sample
test_accessor.py
in current directory with:Expected Output
Based on the xarray accessor documentation I would have assumed that the accessor would stick around on the same DataArray object for the life of the data. My guess is that
Dataset.__getitem__
is recreating theDataArray
every time from the underlyingVariable
object which meansds['a'] is not ds['a']
?Problem Description
I'm currently working on an accessor for a new package called
geoxarray
to address the issues talked about in #2288. One of the cases I'm trying to handle is a NetCDF file with CR standardgrid_mapping
variables. This means that the easiest way to set a CRS object for all variables in a Dataset is to have the Dataset accessor use the accessor of every DataArray (to cache a_crs
property). However, with the way things are working doing something like the below won't work:Output of
xr.show_versions()
xarray: 0.12.3
pandas: 0.25.0
numpy: 1.17.0
scipy: None
netCDF4: 1.5.1.2
pydap: None
h5netcdf: None
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.2.0
distributed: 2.2.0
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
setuptools: 41.0.1
pip: 19.2.2
conda: None
pytest: None
IPython: 7.7.0
sphinx: None
The text was updated successfully, but these errors were encountered: