home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 574097799

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
574097799 MDU6SXNzdWU1NzQwOTc3OTk= 3820 Documentation of DataArray does not warn that inferring dimension names is deprecated 8833517 closed 0     8 2020-03-02T16:37:01Z 2020-03-03T19:34:39Z 2020-03-03T00:38:05Z CONTRIBUTOR      

The documentation states:

coords... ... Additionally, it is possible to define a coord whose name does not match the dimension name, or a coord based on multiple dimensions, with one of the following notations: - mapping {coord name: DataArray} - mapping {coord name: Variable} - mapping {coord name: (dimension name, array-like)} - mapping {coord name: (tuple of dimension names, array-like)}

dims (hashable or sequence of hashable, optional) – Name(s) of the data dimension(s). Must be either a hashable (only for 1D data) or a sequence of hashables with length equal to the number of dimensions. If this argument is omitted, dimension names are taken from coords (if possible) and otherwise default to ['dim_0', ... 'dim_n'].

Which seems to be no longer the case.

MCVE Code Sample

```python da = xr.DataArray(np.zeros((2, 2)), coords={'x': [1, 2], 'y': [1, 2]})


ValueError Traceback (most recent call last) <ipython-input-22-0d63eed9a72f> in <module> ----> 1 da = xr.DataArray(np.zeros((2, 2)), coords={'x': [1, 2], 'y': [1, 2]})

/scratch/local/lib/python3.8/site-packages/xarray/core/dataarray.py in init(self, data, coords, dims, name, attrs, encoding, indexes, fastpath) 366 data = _check_data_shape(data, coords, dims) 367 data = as_compatible_data(data) --> 368 coords, dims = _infer_coords_and_dims(data.shape, coords, dims) 369 variable = Variable(dims, data, attrs, encoding, fastpath=True) 370

/scratch/local/lib/python3.8/site-packages/xarray/core/dataarray.py in _infer_coords_and_dims(shape, coords, dims) 105 if utils.is_dict_like(coords): 106 # deprecated in GH993, removed in GH1539 --> 107 raise ValueError( 108 "inferring DataArray dimensions from " 109 "dictionary like coords is no longer "

ValueError: inferring DataArray dimensions from dictionary like coords is no longer supported. Use an explicit list of dims instead. ```

Expected Output

An update of the documentation to correctly specify the current behavior. (I'll propose a PR later today)

Problem Description

A mismatch between API specification and it's behavior seems like a problem to me :)

Output of xr.show_versions()

`xr.show_versions()` INSTALLED VERSIONS ------------------ commit: None python: 3.8.1 (default, Feb 11 2020, 12:54:25) [GCC 5.4.0 20160609] python-bits: 64 OS: Linux OS-release: 4.15.0-88-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_IE.UTF-8 LOCALE: en_IE.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.3 xarray: 0.14.1 pandas: 0.25.3 numpy: 1.18.0 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.4.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.1.2 cartopy: None seaborn: None numbagg: None setuptools: 45.2.0 pip: 20.0.2 conda: None pytest: None IPython: 7.11.1 sphinx: 2.3.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3820/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
  • 8 rows from issue in issue_comments
Powered by Datasette · Queries took 69.586ms · About: xarray-datasette