Question: REGRESSION: copy(deep=True) casts unicode indices to object (deep=True) and (deep=True/False) accidentally cast IndexVariable's with dtype='<U*' to object. Same applies to () and copy.deepcopy(). This is a regression in xarray = 0.12.2. xarray 0.12.1 and earlier are unaffected.

dtype = np.dtype('O')             else:                 dtype = array.dtype        else:            dtype = np.dtype(dtype)         self._dtype = dtype      @property    def dtype(self):    def dtype(self) -> np.dtype:         return self._dtype     def __array__(self, dtype=None):    def __array__(self, dtype: DTypeLike = None) -> np.ndarray:         if dtype is None:             dtype = self.dtype         array = self.array


Question: REGRESSION: copy(deep=True) casts unicode indices to object (deep=True) and (deep=True/False) accidentally cast IndexVariable's with dtype='<U*' to object. Same applies to () and copy.deepcopy(). This is a regression in xarray = 0.12.2. xarray 0.12.1 and earlier are unaffected.

return np.asarray(array.values, dtype=dtype)      @property    def shape(self):    def shape(self) -> Tuple[int]:         # .shape is broken on pandas prior to v0.15.2         return (len(self.array),)     def __getitem__(self, indexer):    def __getitem__(            self, indexer    ) -> Union[        NumpyIndexingAdapter,        np.ndarray,        np.datetime64,        np.timedelta64,    ]:         key = indexer.tuple         if isinstance(key, tuple) and len(key) == 1:             # unpack key so it can index a pandas.Index object (pandas.Index


Question: REGRESSION: copy(deep=True) casts unicode indices to object (deep=True) and (deep=True/False) accidentally cast IndexVariable's with dtype='<U*' to object. Same applies to () and copy.deepcopy(). This is a regression in xarray = 0.12.2. xarray 0.12.1 and earlier are unaffected.

return result     def transpose(self, order):    def transpose(self, order) -> pd.Index:         return self.array  # self.array should be always one-dimensional     def __repr__(self):    def __repr__(self) -> str:         return ('%s(array=%r, dtype=%r)'                 % (type(self).__name__, self.array, self.dtype))    def copy(self, deep: bool = True) -> 'PandasIndexAdapter':        # Not the same as just writing `self.array.copy(deep=deep)`, as        # shallow copies of the underlying numpy.ndarrays become deep ones        # upon pickling        # >>> len(pickle.dumps((self.array, self.array)))        # 4000281        # >>> len(pickle.dumps((self.array, self.array.copy(deep=False))))        # 8000341        array = self.array.copy(deep=True) if deep else self.array        return PandasIndexAdapter(array, self._dtype)diff --git a/xarray/core/variable.py b/xarray/core/variable.py-- a/xarray/core/variable.py++ b/xarray/core/variable.py


Question: REGRESSION: copy(deep=True) casts unicode indices to object (deep=True) and (deep=True/False) accidentally cast IndexVariable's with dtype='<U*' to object. Same applies to () and copy.deepcopy(). This is a regression in xarray = 0.12.2. xarray 0.12.1 and earlier are unaffected.

data copied from original.         """         if data is None:            if deep:                # self._data should be a `PandasIndexAdapter` instance at this                # point, which doesn't have a copy method, so make a deep copy                # of the underlying `pandas.MultiIndex` and create a new                # `PandasIndexAdapter` instance with it.                data = PandasIndexAdapter(self._data.array.copy(deep=True))            else:                data = self._data            data = self._data.copy(deep=deep)         else:             data = as_compatible_data(data)             if self.shape != data.shape:


Question: expanddims() modifies to write only, upon manually reverting this flag back, attempting to set a single inner value using .loc will instead set all of the inner array values I am using the newly updated expanddims API that was recently updated with this PR . However the flag setting behaviour can also be observed using the old API syntax. When applying the operation 'expanddims({'z': 3}, -1)' on a DataArray the underlying Numpy array flags are changed. 'CCONTIGUOUS' is set to False, and 'WRITEABLE' is set to False, and 'OWNDATA' is set to False. Upon changing 'WRITEABLE' back to True, when I try to set a single value in the DataArray using the '.loc' operator it will instead set all the values in that selected inner array. I am new to Xarray so I can't be entirely sure if this expected behaviour. Regardless I would expect that adding a new dimension to the array would not make that array 'read-only'. I would also not expect the '.loc' method to work differently to how it would otherwise. It's also not congruent with the Numpy 'expanddims' operation. Because when I call the operation 'np.expanddims(nparr, axis=-1)' the 'CCONTIGUOUS ' and 'WRITEABLE ' flags will not be modified. Here is a similar flow of operations that demonstrates the behaviour I would expect from the DataArray after applying 'expanddims': <detailsINSTALLED VERSIONS commit: None python: 3.6.7 (default, Dec 29 2018, 12:05:36) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x8664 processor: i386 byteorder: little LCALL: None LANG: enAU.UTF-8 LOCALE: enAU.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.4.1.1 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.16.2 scipy: 1.2.1 netCDF4: 1.5.0 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nctime_axis: None PseudonetCDF: None rasterio: None cfgrib: 0.9.6.1.post1 iris: None bottleneck: None dask: None distributed: None matplotlib: 3.0.3 cartopy: 0.17.0 seaborn: None setuptools: 39.0.1 pip: 10.0.1 conda: None pytest: None IPython: None sphinx: None </details

Mapping[Hashable, Any]] = None,                     axis=None, **dim_kwargs: Any) -> 'DataArray':         """Return a new object with an additional axis (or axes) inserted at        the corresponding position in the array shape.        the corresponding position in the array shape. The new object is a        view into the underlying array, not a copy.          If dim is already a scalar coordinate, it will be promoted to a 1D         coordinate consisting of a single value.diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py-- a/xarray/core/dataset.py++ b/xarray/core/dataset.py


Question: expanddims() modifies to write only, upon manually reverting this flag back, attempting to set a single inner value using .loc will instead set all of the inner array values I am using the newly updated expanddims API that was recently updated with this PR . However the flag setting behaviour can also be observed using the old API syntax. When applying the operation 'expanddims({'z': 3}, -1)' on a DataArray the underlying Numpy array flags are changed. 'CCONTIGUOUS' is set to False, and 'WRITEABLE' is set to False, and 'OWNDATA' is set to False. Upon changing 'WRITEABLE' back to True, when I try to set a single value in the DataArray using the '.loc' operator it will instead set all the values in that selected inner array. I am new to Xarray so I can't be entirely sure if this expected behaviour. Regardless I would expect that adding a new dimension to the array would not make that array 'read-only'. I would also not expect the '.loc' method to work differently to how it would otherwise. It's also not congruent with the Numpy 'expanddims' operation. Because when I call the operation 'np.expanddims(nparr, axis=-1)' the 'CCONTIGUOUS ' and 'WRITEABLE ' flags will not be modified. Here is a similar flow of operations that demonstrates the behaviour I would expect from the DataArray after applying 'expanddims': <detailsINSTALLED VERSIONS commit: None python: 3.6.7 (default, Dec 29 2018, 12:05:36) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x8664 processor: i386 byteorder: little LCALL: None LANG: enAU.UTF-8 LOCALE: enAU.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.4.1.1 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.16.2 scipy: 1.2.1 netCDF4: 1.5.0 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nctime_axis: None PseudonetCDF: None rasterio: None cfgrib: 0.9.6.1.post1 iris: None bottleneck: None dask: None distributed: None matplotlib: 3.0.3 cartopy: 0.17.0 seaborn: None setuptools: 39.0.1 pip: 10.0.1 conda: None pytest: None IPython: None sphinx: None </details

