home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 689384366

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
689384366 MDU6SXNzdWU2ODkzODQzNjY= 4393 Dimension attrs lost when creating new variable with that dimension 13837821 closed 0     2 2020-08-31T17:52:01Z 2020-09-10T17:37:07Z 2020-09-10T17:37:07Z CONTRIBUTOR      

What happened: When creating a new variable based on an existing dimension, the attrs of the dimension are lost.

What you expected to happen: The attrs should be preserved.

Minimal Complete Verifiable Example:

```python import xarray as xr

ds = xr.Dataset() ds['x'] = xr.DataArray(range(10), dims='x') ds['y'] = xr.DataArray(range(len(ds['x'])), dims='x') ds['x'].attrs['foo'] = 'bar' print(ds['x']) # attrs of ds['x'] are preserved

print('\n****\n')

ds = xr.Dataset() ds['x'] = xr.DataArray(range(10), dims='x') ds['x'].attrs['foo'] = 'bar' ds['y'] = xr.DataArray(range(len(ds['x'])), dims='x') print(ds['x']) # attrs of ds['x'] are lost ```

Output of above code: ``` <xarray.DataArray 'x' (x: 10)> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) Coordinates: * x (x) int64 0 1 2 3 4 5 6 7 8 9 Attributes: foo: bar


<xarray.DataArray 'x' (x: 10)> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) Coordinates: * x (x) int64 0 1 2 3 4 5 6 7 8 9 ```

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None libhdf5: 1.10.5 libnetcdf: 4.7.4 xarray: 0.16.0 pandas: 1.0.3 numpy: 1.19.1 scipy: 1.3.1 netCDF4: 1.5.3 pydap: None h5netcdf: 0.8.0 h5py: 2.10.0 Nio: None zarr: None cftime: 1.2.1 nc_time_axis: None PseudoNetCDF: None rasterio: 1.1.3 cfgrib: None iris: None bottleneck: 1.3.2 dask: 2.18.1 distributed: 2.25.0 matplotlib: 3.2.1 cartopy: 0.18.0 seaborn: 0.10.0 numbagg: None pint: 0.15 setuptools: 49.6.0.post20200814 pip: 19.2.2 conda: 4.8.4 pytest: 5.4.1 IPython: 7.14.0 sphinx: None None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4393/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
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 0.551ms · About: xarray-datasette