home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 759270347

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
759270347 MDU6SXNzdWU3NTkyNzAzNDc= 4660 RecursionError when defining __slots__ on subclass using Containment 47473455 closed 0     4 2020-12-08T09:17:12Z 2021-01-20T08:27:01Z 2021-01-12T00:31:01Z NONE      

What happened: Inheritance of xarray.Dataset request the addition of __slots__: python /home/borja/miniconda3/envs/o3as/lib/python3.6/abc.py:133: FutureWarning: xarray subclass Model should explicitly define __slots__ cls = super().__new__(mcls, name, bases, namespace, **kwargs) /home/borja/Projects/o3skim/o3skim/sources.py:77: FutureWarning: Setting attribute 'dataset' on a 'Model' object. Explicitly define __slots__ to suppress this warning for legitimate custom attributes and raise an error when attempting variables assignments. self.dataset = ds however when added, produces RecursionError.

What you expected to happen: It should be possible to use Containment & Delegation on xarray classes.

Minimal Complete Verifiable Example: ```python import xarray

class MyDSet(xarray.Dataset): slots = ['dataset',] def init(self, ds): self.dataset = ds

def __getattr__(self, k):
    return getattr(self.dataset, k)

def __setattr__(self, k, v):
    setattr(self.dataset, k, v)

Returns:py

reload(mytest) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/borja/miniconda3/envs/o3as/lib/python3.6/importlib/init.py", line 166, in reload _bootstrap._exec(spec, module) File "<frozen importlib._bootstrap>", line 618, in _exec File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/borja/Projects/o3skim/o3skim/mytest.py", line 3, in <module> class BCorrect(xarray.Dataset): File "/home/borja/miniconda3/envs/o3as/lib/python3.6/typing.py", line 978, in new self = super().new(cls, name, bases, namespace, _root=True) File "/home/borja/miniconda3/envs/o3as/lib/python3.6/typing.py", line 137, in new return super().new(cls, name, bases, namespace) File "/home/borja/miniconda3/envs/o3as/lib/python3.6/abc.py", line 133, in new cls = super().new(mcls, name, bases, namespace, **kwargs) File "/home/borja/miniconda3/envs/o3as/lib/python3.6/site-packages/xarray/core/common.py", line 199, in init_subclass if not hasattr(object.new(cls), "dict"): File "/home/borja/Projects/o3skim/o3skim/mytest.py", line 9, in getattr return getattr(self.dataset, k) File "/home/borja/Projects/o3skim/o3skim/mytest.py", line 9, in getattr return getattr(self.dataset, k) File "/home/borja/Projects/o3skim/o3skim/mytest.py", line 9, in getattr return getattr(self.dataset, k) [Previous line repeated 325 more times] RecursionError: maximum recursion depth exceeded ```

Anything else we need to know?: I would recommend to add the following test or similar to ensure it is working: ```python

class X(xarray.Dataset): slots = ['dataset'] def init(self, ds): self.dataset = ds

ds = xarray.Dataset() x = X(ds) ```

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.6.12 |Anaconda, Inc.| (default, Sep 8 2020, 23:10:56) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 5.4.0-56-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.5 libnetcdf: 4.6.3 xarray: 0.16.2 pandas: 1.1.4 numpy: 1.19.4 scipy: 1.5.4 netCDF4: 1.5.4 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.3.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.30.0 distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None pint: None setuptools: 51.0.0.post20201207 pip: 20.3.1 conda: None pytest: 6.1.2 IPython: None sphinx: 3.2.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4660/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 1.032ms · About: xarray-datasette