def expand_dims(self, dim=None, axis=None, **dim_kwargs):         """Return a new object with an additional axis (or axes) inserted at        the corresponding position in the array shape.        the corresponding position in the array shape.  The new object is a        view into the underlying array, not a copy.          If dim is already a scalar coordinate, it will be promoted to a 1D         coordinate consisting of a single value.diff --git a/xarray/core/indexing.py b/xarray/core/indexing.py-- a/xarray/core/indexing.py++ b/xarray/core/indexing.py


Question: expanddims() modifies to write only, upon manually reverting this flag back, attempting to set a single inner value using .loc will instead set all of the inner array values I am using the newly updated expanddims API that was recently updated with this PR . However the flag setting behaviour can also be observed using the old API syntax. When applying the operation 'expanddims({'z': 3}, -1)' on a DataArray the underlying Numpy array flags are changed. 'CCONTIGUOUS' is set to False, and 'WRITEABLE' is set to False, and 'OWNDATA' is set to False. Upon changing 'WRITEABLE' back to True, when I try to set a single value in the DataArray using the '.loc' operator it will instead set all the values in that selected inner array. I am new to Xarray so I can't be entirely sure if this expected behaviour. Regardless I would expect that adding a new dimension to the array would not make that array 'read-only'. I would also not expect the '.loc' method to work differently to how it would otherwise. It's also not congruent with the Numpy 'expanddims' operation. Because when I call the operation 'np.expanddims(nparr, axis=-1)' the 'CCONTIGUOUS ' and 'WRITEABLE ' flags will not be modified. Here is a similar flow of operations that demonstrates the behaviour I would expect from the DataArray after applying 'expanddims': <detailsINSTALLED VERSIONS commit: None python: 3.6.7 (default, Dec 29 2018, 12:05:36) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x8664 processor: i386 byteorder: little LCALL: None LANG: enAU.UTF-8 LOCALE: enAU.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.4.1.1 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.16.2 scipy: 1.2.1 netCDF4: 1.5.0 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nctime_axis: None PseudonetCDF: None rasterio: None cfgrib: 0.9.6.1.post1 iris: None bottleneck: None dask: None distributed: None matplotlib: 3.0.3 cartopy: 0.17.0 seaborn: None setuptools: 39.0.1 pip: 10.0.1 conda: None pytest: None IPython: None sphinx: None </details

def __setitem__(self, key, value):         array, key = self._indexing_array_and_key(key)        array[key] = value        try:            array[key] = value        except ValueError:            # More informative exception if read-only view            if not array.flags.writeable and not array.flags.owndata:                raise ValueError("Assignment destination is a view.  "                                 "Do you want to .copy() array first?")            else:                raise   class DaskIndexingAdapter(ExplicitlyIndexedNDArrayMixin):


Question: xr.combinebycoords raises ValueError if identical coordinates are non-monotonic <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --should return without error. Running the example with raises an error: The documentation for says that "Non-coordinate dimensions will be ignored, as will any coordinate dimensions which do not vary between each dataset". This is not the case with the current implementation, since identical coordinate dimensions are still required to be monotonic. <detailsINSTALLED VERSIONS commit: None python: 3.7.1 (v3.7.1:, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel byteorder: little LCALL: None LANG: None LOCALE: None.None libhdf5: None libnetcdf: None xarray: 0.12.3 pandas: 0.24.2 numpy: 1.16.4 scipy: 1.3.0 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nctime_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.1.1 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 39.0.1 pip: 10.0.1 conda: None pytest: None IPython: 7.1.1 sphinx: None </details

fill_value=fill_value)          # Check the overall coordinates are monotonically increasing        for dim in concatenated.dims:            if dim in concatenated:                indexes = concatenated.indexes.get(dim)                if not (indexes.is_monotonic_increasing                        or indexes.is_monotonic_decreasing):                    raise ValueError("Resulting object does not have monotonic"                                     " global indexes along dimension {}"                                     .format(dim))        for dim in concat_dims:            indexes = concatenated.indexes.get(dim)            if not (indexes.is_monotonic_increasing                    or indexes.is_monotonic_decreasing):                raise ValueError("Resulting object does not have monotonic"                                 " global indexes along dimension {}"                                 .format(dim))         concatenated_grouped_by_data_vars.append(concatenated)      return merge(concatenated_grouped_by_data_vars, compat=compat,


Question: groupby on empty DataArray raises StopIteration This seems similar to and so apologies if it is a duplicate, but I have a minimal example where it happens on an empty DataArray: Using groupby on an empty DataArray or Dataset raises . It should raise a more meaningful error. In particular, I had this issue in a function I was calling inside of a generator, so the StopIteration just broke out of the generator and it took some digging to figure out what was going wrong in my code. <detailsINSTALLED VERSIONS commit: None python: python-bits: 64 OS: Linux OS-release: 3.10.0-862.14.4.el7.x8664 machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.utf8 LOCALE: enUS.UTF-8 xarray: 0.10.7 pandas: 0.23.0 numpy: 1.14.3 scipy: 1.1.0 netCDF4: 1.4.0 h5netcdf: 0.6.1 h5py: 2.7.1 Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: 0.17.5 distributed: 1.21.8 matplotlib: 2.2.2 cartopy: None seaborn: 0.8.1 setuptools: 39.1.0 pip: 10.0.1 conda: None pytest: 3.5.1 IPython: 6.4.0 sphinx: 1.7.4 </details

raise TypeError('`group` must be an xarray.DataArray or the '                                 'name of an xarray variable or dimension')             group = obj[group]<ins>            if len(group) == 0:                raise ValueError("{} must not be empty".format(group.name))</ins>             if group.name not in obj.coords and group.name in obj.dims:                 # DummyGroups should not appear on groupby results                 group = _DummyGroup(obj, group.name, group.coords)


Question: Allow passing a default value (instead of ndarray) for data argument for DataArray Hi, First of all, thanks a lot for the amazing module. It seems when I create a DataArray, I have to pass a numpy.ndarray with a correct size for the argument. It works well when I already have some data, but sometimes I want to create an "empty" DataArray with known coordinates and fill up the data later. For these cases, it would be great if xarray allows passing just a value for the argument, and fill up all the elements of the array with the value. For example, with pandas, I can do: and the resulting would be: Thanks a lot!

return new_coords, dims  <ins>def _check_data_shape(data, coords, dims):    if data is dtypes.NA:        data = np.nan    if coords is not None and utils.is_scalar(data, include_0d=False):        if utils.is_dict_like(coords):            if dims is None:                return data            else:                data_shape = tuple(                    as_variable(coords[k], k).size if k in coords.keys() else 1                    for k in dims                )        else:            data_shape = tuple(as_variable(coord, "foo").size for coord in coords)        data = np.full(data_shape, data)    return data</ins> class _LocIndexer:     def __init__(self, data_array: "DataArray"):         self.data_array = data_array


Question: Allow passing a default value (instead of ndarray) for data argument for DataArray Hi, First of all, thanks a lot for the amazing module. It seems when I create a DataArray, I have to pass a numpy.ndarray with a correct size for the argument. It works well when I already have some data, but sometimes I want to create an "empty" DataArray with known coordinates and fill up the data later. For these cases, it would be great if xarray allows passing just a value for the argument, and fill up all the elements of the array with the value. For example, with pandas, I can do: and the resulting would be: Thanks a lot!

def __init__(         self,        data: Any,        data: Any = dtypes.NA,         coords: Union[Sequence[Tuple], Mapping[Hashable, Any], None] = None,         dims: Union[Hashable, Sequence[Hashable], None] = None,         name: Hashable = None,


Question: Allow passing a default value (instead of ndarray) for data argument for DataArray Hi, First of all, thanks a lot for the amazing module. It seems when I create a DataArray, I have to pass a numpy.ndarray with a correct size for the argument. It works well when I already have some data, but sometimes I want to create an "empty" DataArray with known coordinates and fill up the data later. For these cases, it would be great if xarray allows passing just a value for the argument, and fill up all the elements of the array with the value. For example, with pandas, I can do: and the resulting would be: Thanks a lot!

if encoding is None:                 encoding = getattr(data, "encoding", None)             data = _check_data_shape(data, coords, dims)             data = as_compatible_data(data)             coords, dims = _infer_coords_and_dims(data.shape, coords, dims)             variable = Variable(dims, data, attrs, encoding, fastpath=True)diff --git a/xarray/core/utils.py b/xarray/core/utils.py-- a/xarray/core/utils.py++ b/xarray/core/utils.py


Question: Allow passing a default value (instead of ndarray) for data argument for DataArray Hi, First of all, thanks a lot for the amazing module. It seems when I create a DataArray, I have to pass a numpy.ndarray with a correct size for the argument. It works well when I already have some data, but sometimes I want to create an "empty" DataArray with known coordinates and fill up the data later. For these cases, it would be great if xarray allows passing just a value for the argument, and fill up all the elements of the array with the value. For example, with pandas, I can do: and the resulting would be: Thanks a lot!

import numpy as np import pandas as pd <del>from .pycompat import dask_array_type</del> K = TypeVar("K") V = TypeVar("V") T = TypeVar("T")


Question: Allow passing a default value (instead of ndarray) for data argument for DataArray Hi, First of all, thanks a lot for the amazing module. It seems when I create a DataArray, I have to pass a numpy.ndarray with a correct size for the argument. It works well when I already have some data, but sometimes I want to create an "empty" DataArray with known coordinates and fill up the data later. For these cases, it would be great if xarray allows passing just a value for the argument, and fill up all the elements of the array with the value. For example, with pandas, I can do: and the resulting would be: Thanks a lot!

return cast(Mapping[Hashable, T], kw_kwargs)  def is_scalar(value: Any) -> bool:def is_scalar(value: Any, include_0d: bool = True) -> bool:     """Whether to treat a value as a scalar.      Any non-iterable, string, or 0-D array     """    from .variable import NON_NUMPY_SUPPORTED_ARRAY_TYPES    if include_0d:        include_0d = getattr(value, "ndim", None) == 0     return (        getattr(value, "ndim", None) == 0        include_0d         or isinstance(value, (str, bytes))         or not (            isinstance(value, (Iterable,) + dask_array_type)            isinstance(value, (Iterable,) + NON_NUMPY_SUPPORTED_ARRAY_TYPES)             or hasattr(value, "__array_function__")         )     )


Question: DataArray.quantile does not honor <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --returns <detailsINSTALLED VERSIONS commit: python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-60-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enCA.UTF-8 LOCALE: enCA.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.6.1 xarray: pandas: 0.23.4 numpy: 1.16.1 scipy: 1.1.0 netCDF4: 1.3.1 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 0.19.0 distributed: 1.23.0 matplotlib: 3.0.2 cartopy: 0.17.0 seaborn: None numbagg: None setuptools: 41.0.0 pip: 9.0.1 conda: None pytest: 4.4.0 IPython: 7.0.1 sphinx: 1.7.1 </details

# the former is often more efficient                             reduce_dims = None                         variables[name] = var.quantile(                            q, dim=reduce_dims, interpolation=interpolation                            q,                            dim=reduce_dims,                            interpolation=interpolation,                            keep_attrs=keep_attrs,                         )              else:diff --git a/xarray/core/variable.py b/xarray/core/variable.py-- a/xarray/core/variable.py++ b/xarray/core/variable.py


Question: DataArray.quantile does not honor <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --returns <detailsINSTALLED VERSIONS commit: python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-60-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enCA.UTF-8 LOCALE: enCA.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.6.1 xarray: pandas: 0.23.4 numpy: 1.16.1 scipy: 1.1.0 netCDF4: 1.3.1 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 0.19.0 distributed: 1.23.0 matplotlib: 3.0.2 cartopy: 0.17.0 seaborn: None numbagg: None setuptools: 41.0.0 pip: 9.0.1 conda: None pytest: 4.4.0 IPython: 7.0.1 sphinx: 1.7.1 </details

"""         return self.broadcast_equals(other, equiv=duck_array_ops.array_notnull_equiv)     def quantile(self, q, dim=None, interpolation="linear"):    def quantile(self, q, dim=None, interpolation="linear", keep_attrs=None):         """Compute the qth quantile of the data along the specified dimension.          Returns the qth quantiles(s) of the array elements.


Question: DataArray.quantile does not honor <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --returns <detailsINSTALLED VERSIONS commit: python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-60-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enCA.UTF-8 LOCALE: enCA.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.6.1 xarray: pandas: 0.23.4 numpy: 1.16.1 scipy: 1.1.0 netCDF4: 1.3.1 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 0.19.0 distributed: 1.23.0 matplotlib: 3.0.2 cartopy: 0.17.0 seaborn: None numbagg: None setuptools: 41.0.0 pip: 9.0.1 conda: None pytest: 4.4.0 IPython: 7.0.1 sphinx: 1.7.1 </details

* higher: ``j``.                 * nearest: ``i`` or ``j``, whichever is nearest.                 * midpoint: ``(i + j) / 2``.<ins>        keep_attrs : bool, optional            If True, the variable's attributes (`attrs`) will be copied from            the original object to the new one.  If False (default), the new            object will be returned without attributes.</ins>          Returns         -------


Question: DataArray.quantile does not honor <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --returns <detailsINSTALLED VERSIONS commit: python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-60-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enCA.UTF-8 LOCALE: enCA.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.6.1 xarray: pandas: 0.23.4 numpy: 1.16.1 scipy: 1.1.0 netCDF4: 1.3.1 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 0.19.0 distributed: 1.23.0 matplotlib: 3.0.2 cartopy: 0.17.0 seaborn: None numbagg: None setuptools: 41.0.0 pip: 9.0.1 conda: None pytest: 4.4.0 IPython: 7.0.1 sphinx: 1.7.1 </details

is a scalar. If multiple percentiles are given, first axis of             the result corresponds to the quantile and a quantile dimension             is added to the return array. The other dimensions are the             dimensions that remain after the reduction of the array.            dimensions that remain after the reduction of the array.          See Also         --------


Question: DataArray.quantile does not honor <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --returns <detailsINSTALLED VERSIONS commit: python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-60-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enCA.UTF-8 LOCALE: enCA.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.6.1 xarray: pandas: 0.23.4 numpy: 1.16.1 scipy: 1.1.0 netCDF4: 1.3.1 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 0.19.0 distributed: 1.23.0 matplotlib: 3.0.2 cartopy: 0.17.0 seaborn: None numbagg: None setuptools: 41.0.0 pip: 9.0.1 conda: None pytest: 4.4.0 IPython: 7.0.1 sphinx: 1.7.1 </details

axis = None             new_dims = []         # only add the quantile dimension if q is array like        # Only add the quantile dimension if q is array-like         if q.ndim != 0:             new_dims = ["quantile"] + new_dims          qs = np.nanpercentile(             self.data, q * 100.0, axis=axis, interpolation=interpolation         )        return Variable(new_dims, qs)        if keep_attrs is None:            keep_attrs = _get_keep_attrs(default=False)        attrs = self._attrs if keep_attrs else None        return Variable(new_dims, qs, attrs)      def rank(self, dim, pct=False):         """Ranks the data.


