home / github

Menu
  • GraphQL API
  • Search all tables

issues

Table actions
  • GraphQL API for issues

2 rows where repo = 13221727 and user = 8898319 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 2

  • issue 1
  • pull 1

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
387673324 MDExOlB1bGxSZXF1ZXN0MjM2MTA3NzYy 2590 use keep_attrs in binary operations II MBlaschek 8898319 closed 0     6 2018-12-05T09:47:46Z 2018-12-13T07:16:23Z 2018-12-12T17:11:22Z CONTRIBUTOR   0 pydata/xarray/pulls/2590
  • [x] Closes #2582
  • [x] Tests added (test_binary_ops_keep_attrs)

Please revise and advise.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2590/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 pull
385716625 MDU6SXNzdWUzODU3MTY2MjU= 2582 Keep attributes across operations MBlaschek 8898319 closed 0     6 2018-11-29T12:36:32Z 2018-12-12T17:11:22Z 2018-12-12T17:11:22Z CONTRIBUTOR      

The Problem

When I have two DataArrays and I use a standard operation (+, - ,*, /) the attributes vanish. I think that should not be the case. Even when using as suggested the set_options

```python import numpy as np import xarray as xr a = xr.DataArray(np.random.randn(3,3), dims=('x','y'), name='temp', attrs={'units':'K'}) b = xr.DataArray(np.random.randn(3,3), dims=('x','y'), name='temp', attrs={'units':'K'}) print(a) <xarray.DataArray 'temp' (x: 3, y: 3)> array([[ 1.207407, -1.9429 , 3.168454], [-0.773912, -0.121835, -0.139538], [ 1.823002, 0.185846, 0.53569 ]]) Dimensions without coordinates: x, y Attributes: units: K print(a-b) <xarray.DataArray 'temp' (x: 3, y: 3)> array([[ 1.280892, -1.097781, 2.150318], [-0.208202, -0.03856 , 0.805856], [ 2.192506, 1.049181, 2.277078]]) Dimensions without coordinates: x, y

with xr.set_options(keep_attrs=True): print(a-b)

<xarray.DataArray 'temp' (x: 3, y: 3)> array([[ 1.280892, -1.097781, 2.150318], [-0.208202, -0.03856 , 0.805856], [ 2.192506, 1.049181, 2.277078]]) Dimensions without coordinates: x, y ```

Problem description

Attributes vanish when a normal operation is applied! From docs of set_options: keep_attrs: rule for whether to keep attributes on xarray Datasets/dataarrays after operations. Either True to always keep attrs, False to always discard them, or 'default' to use original logic that attrs should only be kept in unambiguous circumstances. Default: 'default'.

Expected Output

The Attributes should remain. Maybe keep only attributes from the left Array ? Please adjust or advise me.

Output of xr.show_versions()

`` xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.6.6.final.0 python-bits: 64 OS: Linux OS-release: 4.15.0-39-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 xarray: 0.11.0 pandas: 0.23.4 numpy: 1.15.4 scipy: 1.1.0 netCDF4: 1.4.2 h5netcdf: None h5py: 2.8.0 Nio: None zarr: None cftime: 1.0.2.1 PseudonetCDF: None rasterio: None iris: None bottleneck: 1.2.1 cyordereddict: None dask: 0.20.2 distributed: 1.24.2 matplotlib: 3.0.1 cartopy: 0.16.0 seaborn: 0.9.0 setuptools: 40.6.2 pip: 18.1 conda: 4.5.11 pytest: 4.0.0 IPython: 7.1.1 sphinx: 1.8.2 ``
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2582/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 47.579ms · About: xarray-datasette