home / github

Menu
  • Search all tables
  • GraphQL API

issues

Table actions
  • GraphQL API for issues

2 rows where state = "closed", type = "issue" and user = 4849151 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
322849322 MDU6SXNzdWUzMjI4NDkzMjI= 2129 Using `DataArray.where()` with a DataArray as the condition drops the name jacklovell 4849151 closed 0     4 2018-05-14T14:46:18Z 2020-04-14T08:54:33Z 2020-04-14T08:54:33Z NONE      

Code Sample, a copy-pastable example if possible

Create a boolean DataArray to use as a mask for another DataArray, with the same coordinates:

python da_1 = xr.DataArray(np.array([0.861185, 0.301491, 0.642744, 0.773298, 0.786516, 0.011693, 0.659326, 0.07877 , 0.108488, 0.747863]), coords=[('coord1', np.arange(10))], name='da1') da_2 = xr.DataArray(np.array([0.116959, 0.955742, 0.121562, 0.635573, 0.304895, 0.064529, 0.042461, 0.41751 , 0.607457, 0.110104]), coords=[('coord1', np.arange(10))], name='da2') da_3 = np.rint(da_2).astype('bool') print(da_1) <xarray.DataArray 'da1' (coord1: 10)> array([0.861185, 0.301491, 0.642744, 0.773298, 0.786516, 0.011693, 0.659326, 0.07877 , 0.108488, 0.747863]) Coordinates: * coord1 (coord1) int64 0 1 2 3 4 5 6 7 8 9 print(da_1.where(da_3)) <xarray.DataArray (coord1: 10)> array([ nan, 0.301491, nan, 0.773298, nan, nan, nan, nan, 0.108488, nan]) Coordinates: * coord1 (coord1) int64 0 1 2 3 4 5 6 7 8 9

Problem description

When using a DataArray (da_3 in the example) as the condition in the where() method of another DataArray (da_1), the name of the DataArray being masked (da_1) is dropped.

Expected Output

The name should be retained. python print(da_1.where(da_3)) <xarray.DataArray 'da_1` (coord1: 10)> array([ nan, 0.301491, nan, 0.773298, nan, nan, nan, nan, 0.108488, nan]) Coordinates: * coord1 (coord1) int64 0 1 2 3 4 5 6 7 8 9

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.5.final.0 python-bits: 64 OS: Linux OS-release: 4.13.0-38-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 xarray: 0.10.3 pandas: 0.22.0 numpy: 1.14.3 scipy: 1.1.0 netCDF4: 1.3.2 h5netcdf: None h5py: 2.7.1 Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: 0.17.4 distributed: 1.21.8 matplotlib: 2.2.2 cartopy: None seaborn: 0.8.1 setuptools: 39.1.0 pip: 10.0.1 conda: 4.5.2 pytest: 3.5.1 IPython: 6.4.0 sphinx: 1.7.4
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2129/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue
201617371 MDU6SXNzdWUyMDE2MTczNzE= 1217 Using where() in datasets with dataarrays with different dimensions results in huge RAM consumption jacklovell 4849151 closed 0     6 2017-01-18T16:09:50Z 2019-02-23T07:47:01Z 2019-02-23T07:47:01Z NONE      

I have a dataset containing groups of data with different dimensions. e.g.:

Python ds = xr.Dataset() ds['data1'] = xr.DataArray(data1, coords={'t1': t1}) ds['data2'] = xr.DataArray(data2, coords={'t2': t2})

If I do something like ds.where(ds.data1 < 0.1), Python ends up allocating huge amounts of memory (>30GB for a dataset of <1MB) and seems to loop indefinitely, until the call is interrupted with CTRL-C.

To use where() successfully, I have to use a subset of the dataset with only one dimension.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1217/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 22.121ms · About: xarray-datasette