Question: Ignore missing variables when concatenating datasets? Several users ( now myself) have wondered about how to concatenate xray Datasets with different variables. With the current , you need to awkwardly create dummy variables filled with in datasets that don't have them (or drop mismatched variables entirely). Neither of these are great options -- should have an option (the default?) to take care of this for the user. This would also be more consistent with , which takes a more relaxed approach to matching dataframes with different variables (it does an outer join).

to_merge = {var: [] for var in variables_to_merge}          for ds in datasets:            absent_merge_vars = variables_to_merge - set(ds.variables)            if absent_merge_vars:                raise ValueError(                    "variables %r are present in some datasets but not others. "                    % absent_merge_vars                )             for var in variables_to_merge:                to_merge[var].append(ds.variables[var])                if var in ds:                    to_merge[var].append(ds.variables[var])          for var in variables_to_merge:             result_vars[var] = unique_variable(


Question: groupby().apply() on variable with NaNs raises IndexError This results in an IndexError. This is mildly confusing, it took me a little while to figure out the NaN's were to blame. I'm guessing the NaN doesn't get filtered out everywhere. The traceback: My assumption was that it would throw out the values that fall within the NaN group, like: Out: <details</details

group_indices = [slice(i, i + 1) for i in group_indices]             unique_coord = group         else:<ins>            if group.isnull().any():                # drop any NaN valued groups.                # also drop obj values where group was NaN                # Use where instead of reindex to account for duplicate coordinate labels.                obj = obj.where(group.notnull(), drop=True)                group = group.dropna(group_dim)</ins>             # look through group to find the unique values             unique_values, group_indices = unique_value_groups(                 safe_cast_to_index(group), sort=(bins is None)


Question: selection from MultiIndex does not work properly Should select the array <detailsINSTALLED VERSIONS commit: None python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-957.10.1.el7.x8664 machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.14.0 pandas: 0.24.2 numpy: 1.15.4 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: None distributed: None matplotlib: 3.0.2 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 40.8.0 pip: 19.0.3 conda: None pytest: 5.0.0 IPython: 7.3.0 sphinx: None </detailsSorry for being quiet for a long time. I hope I could send a fix for this in a few days...

assert_coordinate_consistent,     remap_label_indexers, )from .dataset import Dataset, merge_indexes, split_indexesfrom .dataset import Dataset, split_indexes from .formatting import format_item from .indexes import Indexes, default_indexes from .merge import PANDAS_TYPES


Question: selection from MultiIndex does not work properly Should select the array <detailsINSTALLED VERSIONS commit: None python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-957.10.1.el7.x8664 machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.14.0 pandas: 0.24.2 numpy: 1.15.4 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: None distributed: None matplotlib: 3.0.2 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 40.8.0 pip: 19.0.3 conda: None pytest: 5.0.0 IPython: 7.3.0 sphinx: None </detailsSorry for being quiet for a long time. I hope I could send a fix for this in a few days...

--------         DataArray.reset_index         """        _check_inplace(inplace)        indexes = either_dict_or_kwargs(indexes, indexes_kwargs, "set_index")        coords, _ = merge_indexes(indexes, self._coords, set(), append=append)        return self._replace(coords=coords)        ds = self._to_temp_dataset().set_index(            indexes, append=append, inplace=inplace, **indexes_kwargs        )        return self._from_temp_dataset(ds)      def reset_index(         self,diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py-- a/xarray/core/dataset.py++ b/xarray/core/dataset.py


Question: selection from MultiIndex does not work properly Should select the array <detailsINSTALLED VERSIONS commit: None python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-957.10.1.el7.x8664 machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.14.0 pandas: 0.24.2 numpy: 1.15.4 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: None distributed: None matplotlib: 3.0.2 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 40.8.0 pip: 19.0.3 conda: None pytest: 5.0.0 IPython: 7.3.0 sphinx: None </detailsSorry for being quiet for a long time. I hope I could send a fix for this in a few days...

"""     vars_to_replace: Dict[Hashable, Variable] = {}     vars_to_remove: List[Hashable] = []<ins>    dims_to_replace: Dict[Hashable, Hashable] = {}</ins>     error_msg = "{} is not the name of an existing variable."      for dim, var_names in indexes.items():


Question: selection from MultiIndex does not work properly Should select the array <detailsINSTALLED VERSIONS commit: None python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-957.10.1.el7.x8664 machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.14.0 pandas: 0.24.2 numpy: 1.15.4 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: None distributed: None matplotlib: 3.0.2 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 40.8.0 pip: 19.0.3 conda: None pytest: 5.0.0 IPython: 7.3.0 sphinx: None </detailsSorry for being quiet for a long time. I hope I could send a fix for this in a few days...

