home / github

Menu
  • GraphQL API
  • Search all tables

issues

Table actions
  • GraphQL API for issues

2 rows where state = "closed", type = "issue" and user = 32801740 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date), closed_at (date)

type 1

  • issue · 2 ✖

state 1

  • closed · 2 ✖

repo 1

  • xarray 2
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
776520994 MDU6SXNzdWU3NzY1MjA5OTQ= 4741 Attribute style access is slow rhkleijn 32801740 closed 0     2 2020-12-30T15:52:07Z 2021-01-05T23:00:29Z 2021-01-05T23:00:29Z CONTRIBUTOR      

I appreciate xarray's ability to use attribute style access ds.foo as an alternative to ds["foo"] as it requires less characters/keystrokes and has less 'visual clutter'.

A drawback is that it can be much slower as lookup time seems to display O(n) behaviour instead of O(1) with n being the number of variables in the dataset. For e.g. n=100 it is approximately 100 times slower than dictionary-style access:

# Dataset with many (100) variables
ds = xr.Dataset({f'var{v}': [] for v in range(100)})

%timeit ds['var0']
462 µs ± 1.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

%timeit ds.var0
47.1 ms ± 205 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

dir() and _ipython_key_completions_() which are used for e.g. tab completion in iPython are equally slow:

%timeit dir(ds)
47 ms ± 163 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

%timeit ds._ipython_key_completions_()
46.8 ms ± 210 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

I would like to see xarray having much better performance for attribute style access.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4741/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue
755607271 MDU6SXNzdWU3NTU2MDcyNzE= 4644 astype method lost its order parameter rhkleijn 32801740 closed 0     7 2020-12-02T21:02:02Z 2020-12-16T16:33:00Z 2020-12-16T16:33:00Z CONTRIBUTOR      

What happened: I upgraded from xarray 0.15.1 to 0.16.2 and the astype method seems to have lost the order parameter.

```python In [1]: import xarray as xr

In [2]: xr.version Out[2]: '0.16.2'

In [3]: xr.DataArray([[1.0, 2.0], [3.0, 4.0]]).astype(dtype='d', order='F').values.strides

TypeError Traceback (most recent call last) <ipython-input-3-208ab49008ef> in <module> ----> 1 xr.DataArray([[1.0, 2.0], [3.0, 4.0]]).astype(dtype='d', order='F').values.strides

TypeError: astype() got an unexpected keyword argument 'order' ```

What you expected to happen: I was expecting to get the same result as with xarray 0.15.1:

```python In [1]: import xarray as xr

In [2]: xr.version Out[2]: '0.15.1'

In [3]: xr.DataArray([[1.0, 2.0], [3.0, 4.0]]).astype(dtype='d', order='F').values.strides Out[3]: (8, 16) ```

Anything else we need to know?: Looking at the documentation it seems it disappeared between 0.16.0 and 0.16.1. The documentation at http://xarray.pydata.org/en/v0.16.0/generated/xarray.DataArray.astype.html still has this snippet

order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout order of the result. ‘C’ means C order, ‘F’ means Fortran order, ‘A’ means ‘F’ order if all the arrays are Fortran contiguous, ‘C’ order otherwise, and ‘K’ means as close to the order the array elements appear in memory as possible. Default is ‘K’.

(which was identical to the documentation from numpy.ndarray.astype at https://numpy.org/doc/stable/reference/generated/numpy.ndarray.astype.html)

while http://xarray.pydata.org/en/v0.16.1/generated/xarray.DataArray.astype.html seems to lack that part.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4644/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 878.6ms · About: xarray-datasette