home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 351343574

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
351343574 MDU6SXNzdWUzNTEzNDM1NzQ= 2371 `AttributeError: 'DataArray' object has no attribute 'ravel'` when using `np.intersect1d(..., assume_unique=True)` 1530840 closed 0     5 2018-08-16T19:47:36Z 2018-10-22T21:27:22Z 2018-10-22T21:27:22Z NONE      

Code Sample, a copy-pastable example if possible

```python

import xarray as xr import numpy as np np.intersect1d(xr.DataArray(np.empty(5), dims=('a',)), xr.DataArray(np.empty(5), dims=('a',))) array([2.37151510e-322, 6.92748216e-310]) np.intersect1d(xr.DataArray(np.empty(5), dims=('a',)), xr.DataArray(np.empty(5), dims=('a',)), assume_unique=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/local1/opt/miniconda3/envs/datacube/lib/python3.6/site-packages/numpy/lib/arraysetops.py", line 368, in intersect1d ar1 = ar1.ravel() File "/local1/opt/miniconda3/envs/datacube/lib/python3.6/site-packages/xarray/core/common.py", line 176, in getattr (type(self).name, name)) AttributeError: 'DataArray' object has no attribute 'ravel' ```

Problem description

I believe this worked in a previous version, not sure what might have changed. But I don't see any reason calling np.intersect1d on DataArray's shouldn't work, or why assume_unique=True ought to make any difference.

Expected Output

Output should be the same as calling intersect1d with assume_unique=True directly on ndarray's. E.g. ```python

np.intersect1d(xr.DataArray(np.empty(5), dims=('a',)).values, xr.DataArray(np.empty(5), dims=('a',)).values, assume_unique=True) array([2.37151510e-322, 6.94714805e-310]) ```

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.6.final.0 python-bits: 64 OS: Linux OS-release: 3.10.0-514.26.2.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 xarray: 0.10.8 pandas: 0.23.4 numpy: 1.15.0 scipy: 1.1.0 netCDF4: None h5netcdf: 0.6.1 h5py: 2.8.0 Nio: None zarr: 2.2.0 bottleneck: None cyordereddict: None dask: 0.18.2 distributed: 1.22.0 matplotlib: 2.2.3 cartopy: None seaborn: None setuptools: 40.0.0 pip: 18.0 conda: None pytest: None IPython: None sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2371/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
  • 5 rows from issue in issue_comments
Powered by Datasette · Queries took 5.179ms · About: xarray-datasette