if not len(names) and len(var_names) == 1:             idx = pd.Index(variables[var_names[0]].values)         else:        else:  # MultiIndex             for n in var_names:                 try:                     var = variables[n]


Question: selection from MultiIndex does not work properly Should select the array <detailsINSTALLED VERSIONS commit: None python: 3.6.8 (default, Dec 30 2018, 01:22:34) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-957.10.1.el7.x8664 machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.14.0 pandas: 0.24.2 numpy: 1.15.4 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nctimeaxis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: None distributed: None matplotlib: 3.0.2 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 40.8.0 pip: 19.0.3 conda: None pytest: 5.0.0 IPython: 7.3.0 sphinx: None </detailsSorry for being quiet for a long time. I hope I could send a fix for this in a few days...

levels.append(cat.categories)              idx = pd.MultiIndex(levels, codes, names=names)            for n in names:                dims_to_replace[n] = dim          vars_to_replace[dim] = IndexVariable(dim, idx)         vars_to_remove.extend(var_names)      new_variables = {k: v for k, v in variables.items() if k not in vars_to_remove}     new_variables.update(vars_to_replace)    # update dimensions if necessary  GH: 3512    for k, v in new_variables.items():        if any(d in dims_to_replace for d in v.dims):            new_dims = [dims_to_replace.get(d, d) for d in v.dims]            new_variables[k] = v._replace(dims=new_dims)     new_coord_names = coord_names | set(vars_to_replace)     new_coord_names -= set(vars_to_remove)     return new_variables, new_coord_names


Question: DatasetGroupBy does not implement quantile The docs claim works on grouped datasets, but that does not seem to be the case: this was found while trying to silence the nit-picky sphinx warnings in

