home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 316660970

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
316660970 MDU6SXNzdWUzMTY2NjA5NzA= 2075 apply_ufunc can generate an invalid object. 6815844 closed 0     2 2018-04-23T04:52:25Z 2018-04-23T05:08:02Z 2018-04-23T05:08:02Z MEMBER      

Code Sample, a copy-pastable example if possible

apply_ufunc can generate an invalid object if the size of the array is changed by ufunc,

python In [1]: import numpy as np ...: import xarray as xr ...: ...: da = xr.DataArray([1, 2, 3], dims=['x'], coords={'x': [0, 0.5, 1]}) ...: ...: def tile(x): ...: return np.tile(da, [2]) ...: ...: tiled = xr.apply_ufunc(tile, da, input_core_dims=[['x']], ...: output_core_dims=[['x']]) ...: tiled ...: Out[1]: <xarray.DataArray (x: 6)> array([1, 2, 3, 1, 2, 3]) Coordinates: * x (x) float64 0.0 0.5 1.0

In the above example, tiled.shape = (6, ) but tiled['x'].shape = (3,). I think we need a sanity check and drop coordinate if necessary.

Problem description

Any of our function should not generate invalid xarray objects.

Expected Output

python Out[1]: <xarray.DataArray (x: 6)> array([1, 2, 3, 1, 2, 3]) Dimensions without coordinates: x

or raise an Error.

Output of xr.show_versions()

# Paste the output here xr.show_versions() here INSTALLED VERSIONS ------------------ commit: None python: 3.6.4.final.0 python-bits: 64 OS: Linux OS-release: 4.4.0-119-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 xarray: 0.10.3+dev2.ga0bdbfb pandas: 0.22.0 numpy: 1.14.0 scipy: 1.0.0 netCDF4: 1.3.1 h5netcdf: None h5py: None Nio: None zarr: 2.1.4 bottleneck: 1.2.1 cyordereddict: None dask: 0.17.1 distributed: 1.21.1 matplotlib: 2.1.2 cartopy: 0.16.0 seaborn: 0.8.1 setuptools: 38.4.0 pip: 9.0.1 conda: None pytest: 3.3.2 IPython: 6.2.1 sphinx: 1.7.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2075/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 1.746ms · About: xarray-datasette