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

AttributeError accessing data_array.variable #4194

Closed
michaelaye opened this issue Jul 2, 2020 · 3 comments
Closed

AttributeError accessing data_array.variable #4194

michaelaye opened this issue Jul 2, 2020 · 3 comments

Comments

@michaelaye
Copy link

What happened:

accessing variable attribute seems to work but also throws an AttributeError:

AttributeError: 'Variable' object has no attribute 'variable'

What you expected to happen:

According to https://xarray.pydata.org/en/stable/terminology.html all DataArrays should have "an underlying variable that can be accessed via arr.vairable", so I tried that out and got the error.

Minimal Complete Verifiable Example:

Using the example code from the docs:

data = xr.DataArray(np.random.randn(2, 3), dims=('x', 'y'), coords={'x': [10, 20]})
data.variable

Environment:
Python 3.7 on Kubuntu 20.04 using Brave browser in Jupyterlab, up-to-date conda env.

Output of xr.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.7.6 | packaged by conda-forge | (default, Jun 1 2020, 18:57:50)
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-40-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.6
libnetcdf: 4.7.4

xarray: 0.15.1
pandas: 1.0.5
numpy: 1.18.5
scipy: 1.5.0
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.1.3
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.5
cfgrib: None
iris: None
bottleneck: None
dask: 2.19.0
distributed: 2.19.0
matplotlib: 3.2.2
cartopy: 0.18.0
seaborn: 0.10.1
numbagg: None
setuptools: 47.3.1.post20200616
pip: 20.1.1
conda: installed
pytest: 5.4.3
IPython: 7.16.1
sphinx: 3.1.1

image

@dcherian
Copy link
Contributor

dcherian commented Jul 2, 2020

Thanks for the well written report @michaelaye

This has been fixed on master, so I'm closing.

@dcherian dcherian closed this as completed Jul 2, 2020
@keewis
Copy link
Collaborator

keewis commented Jul 2, 2020

see also #3972 and #3973

@michaelaye
Copy link
Author

ah sorry, i tried to search but didn't recognize that as the same thing.

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

No branches or pull requests

3 participants