out = ops.fillna(self, value)         return out <ins>    def quantile(self, q, dim=None, interpolation="linear", keep_attrs=None):        """Compute the qth quantile over each array in the groups and        concatenate them together into a new array.        Parameters        ----------        q : float in range of [0,1] (or sequence of floats)            Quantile to compute, which must be between 0 and 1            inclusive.        dim : `...`, str or sequence of str, optional            Dimension(s) over which to apply quantile.            Defaults to the grouped dimension.        interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}            This optional parameter specifies the interpolation method to            use when the desired quantile lies between two data points            ``i < j``:                * linear: ``i + (j - i) * fraction``, where ``fraction`` is                  the fractional part of the index surrounded by ``i`` and                  ``j``.                * lower: ``i``.                * higher: ``j``.                * nearest: ``i`` or ``j``, whichever is nearest.                * midpoint: ``(i + j) / 2``.        Returns        -------        quantiles : Variable            If `q` is a single quantile, then the result is a            scalar. If multiple percentiles are given, first axis of            the result corresponds to the quantile. In either case a            quantile dimension is added to the return array. The other            dimensions are the dimensions that remain after the            reduction of the array.        See Also        --------        numpy.nanpercentile, pandas.Series.quantile, Dataset.quantile,        DataArray.quantile        """        if dim is None:            dim = self._group_dim        out = self.map(            self._obj.__class__.quantile,            shortcut=False,            q=q,            dim=dim,            interpolation=interpolation,            keep_attrs=keep_attrs,        )        return out</ins>     def where(self, cond, other=dtypes.NA):         """Return elements from `self` or `other` depending on `cond`.


Question: DatasetGroupBy does not implement quantile The docs claim works on grouped datasets, but that does not seem to be the case: this was found while trying to silence the nit-picky sphinx warnings in

combined = self._maybe_unstack(combined)         return combined <del>    def quantile(self, q, dim=None, interpolation="linear", keep_attrs=None):        """Compute the qth quantile over each array in the groups and        concatenate them together into a new array.        Parameters        ----------        q : float in range of [0,1] (or sequence of floats)            Quantile to compute, which must be between 0 and 1            inclusive.        dim : `...`, str or sequence of str, optional            Dimension(s) over which to apply quantile.            Defaults to the grouped dimension.        interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}            This optional parameter specifies the interpolation method to            use when the desired quantile lies between two data points            ``i < j``:                * linear: ``i + (j - i) * fraction``, where ``fraction`` is                  the fractional part of the index surrounded by ``i`` and                  ``j``.                * lower: ``i``.                * higher: ``j``.                * nearest: ``i`` or ``j``, whichever is nearest.                * midpoint: ``(i + j) / 2``.        Returns        -------        quantiles : Variable            If `q` is a single quantile, then the result            is a scalar. If multiple percentiles are given, first axis of            the result corresponds to the quantile and a quantile dimension            is added to the return array. The other dimensions are the            dimensions that remain after the reduction of the array.        See Also        --------        numpy.nanpercentile, pandas.Series.quantile, Dataset.quantile,        DataArray.quantile        """        if dim is None:            dim = self._group_dim        out = self.map(            self._obj.__class__.quantile,            shortcut=False,            q=q,            dim=dim,            interpolation=interpolation,            keep_attrs=keep_attrs,        )        if np.asarray(q, dtype=np.float64).ndim == 0:            out = out.drop_vars("quantile")        return out</del>     def reduce(         self, func, dim=None, axis=None, keep_attrs=None, shortcut=True, **kwargs     ):


Question: "ValueError: Percentiles must be in the range [0, 100]" <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --By wrapping (xref: ) we also get the numpy error. However, the error message is wrong as xarray needs it to be in 0..1. BTW: thanks for , makes my life easier! Edit: uses internally. <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Jul 1 2019, 21:52:21) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.12.14-lp151.28.36-default machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enGB.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.14.1+28.gf2b2f9f6 (current master) pandas: 0.25.2 numpy: 1.17.3 scipy: 1.3.1 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: None cftime: 1.0.4.2 nctime_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.1 cfgrib: None iris: None bottleneck: 1.2.1 dask: 2.6.0 distributed: 2.6.0 matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 41.4.0 pip: 19.3.1 conda: None pytest: 5.2.2 IPython: 7.9.0 sphinx: 2.2.1 </details

scalar = utils.is_scalar(q)         q = np.atleast_1d(np.asarray(q, dtype=np.float64)) <ins>        # TODO: remove once numpy >= 1.15.0 is the minimum requirement        if np.count_nonzero(q < 0.0) or np.count_nonzero(q > 1.0):            raise ValueError("Quantiles must be in the range [0, 1]")</ins>         if dim is None:             dim = self.dims


Question: "ValueError: Percentiles must be in the range [0, 100]" <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --By wrapping (xref: ) we also get the numpy error. However, the error message is wrong as xarray needs it to be in 0..1. BTW: thanks for , makes my life easier! Edit: uses internally. <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Jul 1 2019, 21:52:21) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.12.14-lp151.28.36-default machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enGB.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.14.1+28.gf2b2f9f6 (current master) pandas: 0.25.2 numpy: 1.17.3 scipy: 1.3.1 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: None cftime: 1.0.4.2 nctime_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.1 cfgrib: None iris: None bottleneck: 1.2.1 dask: 2.6.0 distributed: 2.6.0 matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 41.4.0 pip: 19.3.1 conda: None pytest: 5.2.2 IPython: 7.9.0 sphinx: 2.2.1 </details

def _wrapper(npa, **kwargs):             # move quantile axis to end. required for apply_ufunc<ins>            # TODO: use np.nanquantile once numpy >= 1.15.0 is the minimum requirement</ins>             return np.moveaxis(np.nanpercentile(npa, **kwargs), 0, -1)          axis = np.arange(-1, -1 * len(dim) - 1, -1)


Question: Confusing error message when attribute not equal during concat If two or more s are concatentated and they have list attributes that are not equal an exception is raised about arrays not being truth values. I guess the expected result would be that the list attribute is not included in the resulting DataArray's attributes. <details</detailsconcat fails with attrs that are dictionaries with ndarrays Fails with the following error: This is a problem because the following code actually executes properly Equivalence for an array within a nested dictionary as an attribute is evaluated differently than an array attribute, which is non-intuitive. This bug is related to but is additionally pointing out a difference in evaluation for more complex attributes. The output of the code sample should concatenate successfully with the nested dictionary attribute, or a more easily interpretable error should be thrown telling me I'm dumb for using dictionaries in attributes. (See ) <detailsINSTALLED VERSIONS commit: None python: python-bits: 64 OS: Linux OS-release: 4.15.0-23-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 xarray: 0.10.9 pandas: 0.23.4 numpy: 1.15.3 scipy: 1.1.0 netCDF4: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None PseudonetCDF: None rasterio: None iris: None bottleneck: None cyordereddict: None dask: None distributed: None matplotlib: 3.0.0 cartopy: None seaborn: None setuptools: 40.4.3 pip: 9.0.1 conda: None pytest: None IPython: 7.0.1 sphinx: None </detailsconcat fails with attrs that are dictionaries with ndarrays Fails with the following error: This is a problem because the following code actually executes properly Equivalence for an array within a nested dictionary as an attribute is evaluated differently than an array attribute, which is non-intuitive. This bug is related to but is additionally pointing out a difference in evaluation for more complex attributes. The output of the code sample should concatenate successfully with the nested dictionary attribute, or a more easily interpretable error should be thrown telling me I'm dumb for using dictionaries in attributes. (See ) <detailsINSTALLED VERSIONS commit: None python: python-bits: 64 OS: Linux OS-release: 4.15.0-23-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 xarray: 0.10.9 pandas: 0.23.4 numpy: 1.15.3 scipy: 1.1.0 netCDF4: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None PseudonetCDF: None rasterio: None iris: None bottleneck: None cyordereddict: None dask: None distributed: None matplotlib: 3.0.0 cartopy: None seaborn: None setuptools: 40.4.3 pip: 9.0.1 conda: None pytest: None IPython: 7.0.1 sphinx: None </details

those of the first object with that dimension. Indexes for the same           dimension must have the same size in all objects.     indexers, mode, concat_over : deprecated     Returns     -------     concatenated : type of objs     Notes    -----    Each concatenated Variable preserves corresponding ``attrs`` from the first element of ``objs``.     See also     --------     mergediff --git a/xarray/core/variable.py b/xarray/core/variable.py-- a/xarray/core/variable.py++ b/xarray/core/variable.py


Question: Confusing error message when attribute not equal during concat If two or more s are concatentated and they have list attributes that are not equal an exception is raised about arrays not being truth values. I guess the expected result would be that the list attribute is not included in the resulting DataArray's attributes. <details</detailsconcat fails with attrs that are dictionaries with ndarrays Fails with the following error: This is a problem because the following code actually executes properly Equivalence for an array within a nested dictionary as an attribute is evaluated differently than an array attribute, which is non-intuitive. This bug is related to but is additionally pointing out a difference in evaluation for more complex attributes. The output of the code sample should concatenate successfully with the nested dictionary attribute, or a more easily interpretable error should be thrown telling me I'm dumb for using dictionaries in attributes. (See ) <detailsINSTALLED VERSIONS commit: None python: python-bits: 64 OS: Linux OS-release: 4.15.0-23-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 xarray: 0.10.9 pandas: 0.23.4 numpy: 1.15.3 scipy: 1.1.0 netCDF4: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None PseudonetCDF: None rasterio: None iris: None bottleneck: None cyordereddict: None dask: None distributed: None matplotlib: 3.0.0 cartopy: None seaborn: None setuptools: 40.4.3 pip: 9.0.1 conda: None pytest: None IPython: 7.0.1 sphinx: None </detailsconcat fails with attrs that are dictionaries with ndarrays Fails with the following error: This is a problem because the following code actually executes properly Equivalence for an array within a nested dictionary as an attribute is evaluated differently than an array attribute, which is non-intuitive. This bug is related to but is additionally pointing out a difference in evaluation for more complex attributes. The output of the code sample should concatenate successfully with the nested dictionary attribute, or a more easily interpretable error should be thrown telling me I'm dumb for using dictionaries in attributes. (See ) <detailsINSTALLED VERSIONS commit: None python: python-bits: 64 OS: Linux OS-release: 4.15.0-23-generic machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 xarray: 0.10.9 pandas: 0.23.4 numpy: 1.15.3 scipy: 1.1.0 netCDF4: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None PseudonetCDF: None rasterio: None iris: None bottleneck: None cyordereddict: None dask: None distributed: None matplotlib: 3.0.0 cartopy: None seaborn: None setuptools: 40.4.3 pip: 9.0.1 conda: None pytest: None IPython: 7.0.1 sphinx: None </details

if not shortcut:             for var in variables:                 if var.dims != first_var.dims:                    raise ValueError("inconsistent dimensions")                utils.remove_incompatible_items(attrs, var.attrs)                    raise ValueError(                        f"Variable has dimensions {list(var.dims)} but first Variable has dimensions {list(first_var.dims)}"                    )          return cls(dims, data, attrs, encoding)


Question: combinebycoords should allow for missing panels in hypercube Currently, it throws the following error: This is b/c calls , which mandates that the passed datasets form a complete hypercube. This check functiono also serves the purpose of mandating that the dimension depths are the same. Could we pull that part out as a separate function and, for , only call this first part but NOT mandate that the hypercube is complete? The expected behavior, in my mind, should be to simply replace the missing tiles of the hypercube with . I'll file a PR to this effect and welcome comments. <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Dec 6 2019, 08:54:18) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.14.150+ machine: x8664 processor: x8664 byteorder: little LCALL: enUS.UTF-8 LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.14.1 pandas: 0.25.3 numpy: 1.17.3 scipy: 1.3.2 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: 2.3.2 cftime: 1.0.4.2 nctime_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.1 cfgrib: None iris: 2.2.0 bottleneck: None dask: 2.8.1 distributed: 2.8.1 matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 42.0.2.post20191201 pip: 19.3.1 conda: 4.8.0 pytest: 5.3.1 IPython: 7.10.1 sphinx: 2.2.2 </details

return combined_ids, concat_dims  def _check_shape_tile_ids(combined_tile_ids):def _check_dimension_depth_tile_ids(combined_tile_ids):    """    Check all tuples are the same length, i.e. check that all lists are    nested to the same depth.    """     tile_ids = combined_tile_ids.keys()    # Check all tuples are the same length    # i.e. check that all lists are nested to the same depth     nesting_depths = [len(tile_id) for tile_id in tile_ids]     if not nesting_depths:         nesting_depths = [0]


Question: combinebycoords should allow for missing panels in hypercube Currently, it throws the following error: This is b/c calls , which mandates that the passed datasets form a complete hypercube. This check functiono also serves the purpose of mandating that the dimension depths are the same. Could we pull that part out as a separate function and, for , only call this first part but NOT mandate that the hypercube is complete? The expected behavior, in my mind, should be to simply replace the missing tiles of the hypercube with . I'll file a PR to this effect and welcome comments. <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Dec 6 2019, 08:54:18) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.14.150+ machine: x8664 processor: x8664 byteorder: little LCALL: enUS.UTF-8 LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.14.1 pandas: 0.25.3 numpy: 1.17.3 scipy: 1.3.2 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: 2.3.2 cftime: 1.0.4.2 nctime_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.1 cfgrib: None iris: 2.2.0 bottleneck: None dask: 2.8.1 distributed: 2.8.1 matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 42.0.2.post20191201 pip: 19.3.1 conda: 4.8.0 pytest: 5.3.1 IPython: 7.10.1 sphinx: 2.2.2 </details

"The supplied objects do not form a hypercube because"             " sub-lists do not have consistent depths"         )    # return these just to be reused in _check_shape_tile_ids    return tile_ids, nesting_depths     # Check all lists along one dimension are same lengthdef _check_shape_tile_ids(combined_tile_ids):    """Check all lists along one dimension are same length."""    tile_ids, nesting_depths = _check_dimension_depth_tile_ids(combined_tile_ids)     for dim in range(nesting_depths[0]):         indices_along_dim = [tile_id[dim] for tile_id in tile_ids]         occurrences = Counter(indices_along_dim)


Question: combinebycoords should allow for missing panels in hypercube Currently, it throws the following error: This is b/c calls , which mandates that the passed datasets form a complete hypercube. This check functiono also serves the purpose of mandating that the dimension depths are the same. Could we pull that part out as a separate function and, for , only call this first part but NOT mandate that the hypercube is complete? The expected behavior, in my mind, should be to simply replace the missing tiles of the hypercube with . I'll file a PR to this effect and welcome comments. <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Dec 6 2019, 08:54:18) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.14.150+ machine: x8664 processor: x8664 byteorder: little LCALL: enUS.UTF-8 LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.14.1 pandas: 0.25.3 numpy: 1.17.3 scipy: 1.3.2 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: 2.3.2 cftime: 1.0.4.2 nctime_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.1 cfgrib: None iris: 2.2.0 bottleneck: None dask: 2.8.1 distributed: 2.8.1 matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 42.0.2.post20191201 pip: 19.3.1 conda: 4.8.0 pytest: 5.3.1 IPython: 7.10.1 sphinx: 2.2.2 </details

coords : {'minimal', 'different', 'all' or list of str}, optional         As per the 'data_vars' kwarg, but for coordinate variables.     fill_value : scalar, optional        Value to use for newly missing values        Value to use for newly missing values. If None, raises a ValueError if        the passed Datasets do not create a complete hypercube.     join : {'outer', 'inner', 'left', 'right', 'exact'}, optional         String indicating how to combine differing indexes         (excluding concat_dim) in objects


Question: combinebycoords should allow for missing panels in hypercube Currently, it throws the following error: This is b/c calls , which mandates that the passed datasets form a complete hypercube. This check functiono also serves the purpose of mandating that the dimension depths are the same. Could we pull that part out as a separate function and, for , only call this first part but NOT mandate that the hypercube is complete? The expected behavior, in my mind, should be to simply replace the missing tiles of the hypercube with . I'll file a PR to this effect and welcome comments. <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Dec 6 2019, 08:54:18) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.14.150+ machine: x8664 processor: x8664 byteorder: little LCALL: enUS.UTF-8 LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.14.1 pandas: 0.25.3 numpy: 1.17.3 scipy: 1.3.2 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: 2.3.2 cftime: 1.0.4.2 nctime_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.1 cfgrib: None iris: 2.2.0 bottleneck: None dask: 2.8.1 distributed: 2.8.1 matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 42.0.2.post20191201 pip: 19.3.1 conda: 4.8.0 pytest: 5.3.1 IPython: 7.10.1 sphinx: 2.2.2 </details

temperature    (y, x) float64 1.654 10.63 7.015 2.543 ... 12.46 2.22 15.96     precipitation  (y, x) float64 0.2136 0.9974 0.7603 ... 0.6125 0.4654 0.5953 <ins>    >>> xr.combine_by_coords([x1, x2, x3])    <xarray.Dataset>    Dimensions:        (x: 6, y: 4)    Coordinates:    * x              (x) int64 10 20 30 40 50 60    * y              (y) int64 0 1 2 3    Data variables:    temperature    (y, x) float64 1.654 10.63 7.015 nan ... 12.46 2.22 15.96    precipitation  (y, x) float64 0.2136 0.9974 0.7603 ... 0.6125 0.4654 0.5953</ins>     """      # Group by data vars


