home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 698263021

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
698263021 MDU6SXNzdWU2OTgyNjMwMjE= 4415 Adding new DataArray to a Dataset removes attrs of existing coord 3958036 closed 0     3 2020-09-10T17:21:32Z 2020-09-10T17:38:08Z 2020-09-10T17:38:08Z CONTRIBUTOR      

Minimal Complete Verifiable Example: ``` import numpy as np import xarray as xr

ds = xr.Dataset() ds["a"] = xr.DataArray(np.linspace(0., 1.), dims="x")

ds["x"] = xr.DataArray(np.linspace(0., 2., len(ds["x"])), dims="x") ds["x"].attrs["foo"] = "bar"

print(ds["x"])

ds["b"] = xr.DataArray(np.linspace(0., 1.), dims="x")

print(ds["x"]) ```

What happened: Attribute "foo" is present at the first print, but missing in the second, after adding b to ds.

full output</tt> ``` <xarray.DataArray 'x' (x: 50)> array([0. , 0.040816, 0.081633, 0.122449, 0.163265, 0.204082, 0.244898, 0.285714, 0.326531, 0.367347, 0.408163, 0.44898 , 0.489796, 0.530612, 0.571429, 0.612245, 0.653061, 0.693878, 0.734694, 0.77551 , 0.816327, 0.857143, 0.897959, 0.938776, 0.979592, 1.020408, 1.061224, 1.102041, 1.142857, 1.183673, 1.22449 , 1.265306, 1.306122, 1.346939, 1.387755, 1.428571, 1.469388, 1.510204, 1.55102 , 1.591837, 1.632653, 1.673469, 1.714286, 1.755102, 1.795918, 1.836735, 1.877551, 1.918367, 1.959184, 2. ]) Coordinates: * x (x) float64 0.0 0.04082 0.08163 0.1224 ... 1.878 1.918 1.959 2.0 Attributes: foo: bar <xarray.DataArray 'x' (x: 50)> array([0. , 0.040816, 0.081633, 0.122449, 0.163265, 0.204082, 0.244898, 0.285714, 0.326531, 0.367347, 0.408163, 0.44898 , 0.489796, 0.530612, 0.571429, 0.612245, 0.653061, 0.693878, 0.734694, 0.77551 , 0.816327, 0.857143, 0.897959, 0.938776, 0.979592, 1.020408, 1.061224, 1.102041, 1.142857, 1.183673, 1.22449 , 1.265306, 1.306122, 1.346939, 1.387755, 1.428571, 1.469388, 1.510204, 1.55102 , 1.591837, 1.632653, 1.673469, 1.714286, 1.755102, 1.795918, 1.836735, 1.877551, 1.918367, 1.959184, 2. ]) Coordinates: * x (x) float64 0.0 0.04082 0.08163 0.1224 ... 1.878 1.918 1.959 2.0 ```

What you expected to happen: Coordinate x should be unchanged.

full expected output</tt> ``` <xarray.DataArray 'x' (x: 50)> array([0. , 0.040816, 0.081633, 0.122449, 0.163265, 0.204082, 0.244898, 0.285714, 0.326531, 0.367347, 0.408163, 0.44898 , 0.489796, 0.530612, 0.571429, 0.612245, 0.653061, 0.693878, 0.734694, 0.77551 , 0.816327, 0.857143, 0.897959, 0.938776, 0.979592, 1.020408, 1.061224, 1.102041, 1.142857, 1.183673, 1.22449 , 1.265306, 1.306122, 1.346939, 1.387755, 1.428571, 1.469388, 1.510204, 1.55102 , 1.591837, 1.632653, 1.673469, 1.714286, 1.755102, 1.795918, 1.836735, 1.877551, 1.918367, 1.959184, 2. ]) Coordinates: * x (x) float64 0.0 0.04082 0.08163 0.1224 ... 1.878 1.918 1.959 2.0 Attributes: foo: bar <xarray.DataArray 'x' (x: 50)> array([0. , 0.040816, 0.081633, 0.122449, 0.163265, 0.204082, 0.244898, 0.285714, 0.326531, 0.367347, 0.408163, 0.44898 , 0.489796, 0.530612, 0.571429, 0.612245, 0.653061, 0.693878, 0.734694, 0.77551 , 0.816327, 0.857143, 0.897959, 0.938776, 0.979592, 1.020408, 1.061224, 1.102041, 1.142857, 1.183673, 1.22449 , 1.265306, 1.306122, 1.346939, 1.387755, 1.428571, 1.469388, 1.510204, 1.55102 , 1.591837, 1.632653, 1.673469, 1.714286, 1.755102, 1.795918, 1.836735, 1.877551, 1.918367, 1.959184, 2. ]) Coordinates: * x (x) float64 0.0 0.04082 0.08163 0.1224 ... 1.878 1.918 1.959 2.0 Attributes: foo: bar ```

Anything else we need to know?:

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 | packaged by conda-forge | (default, Jun 1 2020, 18:57:50) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 5.4.0-47-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.4 xarray: 0.16.0 pandas: 1.1.1 numpy: 1.18.5 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: 1.2.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.23.0 distributed: 2.25.0 matplotlib: 3.2.2 cartopy: None seaborn: None numbagg: None pint: 0.13 setuptools: 49.6.0.post20200814 pip: 20.2.3 conda: 4.8.4 pytest: 5.4.3 IPython: 7.15.0 sphinx: 3.2.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4415/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
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.627ms · About: xarray-datasette