question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't create weakrefs on DataArrays since xarray 0.13.0

See original GitHub issue

MCVE Code Sample

import xarray as xr
from weakref import ref
arr = xr.DataArray([1, 2, 3])
ref(arr)

Expected Output

I expect the weak reference to be created as in former versions

Problem Description

The above code raises the following exception: TypeError: cannot create weak reference to 'DataArray' object

Output of xr.show_versions()

INSTALLED VERSIONS

commit: None python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-1062.1.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.2

xarray: 0.13.0 pandas: 0.25.1 numpy: 1.17.0 scipy: 1.3.0 netCDF4: 1.5.1.2 pydap: None h5netcdf: 0.7.4 h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudoNetCDF: None rasterio: 1.0.22 cfgrib: None iris: None bottleneck: None dask: 2.3.0 distributed: 2.4.0 matplotlib: 3.1.1 cartopy: 0.17.0 seaborn: None numbagg: None setuptools: 41.2.0 pip: 19.2.3 conda: None pytest: 5.0.1 IPython: 7.8.0 sphinx: None

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mraspaudcommented, Sep 18, 2019

and thanks for the workaround and impressively fast reaction 😃

1reaction
crusaderkycommented, Sep 18, 2019

@mraspaud temporary workaround:

class DataArrayWithWeakRef(xarray.DataArray):
    __slots__ = ("__weakref__", )

a = DataArrayWithWeakRef([1, 2, 3])
ref(a)

<weakref at 0x11e3b1e58; to 'DataArrayWithWeakRef' at 0x11ef3cd68>
Read more comments on GitHub >

github_iconTop Results From Across the Web

What's New - Xarray
Make sure DataArray.name is always a string when used as label for plotting. ... reset_coords(drop=True) does not create indexes (GH6607) ...
Read more >
Time series data — xarray 0.13.0 documentation
When reading or writing netCDF files, xarray automatically decodes datetime and timedelta arrays using CF conventions (that is, by using a units attribute...
Read more >
Build a time-selectable python xarray although time is not a ...
But ds.time.dt.season does not work : "arrays used as indices must ... me since I actually have two other DataArray (IM and IMS)....
Read more >
Coordinate Reference System Management — rioxarray 0.13 ...
Look in the crs attribute and load in the CRS from there. This is for backwards compatibility with xarray.open_rasterio , which is deprecated...
Read more >
- openSUSE Commits - openSUSE Mailing Lists
Hello community, here is the log from the commit of package python-xarray for openSUSE:Factory checked in at 2019-10-24 23:11:38 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found