Question: combinebycoords should allow for missing panels in hypercube Currently, it throws the following error: This is b/c calls , which mandates that the passed datasets form a complete hypercube. This check functiono also serves the purpose of mandating that the dimension depths are the same. Could we pull that part out as a separate function and, for , only call this first part but NOT mandate that the hypercube is complete? The expected behavior, in my mind, should be to simply replace the missing tiles of the hypercube with . I'll file a PR to this effect and welcome comments. <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Dec 6 2019, 08:54:18) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.14.150+ machine: x8664 processor: x8664 byteorder: little LCALL: enUS.UTF-8 LANG: enUS.UTF-8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.14.1 pandas: 0.25.3 numpy: 1.17.3 scipy: 1.3.2 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: 2.3.2 cftime: 1.0.4.2 nctime_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.1 cfgrib: None iris: 2.2.0 bottleneck: None dask: 2.8.1 distributed: 2.8.1 matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 42.0.2.post20191201 pip: 19.3.1 conda: 4.8.0 pytest: 5.3.1 IPython: 7.10.1 sphinx: 2.2.2 </details

list(datasets_with_same_vars)         )         _check_shape_tile_ids(combined_ids)        if fill_value is None:            # check that datasets form complete hypercube            _check_shape_tile_ids(combined_ids)        else:            # check only that all datasets have same dimension depth for these            # vars            _check_dimension_depth_tile_ids(combined_ids)          # Concatenate along all of concat_dims one by one to create single ds         concatenated = _combine_nd(


Question: Merging dataArray into dataset using dataset method fails While it's possible to merge a dataset and a dataarray object using the top-level function, if you try the same thing with the method it fails. Output:

