home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 407085814

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
407085814 MDU6SXNzdWU0MDcwODU4MTQ= 2748 Inconsistent name behavior in masking 6164157 closed 0     2 2019-02-06T05:25:47Z 2019-02-11T19:05:40Z 2019-02-11T19:05:40Z CONTRIBUTOR      

Code Sample, a copy-pastable example if possible

Consider the following 4 ways to mask an DataArray:

```python import xarray as xr

ds=xr.Dataset({'a': (['x'], range(10))}, coords={'x': range(10)}) ds['msk']=ds.a>5 msk=ds.a>5

v1=ds.a.where(ds.a>5) v2=ds.a.where(msk) v3=ds.where(ds.msk).a v4=ds.a.where(ds.msk)

', '.join(str(v.name) for v in (v1, v2, v3, v4))#output: 'a, a, a, None'

Problem description

All vs defined above are identical, except that v4 has lost its name in masking. This can cause errors in merging (like just happened to me and was hard and annoying to catch).

Is this behavior intentional? It seems inconsistent to me that ds.a.where(ds.msk) is not equivalent to ds.where(ds.msk).a

Expected Output

I would expect ds.a.where(ds.msk) to return a DataArray with the name a.

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.2 (default, Dec 29 2018, 00:00:04) [Clang 4.0.1 (tags/RELEASE_401/final)] python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: None libnetcdf: None xarray: 0.11.1+49.g27cf53f2 pandas: 0.23.3 numpy: 1.16.0 scipy: 1.2.0 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: 2.2.0 cftime: 1.0.3.4 PseudonetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 cyordereddict: None dask: 1.1.0 distributed: 1.25.3 matplotlib: 3.0.2 cartopy: 0.17.0 seaborn: 0.9.0 setuptools: 40.8.0 pip: 19.0.1 conda: None pytest: None IPython: 7.2.0 sphinx: 1.8.2
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2748/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.552ms · About: xarray-datasette