If any variables conflict (see ``compat``).         """         _check_inplace(inplace)<ins>        other = other.to_dataset() if isinstance(other, xr.DataArray) else other</ins>         merge_result = dataset_merge_method(             self,             other,


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

from .core.alignment import align, broadcast from .core.combine import auto_combine, combine_by_coords, combine_nested from .core.common import ALL_DIMS, full_like, ones_like, zeros_likefrom .core.computation import apply_ufunc, dot, wherefrom .core.computation import apply_ufunc, dot, polyval, where from .core.concat import concat from .core.dataarray import DataArray from .core.dataset import Dataset


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

"open_mfdataset",     "open_rasterio",     "open_zarr",    "polyval",     "register_dataarray_accessor",     "register_dataset_accessor",     "save_mfdataset",diff --git a/xarray/core/computation.py b/xarray/core/computation.py-- a/xarray/core/computation.py++ b/xarray/core/computation.py


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

dataset_join="exact",         dask="allowed",     )def polyval(coord, coeffs, degree_dim="degree"):    """Evaluate a polynomial at specific values    Parameters    ----------    coord : DataArray        The 1D coordinate along which to evaluate the polynomial.    coeffs : DataArray        Coefficients of the polynomials.    degree_dim : str, default "degree"        Name of the polynomial degree dimension in `coeffs`.    See also    --------    xarray.DataArray.polyfit    numpy.polyval    """    from .dataarray import DataArray    from .missing import get_clean_interp_index    x = get_clean_interp_index(coord, coord.name)    deg_coord = coeffs[degree_dim]    lhs = DataArray(        np.vander(x, int(deg_coord.max()) + 1),        dims=(coord.name, degree_dim),        coords={coord.name: coord, degree_dim: np.arange(deg_coord.max() + 1)[::-1]},    )    return (lhs * coeffs).sum(degree_dim)diff --git a/xarray/core/dask_array_ops.py b/xarray/core/dask_array_ops.py-- a/xarray/core/dask_array_ops.py++ b/xarray/core/dask_array_ops.py


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

# crop boundary.     index = (slice(None),) * axis + (slice(drop_size, drop_size + orig_shape[axis]),)     return out[index]def least_squares(lhs, rhs, rcond=None, skipna=False):    import dask.array as da    lhs_da = da.from_array(lhs, chunks=(rhs.chunks[0], lhs.shape[1]))    if skipna:        added_dim = rhs.ndim == 1        if added_dim:            rhs = rhs.reshape(rhs.shape[0], 1)        results = da.apply_along_axis(            nputils._nanpolyfit_1d,            0,            rhs,            lhs_da,            dtype=float,            shape=(lhs.shape[1] + 1,),            rcond=rcond,        )        coeffs = results[:-1, ...]        residuals = results[-1, ...]        if added_dim:            coeffs = coeffs.reshape(coeffs.shape[0])            residuals = residuals.reshape(residuals.shape[0])    else:        coeffs, residuals, _, _ = da.linalg.lstsq(lhs_da, rhs)    return coeffs, residualsdiff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py-- a/xarray/core/dataarray.py++ b/xarray/core/dataarray.py


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

return map_blocks(func, self, args, kwargs)     def polyfit(        self,        dim: Hashable,        deg: int,        skipna: bool = None,        rcond: float = None,        w: Union[Hashable, Any] = None,        full: bool = False,        cov: bool = False,    ):        """        Least squares polynomial fit.        This replicates the behaviour of `numpy.polyfit` but differs by skipping        invalid values when `skipna = True`.        Parameters        ----------        dim : hashable            Coordinate along which to fit the polynomials.        deg : int            Degree of the fitting polynomial.        skipna : bool, optional            If True, removes all invalid values before fitting each 1D slices of the array.            Default is True if data is stored in a dask.array or if there is any            invalid values, False otherwise.        rcond : float, optional            Relative condition number to the fit.        w : Union[Hashable, Any], optional            Weights to apply to the y-coordinate of the sample points.            Can be an array-like object or the name of a coordinate in the dataset.        full : bool, optional            Whether to return the residuals, matrix rank and singular values in addition            to the coefficients.        cov : Union[bool, str], optional            Whether to return to the covariance matrix in addition to the coefficients.            The matrix is not scaled if `cov='unscaled'`.        Returns        -------        polyfit_results : Dataset            A single dataset which contains:            polyfit_coefficients                The coefficients of the best fit.            polyfit_residuals                The residuals of the least-square computation (only included if `full=True`)            [dim]_matrix_rank                The effective rank of the scaled Vandermonde coefficient matrix (only included if `full=True`)            [dim]_singular_value                The singular values of the scaled Vandermonde coefficient matrix (only included if `full=True`)            polyfit_covariance                The covariance matrix of the polynomial coefficient estimates (only included if `full=False` and `cov=True`)        See also        --------        numpy.polyfit        """        return self._to_temp_dataset().polyfit(            dim, deg, skipna=skipna, rcond=rcond, w=w, full=full, cov=cov        )     def pad(         self,         pad_width: Mapping[Hashable, Union[int, Tuple[int, int]]] = None,diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py-- a/xarray/core/dataset.py++ b/xarray/core/dataset.py


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

merge_coordinates_without_align,     merge_data_and_coords, )<ins>from .missing import get_clean_interp_index</ins> from .options import OPTIONS, _get_keep_attrs from .pycompat import dask_array_type from .utils import (


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

return map_blocks(func, self, args, kwargs)     def polyfit(        self,        dim: Hashable,        deg: int,        skipna: bool = None,        rcond: float = None,        w: Union[Hashable, Any] = None,        full: bool = False,        cov: Union[bool, str] = False,    ):        """        Least squares polynomial fit.        This replicates the behaviour of `numpy.polyfit` but differs by skipping        invalid values when `skipna = True`.        Parameters        ----------        dim : hashable            Coordinate along which to fit the polynomials.        deg : int            Degree of the fitting polynomial.        skipna : bool, optional            If True, removes all invalid values before fitting each 1D slices of the array.            Default is True if data is stored in a dask.array or if there is any            invalid values, False otherwise.        rcond : float, optional            Relative condition number to the fit.        w : Union[Hashable, Any], optional            Weights to apply to the y-coordinate of the sample points.            Can be an array-like object or the name of a coordinate in the dataset.        full : bool, optional            Whether to return the residuals, matrix rank and singular values in addition            to the coefficients.        cov : Union[bool, str], optional            Whether to return to the covariance matrix in addition to the coefficients.            The matrix is not scaled if `cov='unscaled'`.        Returns        -------        polyfit_results : Dataset            A single dataset which contains (for each "var" in the input dataset):            [var]_polyfit_coefficients                The coefficients of the best fit for each variable in this dataset.            [var]_polyfit_residuals                The residuals of the least-square computation for each variable (only included if `full=True`)            [dim]_matrix_rank                The effective rank of the scaled Vandermonde coefficient matrix (only included if `full=True`)            [dim]_singular_values                The singular values of the scaled Vandermonde coefficient matrix (only included if `full=True`)            [var]_polyfit_covariance                The covariance matrix of the polynomial coefficient estimates (only included if `full=False` and `cov=True`)        See also        --------        numpy.polyfit        """        variables = {}        skipna_da = skipna        x = get_clean_interp_index(self, dim)        xname = "{}_".format(self[dim].name)        order = int(deg) + 1        lhs = np.vander(x, order)        if rcond is None:            rcond = x.shape[0] * np.core.finfo(x.dtype).eps        # Weights:        if w is not None:            if isinstance(w, Hashable):                w = self.coords[w]            w = np.asarray(w)            if w.ndim != 1:                raise TypeError("Expected a 1-d array for weights.")            if w.shape[0] != lhs.shape[0]:                raise TypeError("Expected w and {} to have the same length".format(dim))            lhs *= w[:, np.newaxis]        # Scaling        scale = np.sqrt((lhs * lhs).sum(axis=0))        lhs /= scale        degree_dim = utils.get_temp_dimname(self.dims, "degree")        rank = np.linalg.matrix_rank(lhs)        if rank != order and not full:            warnings.warn(                "Polyfit may be poorly conditioned", np.RankWarning, stacklevel=4            )        if full:            rank = xr.DataArray(rank, name=xname + "matrix_rank")            variables[rank.name] = rank            sing = np.linalg.svd(lhs, compute_uv=False)            sing = xr.DataArray(                sing,                dims=(degree_dim,),                coords={degree_dim: np.arange(order)[::-1]},                name=xname + "singular_values",            )            variables[sing.name] = sing        for name, da in self.data_vars.items():            if dim not in da.dims:                continue            if skipna is None:                if isinstance(da.data, dask_array_type):                    skipna_da = True                else:                    skipna_da = np.any(da.isnull())            dims_to_stack = [dimname for dimname in da.dims if dimname != dim]            stacked_coords = {}            if dims_to_stack:                stacked_dim = utils.get_temp_dimname(dims_to_stack, "stacked")                rhs = da.transpose(dim, *dims_to_stack).stack(                    {stacked_dim: dims_to_stack}                )                stacked_coords = {stacked_dim: rhs[stacked_dim]}                scale_da = scale[:, np.newaxis]            else:                rhs = da                scale_da = scale            if w is not None:                rhs *= w[:, np.newaxis]            coeffs, residuals = duck_array_ops.least_squares(                lhs, rhs.data, rcond=rcond, skipna=skipna_da            )            if isinstance(name, str):                name = "{}_".format(name)            else:                # Thus a ReprObject => polyfit was called on a DataArray                name = ""            coeffs = xr.DataArray(                coeffs / scale_da,                dims=[degree_dim] + list(stacked_coords.keys()),                coords={degree_dim: np.arange(order)[::-1], **stacked_coords},                name=name + "polyfit_coefficients",            )            if dims_to_stack:                coeffs = coeffs.unstack(stacked_dim)            variables[coeffs.name] = coeffs            if full or (cov is True):                residuals = xr.DataArray(                    residuals if dims_to_stack else residuals.squeeze(),                    dims=list(stacked_coords.keys()),                    coords=stacked_coords,                    name=name + "polyfit_residuals",                )                if dims_to_stack:                    residuals = residuals.unstack(stacked_dim)                variables[residuals.name] = residuals            if cov:                Vbase = np.linalg.inv(np.dot(lhs.T, lhs))                Vbase /= np.outer(scale, scale)                if cov == "unscaled":                    fac = 1                else:                    if x.shape[0] <= order:                        raise ValueError(                            "The number of data points must exceed order to scale the covariance matrix."                        )                    fac = residuals / (x.shape[0] - order)                covariance = xr.DataArray(Vbase, dims=("cov_i", "cov_j"),) * fac                variables[name + "polyfit_covariance"] = covariance        return Dataset(data_vars=variables, attrs=self.attrs.copy())     def pad(         self,         pad_width: Mapping[Hashable, Union[int, Tuple[int, int]]] = None,diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py-- a/xarray/core/duck_array_ops.py++ b/xarray/core/duck_array_ops.py


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

return dask_array_ops.rolling_window(array, axis, window, center, fill_value)     else:  # np.ndarray         return nputils.rolling_window(array, axis, window, center, fill_value)def least_squares(lhs, rhs, rcond=None, skipna=False):    """Return the coefficients and residuals of a least-squares fit.    """    if isinstance(rhs, dask_array_type):        return dask_array_ops.least_squares(lhs, rhs, rcond=rcond, skipna=skipna)    else:        return nputils.least_squares(lhs, rhs, rcond=rcond, skipna=skipna)diff --git a/xarray/core/nputils.py b/xarray/core/nputils.py-- a/xarray/core/nputils.py++ b/xarray/core/nputils.py


Question: Implement polyfit? Fitting a line (or curve) to data along a specified axis is a long-standing need of xarray users. There are many blog posts and SO questions about how to do it: The main use case in my domain is finding the temporal trend on a 3D variable (e.g. temperature in time, lon, lat). Yes, you can do it with applyufunc, but applyufunc is inaccessibly complex for many users. Much of our existing API could be removed and replaced with applyufunc calls, but that doesn't mean we should do it. I am proposing we add a Dataarray method called . It would work like this: Numpy's function is already vectorized in the sense that it accepts 1D x and 2D y, performing the fit independently over each column of y. To extend this to ND, we would just need to reshape the data going in and out of the function. We do this already in . For dask, we could simply require that the dimension over which the fit is calculated be contiguous, and then call mapblocks. Thoughts?

return f  <ins>def _nanpolyfit_1d(arr, x, rcond=None):    out = np.full((x.shape[1] + 1,), np.nan)    mask = np.isnan(arr)    if not np.all(mask):        out[:-1], out[-1], _, _ = np.linalg.lstsq(x[~mask, :], arr[~mask], rcond=rcond)    return outdef least_squares(lhs, rhs, rcond=None, skipna=False):    if skipna:        added_dim = rhs.ndim == 1        if added_dim:            rhs = rhs.reshape(rhs.shape[0], 1)        nan_cols = np.any(np.isnan(rhs), axis=0)        out = np.empty((lhs.shape[1] + 1, rhs.shape[1]))        if np.any(nan_cols):            out[:, nan_cols] = np.apply_along_axis(                _nanpolyfit_1d, 0, rhs[:, nan_cols], lhs            )        if np.any(~nan_cols):            out[:-1, ~nan_cols], out[-1, ~nan_cols], _, _ = np.linalg.lstsq(                lhs, rhs[:, ~nan_cols], rcond=rcond            )        coeffs = out[:-1, :]        residuals = out[-1, :]        if added_dim:            coeffs = coeffs.reshape(coeffs.shape[0])            residuals = residuals.reshape(residuals.shape[0])    else:        coeffs, residuals, _, _ = np.linalg.lstsq(lhs, rhs, rcond=rcond)    return coeffs, residuals</ins> nanmin = _create_bottleneck_method("nanmin") nanmax = _create_bottleneck_method("nanmax") nanmean = _create_bottleneck_method("nanmean")


Question: Turn on reprhtml by default? I just wanted to open this to discuss turning the reprhtml on by default. This PR it as a style option, but I suspect that more people will use if it is on by default. Does that seem like a reasonable change?

CMAP_SEQUENTIAL: "viridis",     CMAP_DIVERGENT: "RdBu_r",     KEEP_ATTRS: "default",    DISPLAY_STYLE: "text",    DISPLAY_STYLE: "html", }  _JOIN_OPTIONS = frozenset(["inner", "outer", "left", "right", "exact"])


Question: Truncate array repr based on line count <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --I thought we might have had an issue (and maybe solved it?) but couldn't find it anywhere. Forgive me if I'm duplicating. With larger arrays, it's much more reasonable: <!-- this should explain why the current behavior is a problem and why the expected output is a better solution --Something like 40 lines is probably a reasonable place to truncate? <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Jul 1 2019, 21:52:21) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: [...] machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.utf8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.15.0 pandas: 0.25.3 numpy: 1.17.3 scipy: 1.3.2 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: None cftime: 1.0.4.2 nctime_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 2.7.0 distributed: 2.7.0 matplotlib: 3.1.2 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 41.6.0.post20191101 pip: 19.3.1 conda: None pytest: 5.2.2 IPython: 7.9.0 sphinx: 2.2.1 </details

import contextlib import functools from datetime import datetime, timedeltafrom itertools import zip_longestfrom itertools import chain, zip_longest from typing import Hashable  import numpy as np


Question: Truncate array repr based on line count <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --I thought we might have had an issue (and maybe solved it?) but couldn't find it anywhere. Forgive me if I'm duplicating. With larger arrays, it's much more reasonable: <!-- this should explain why the current behavior is a problem and why the expected output is a better solution --Something like 40 lines is probably a reasonable place to truncate? <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Jul 1 2019, 21:52:21) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: [...] machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.utf8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.15.0 pandas: 0.25.3 numpy: 1.17.3 scipy: 1.3.2 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: None cftime: 1.0.4.2 nctime_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 2.7.0 distributed: 2.7.0 matplotlib: 3.1.2 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 41.6.0.post20191101 pip: 19.3.1 conda: None pytest: 5.2.2 IPython: 7.9.0 sphinx: 2.2.1 </details

np.set_printoptions(**original)  <ins>def limit_lines(string: str, *, limit: int):    """    If the string is more lines than the limit,    this returns the middle lines replaced by an ellipsis    """    lines = string.splitlines()    if len(lines) > limit:        string = "\n".join(chain(lines[: limit // 2], ["..."], lines[-limit // 2 :]))    return string</ins> def short_numpy_repr(array):     array = np.asarray(array)


Question: Truncate array repr based on line count <!-- In order for the maintainers to efficiently understand and prioritize issues, we ask you post a "Minimal, Complete and Verifiable Example" (MCVE): --I thought we might have had an issue (and maybe solved it?) but couldn't find it anywhere. Forgive me if I'm duplicating. With larger arrays, it's much more reasonable: <!-- this should explain why the current behavior is a problem and why the expected output is a better solution --Something like 40 lines is probably a reasonable place to truncate? <detailsINSTALLED VERSIONS commit: None python: 3.7.3 (default, Jul 1 2019, 21:52:21) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: [...] machine: x8664 processor: x8664 byteorder: little LCALL: None LANG: enUS.utf8 LOCALE: enUS.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1 xarray: 0.15.0 pandas: 0.25.3 numpy: 1.17.3 scipy: 1.3.2 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: None cftime: 1.0.4.2 nctime_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 2.7.0 distributed: 2.7.0 matplotlib: 3.1.2 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 41.6.0.post20191101 pip: 19.3.1 conda: None pytest: 5.2.2 IPython: 7.9.0 sphinx: 2.2.1 </details

elif hasattr(internal_data, "__array_function__") or isinstance(         internal_data, dask_array_type     ):        return repr(array.data)        return limit_lines(repr(array.data), limit=40)     elif array._in_memory or array.size < 1e5:         return short_numpy_repr(array)     else:


Question: In-place addition of arrays with the same coords but in a different order I have two DataArrays with the same dimension, but the index is in a different order. Adding them with works fine, but the in-place addition fails. is working fine. I would expect to do the same. The in-place addition fails: <details<summaryOutput of </summaryINSTALLED VERSIONS commit: None python: 3.8.2 (default, Mar 26 2020, 15:53:00) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.19.112-1-MANJARO machine: x8664 processor: byteorder: little LCALL: None LANG: frFR.UTF-8 LOCALE: frFR.UTF-8 libhdf5: None libnetcdf: None xarray: 0.15.0 pandas: 1.0.3 numpy: 1.18.1 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nctime_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None setuptools: 46.1.1.post20200323 pip: 20.0.2 conda: None pytest: None IPython: None sphinx: None </details

from .formatting import format_item from .indexes import Indexes, default_indexes, propagate_indexes from .indexing import is_fancy_indexerfrom .merge import PANDAS_TYPES, _extract_indexes_from_coordsfrom .merge import PANDAS_TYPES, MergeError, _extract_indexes_from_coords from .options import OPTIONS from .utils import Default, ReprObject, _check_inplace, _default, either_dict_or_kwargs from .variable import (


Question: In-place addition of arrays with the same coords but in a different order I have two DataArrays with the same dimension, but the index is in a different order. Adding them with works fine, but the in-place addition fails. is working fine. I would expect to do the same. The in-place addition fails: <details<summaryOutput of </summaryINSTALLED VERSIONS commit: None python: 3.8.2 (default, Mar 26 2020, 15:53:00) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.19.112-1-MANJARO machine: x8664 processor: byteorder: little LCALL: None LANG: frFR.UTF-8 LOCALE: frFR.UTF-8 libhdf5: None libnetcdf: None xarray: 0.15.0 pandas: 1.0.3 numpy: 1.18.1 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nctime_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None setuptools: 46.1.1.post20200323 pip: 20.0.2 conda: None pytest: None IPython: None sphinx: None </details

# don't support automatic alignment with in-place arithmetic.             other_coords = getattr(other, "coords", None)             other_variable = getattr(other, "variable", other)            with self.coords._merge_inplace(other_coords):                f(self.variable, other_variable)            try:                with self.coords._merge_inplace(other_coords):                    f(self.variable, other_variable)            except MergeError as exc:                raise MergeError(                    "Automatic alignment is not supported for in-place operations.\n"                    "Consider aligning the indices manually or using a not-in-place operation.\n"                    "See https://github.com/pydata/xarray/issues/3910 for more explanations."                ) from exc             return self          return func


Question: xr.fulllike (often) fails when other is chunked and fillvalue is non-scalar I've been running into some issues when using , when my is a chunked dask array, and the is a numpy array. Now, I just checked, mentions only scalar in the signature. However, this is a very convenient way to get all the coordinates and dimensions attached to an array like this, so it feels like desirable functionality. And as I mention below, both numpy and dask function similary, taking much more than just scalars. This results in an error: Expected is a DataArray with the dimensions and coords of , and the numpy array of as its data. The issue lies here: Calling with the given number of chunks results in it trying to to apply the for every individual chunk. As one would expect, if I set to the size of a single chunk it doesn't error: It does fail on a similarly chunked dask array (since it's applying it for every chunk): The most obvious solution would be to force it down the route, since all the values already exist in memory anyway. So maybe another type check does the trick. However, accepts quite a variety of arguments for the fill value (scalars, numpy arrays, lists, tuples, ranges). The dask docs mention only a scalar in the signature for: As does However, in all cases, they still broadcast automatically... So kind of undefined behavior of a blocked ? <details<summaryOutput of </summaryINSTALLED VERSIONS commit: None python: 3.7.6 (default, Jan 7 2020, 21:48:41) [MSC v.1916 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel byteorder: little LCALL: None LANG: en LOCALE: None.None libhdf5: 1.10.5 libnetcdf: 4.7.3 xarray: 0.15.1 pandas: 0.25.3 numpy: 1.17.5 scipy: 1.3.1 netCDF4: 1.5.3 pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: 2.4.0 cftime: 1.0.4.2 nctimeaxis: None PseudoNetCDF: None rasterio: 1.1.2 cfgrib: None iris: None bottleneck: 1.3.2 dask: 2.9.2 distributed: 2.10.0 matplotlib: 3.1.2 cartopy: None seaborn: 0.10.0 numbagg: None setuptools: 46.1.3.post20200325 pip: 20.0.2 conda: None pytest: 5.3.4 IPython: 7.13.0 sphinx: 2.3.1 </detailsxr.fulllike (often) fails when other is chunked and fillvalue is non-scalar I've been running into some issues when using , when my is a chunked dask array, and the is a numpy array. Now, I just checked, mentions only scalar in the signature. However, this is a very convenient way to get all the coordinates and dimensions attached to an array like this, so it feels like desirable functionality. And as I mention below, both numpy and dask function similary, taking much more than just scalars. This results in an error: Expected is a DataArray with the dimensions and coords of , and the numpy array of as its data. The issue lies here: Calling with the given number of chunks results in it trying to to apply the for every individual chunk. As one would expect, if I set to the size of a single chunk it doesn't error: It does fail on a similarly chunked dask array (since it's applying it for every chunk): The most obvious solution would be to force it down the route, since all the values already exist in memory anyway. So maybe another type check does the trick. However, accepts quite a variety of arguments for the fill value (scalars, numpy arrays, lists, tuples, ranges). The dask docs mention only a scalar in the signature for: As does However, in all cases, they still broadcast automatically... So kind of undefined behavior of a blocked ? <details<summaryOutput of </summaryINSTALLED VERSIONS commit: None python: 3.7.6 (default, Jan 7 2020, 21:48:41) [MSC v.1916 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel byteorder: little LCALL: None LANG: en LOCALE: None.None libhdf5: 1.10.5 libnetcdf: 4.7.3 xarray: 0.15.1 pandas: 0.25.3 numpy: 1.17.5 scipy: 1.3.1 netCDF4: 1.5.3 pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: 2.4.0 cftime: 1.0.4.2 nctimeaxis: None PseudoNetCDF: None rasterio: 1.1.2 cfgrib: None iris: None bottleneck: 1.3.2 dask: 2.9.2 distributed: 2.10.0 matplotlib: 3.1.2 cartopy: None seaborn: 0.10.0 numbagg: None setuptools: 46.1.3.post20200325 pip: 20.0.2 conda: None pytest: 5.3.4 IPython: 7.13.0 sphinx: 2.3.1 </details

from .options import OPTIONS, _get_keep_attrs from .pycompat import dask_array_type from .rolling_exp import RollingExpfrom .utils import Frozen, either_dict_or_kwargsfrom .utils import Frozen, either_dict_or_kwargs, is_scalar  # Used as a sentinel value to indicate a all dimensions ALL_DIMS = ...