{"instance_id": "pydata__xarray-2905", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/variable.py b/xarray/core/variable.py\nindex 45553eb9..ebd2731d 100644\n--- a/xarray/core/variable.py\n+++ b/xarray/core/variable.py\n@@ -201,7 +201,7 @@ def as_compatible_data(data, fastpath=False):\n         # can't use fastpath (yet) for scalars\n         return _maybe_wrap_data(data)\n \n-    if isinstance(data, Variable):\n+    if isinstance(data, (Variable, xr.DataArray)):\n         return data.data\n \n     if isinstance(data, NON_NUMPY_SUPPORTED_ARRAY_TYPES):\n@@ -218,7 +218,8 @@ def as_compatible_data(data, fastpath=False):\n         data = np.timedelta64(getattr(data, \"value\", data), \"ns\")\n \n     # we don't want nested self-described arrays\n-    data = getattr(data, \"values\", data)\n+    if isinstance(data, (pd.Series, pd.Index, pd.DataFrame)):\n+        data = data.values\n \n     if isinstance(data, np.ma.MaskedArray):\n         mask = np.ma.getmaskarray(data)\n", "model": "claude-sonnet-5-5", "steps": 12, "finished": true, "patch_lines": 23, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 23, "steps": 12}], "ms": 25451}
{"instance_id": "pydata__xarray-3095", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/variable.py b/xarray/core/variable.py\nindex 379be8f5..4dc056af 100644\n--- a/xarray/core/variable.py\n+++ b/xarray/core/variable.py\n@@ -1947,7 +1947,8 @@ class IndexVariable(Variable):\n                 # point, which doesn't have a copy method, so make a deep copy\n                 # of the underlying `pandas.MultiIndex` and create a new\n                 # `PandasIndexAdapter` instance with it.\n-                data = PandasIndexAdapter(self._data.array.copy(deep=True))\n+                data = PandasIndexAdapter(self._data.array.copy(deep=True),\n+                                          dtype=self._data.dtype)\n             else:\n                 data = self._data\n         else:\n", "model": "claude-haiku-5-5", "steps": 9, "finished": true, "patch_lines": 14, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 14, "steps": 9}], "ms": 19127}
{"instance_id": "pydata__xarray-3151", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/combine.py b/xarray/core/combine.py\nindex 37ae903b..472bc2c8 100644\n--- a/xarray/core/combine.py\n+++ b/xarray/core/combine.py\n@@ -500,8 +500,11 @@ def combine_by_coords(datasets, compat='no_conflicts', data_vars='all',\n                                    data_vars=data_vars, coords=coords,\n                                    fill_value=fill_value)\n \n-        # Check the overall coordinates are monotonically increasing\n-        for dim in concatenated.dims:\n+        # Check the overall coordinates are monotonically increasing along\n+        # the dimensions we concatenated along. Dimensions whose coordinates\n+        # are identical across datasets are left alone, so they may be\n+        # non-monotonic.\n+        for dim in concat_dims:\n             if dim in concatenated:\n                 indexes = concatenated.indexes.get(dim)\n                 if not (indexes.is_monotonic_increasing\n", "model": "claude-haiku-5-5", "steps": 7, "finished": true, "patch_lines": 18, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 18, "steps": 7}], "ms": 16938}
{"instance_id": "pydata__xarray-3305", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/variable.py b/xarray/core/variable.py\nindex 2e9906ce..59419b40 100644\n--- a/xarray/core/variable.py\n+++ b/xarray/core/variable.py\n@@ -1592,7 +1592,7 @@ class Variable(\n         \"\"\"\n         return self.broadcast_equals(other, equiv=duck_array_ops.array_notnull_equiv)\n \n-    def quantile(self, q, dim=None, interpolation=\"linear\"):\n+    def quantile(self, q, dim=None, interpolation=\"linear\", keep_attrs=None):\n         \"\"\"Compute the qth quantile of the data along the specified dimension.\n \n         Returns the qth quantiles(s) of the array elements.\n@@ -1616,6 +1616,13 @@ class Variable(\n                 * nearest: ``i`` or ``j``, whichever is nearest.\n                 * midpoint: ``(i + j) / 2``.\n \n+        Returns\n+        -------\n+        keep_attrs : bool, optional\n+            If True, the variable's attributes (`attrs`) will be copied from\n+            the original object to the new one.  If False (default), the new\n+            object will be returned without attributes.\n+\n         Returns\n         -------\n         quantiles : Variable\n@@ -1637,6 +1644,10 @@ class Variable(\n                 \"prior to calling this method.\"\n             )\n \n+        if keep_attrs is None:\n+            keep_attrs = _get_keep_attrs(default=False)\n+        attrs = self._attrs if keep_attrs else None\n+\n         q = np.asarray(q, dtype=np.float64)\n \n         new_dims = list(self.dims)\n@@ -1658,7 +1669,7 @@ class Variable(\n         qs = np.nanpercentile(\n             self.data, q * 100.0, axis=axis, interpolation=interpolation\n         )\n-        return Variable(new_dims, qs)\n+        return Variable(new_dims, qs, attrs=attrs)\n \n     def rank(self, dim, pct=False):\n         \"\"\"Ranks the data.\n", "model": "claude-haiku-5-5", "steps": 12, "finished": false, "patch_lines": 47, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 47, "steps": 12}], "ms": 24501}
{"instance_id": "pydata__xarray-3677", "model_name_or_path": "cain-70b-e124", "model_patch": "diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py\nindex ac0a923d..a18c8984 100644\n--- a/xarray/core/dataset.py\n+++ b/xarray/core/dataset.py\n@@ -1,5700 +1,4 @@\n-import copy\n-import functools\n-import sys\n-import warnings\n-from collections import defaultdict\n-from html import escape\n-from numbers import Number\n-from pathlib import Path\n-from typing import (\n-    TYPE_CHECKING,\n-    Any,\n-    Callable,\n-    DefaultDict,\n-    Dict,\n-    Hashable,\n-    Iterable,\n-    Iterator,\n-    List,\n-    Mapping,\n-    MutableMapping,\n-    Optional,\n-    Sequence,\n-    Set,\n-    Tuple,\n-    TypeVar,\n-    Union,\n-    cast,\n-)\n-\n-import numpy as np\n-import pandas as pd\n-\n-import xarray as xr\n-\n-from ..coding.cftimeindex import _parse_array_of_cftime_strings\n-from ..plot.dataset_plot import _Dataset_PlotMethods\n-from . import (\n-    alignment,\n-    dtypes,\n-    duck_array_ops,\n-    formatting,\n-    formatting_html,\n-    groupby,\n-    ops,\n-    resample,\n-    rolling,\n-    utils,\n-)\n-from .alignment import _broadcast_helper, _get_broadcast_dims_map_common_coords, align\n-from .common import (\n-    DataWithCoords,\n-    ImplementsDatasetReduce,\n-    _contains_datetime_like_objects,\n-)\n-from .coordinates import (\n-    DatasetCoordinates,\n-    LevelCoordinatesSource,\n-    assert_coordinate_consistent,\n-    remap_label_indexers,\n-)\n-from .duck_array_ops import datetime_to_numeric\n-from .indexes import (\n-    Indexes,\n-    default_indexes,\n-    isel_variable_and_index,\n-    propagate_indexes,\n-    roll_index,\n-)\n-from .indexing import is_fancy_indexer\n-from .merge import (\n-    dataset_merge_method,\n-    dataset_update_method,\n-    merge_coordinates_without_align,\n-    merge_data_and_coords,\n-)\n-from .options import OPTIONS, _get_keep_attrs\n-from .pycompat import dask_array_type\n-from .utils import (\n-    Default,\n-    Frozen,\n-    SortedKeysDict,\n-    _check_inplace,\n-    _default,\n-    decode_numpy_dict_values,\n-    either_dict_or_kwargs,\n-    hashable,\n-    is_dict_like,\n-    is_list_like,\n-    is_scalar,\n-    maybe_wrap_array,\n-)\n-from .variable import (\n-    IndexVariable,\n-    Variable,\n-    as_variable,\n-    broadcast_variables,\n-    assert_unique_multiindex_level_names,\n-)\n-\n-if TYPE_CHECKING:\n-    from ..backends import AbstractDataStore, ZarrStore\n-    from .dataarray import DataArray\n-    from .merge import CoercibleMapping\n-\n-    T_DSorDA = TypeVar(\"T_DSorDA\", DataArray, \"Dataset\")\n-\n-    try:\n-        from dask.delayed import Delayed\n-    except ImportError:\n-        Delayed = None\n-\n-\n-# list of attributes of pd.DatetimeIndex that are ndarrays of time info\n-_DATETIMEINDEX_COMPONENTS = [\n-    \"year\",\n-    \"month\",\n-    \"day\",\n-    \"hour\",\n-    \"minute\",\n-    \"second\",\n-    \"microsecond\",\n-    \"nanosecond\",\n-    \"date\",\n-    \"time\",\n-    \"dayofyear\",\n-    \"weekofyear\",\n-    \"dayofweek\",\n-    \"quarter\",\n-]\n-\n-\n-def _get_virtual_variable(\n-    variables, key: Hashable, level_vars: Mapping = None, dim_sizes: Mapping = None\n-) -> Tuple[Hashable, Hashable, Variable]:\n-    \"\"\"Get a virtual variable (e.g., 'time.year' or a MultiIndex level)\n-    from a dict of xarray.Variable objects (if possible)\n-    \"\"\"\n-    if level_vars is None:\n-        level_vars = {}\n-    if dim_sizes is None:\n-        dim_sizes = {}\n-\n-    if key in dim_sizes:\n-        data = pd.Index(range(dim_sizes[key]), name=key)\n-        variable = IndexVariable((key,), data)\n-        return key, key, variable\n-\n-    if not isinstance(key, str):\n-        raise KeyError(key)\n-\n-    split_key = key.split(\".\", 1)\n-    var_name: Optional[str]\n-    if len(split_key) == 2:\n-        ref_name, var_name = split_key\n-    elif len(split_key) == 1:\n-        ref_name, var_name = key, None\n-    else:\n-        raise KeyError(key)\n-\n-    if ref_name in level_vars:\n-        dim_var = variables[level_vars[ref_name]]\n-        ref_var = dim_var.to_index_variable().get_level_variable(ref_name)\n-    else:\n-        ref_var = variables[ref_name]\n-\n-    if var_name is None:\n-        virtual_var = ref_var\n-        var_name = key\n-    else:\n-        if _contains_datetime_like_objects(ref_var):\n-            ref_var = xr.DataArray(ref_var)\n-            data = getattr(ref_var.dt, var_name).data\n-        else:\n-            data = getattr(ref_var, var_name).data\n-        virtual_var = Variable(ref_var.dims, data)\n-\n-    return ref_name, var_name, virtual_var\n-\n-\n-def calculate_dimensions(variables: Mapping[Hashable, Variable]) -> Dict[Hashable, int]:\n-    \"\"\"Calculate the dimensions corresponding to a set of variables.\n-\n-    Returns dictionary mapping from dimension names to sizes. Raises ValueError\n-    if any of the dimension sizes conflict.\n-    \"\"\"\n-    dims: Dict[Hashable, int] = {}\n-    last_used = {}\n-    scalar_vars = {k for k, v in variables.items() if not v.dims}\n-    for k, var in variables.items():\n-        for dim, size in zip(var.dims, var.shape):\n-            if dim in scalar_vars:\n-                raise ValueError(\n-                    \"dimension %r already exists as a scalar \" \"variable\" % dim\n-                )\n-            if dim not in dims:\n-                dims[dim] = size\n-                last_used[dim] = k\n-            elif dims[dim] != size:\n-                raise ValueError(\n-                    \"conflicting sizes for dimension %r: \"\n-                    \"length %s on %r and length %s on %r\"\n-                    % (dim, size, k, dims[dim], last_used[dim])\n-                )\n-    return dims\n-\n-\n-def merge_indexes(\n-    indexes: Mapping[Hashable, Union[Hashable, Sequence[Hashable]]],\n-    variables: Mapping[Hashable, Variable],\n-    coord_names: Set[Hashable],\n-    append: bool = False,\n-) -> Tuple[Dict[Hashable, Variable], Set[Hashable]]:\n-    \"\"\"Merge variables into multi-indexes.\n-\n-    Not public API. Used in Dataset and DataArray set_index\n-    methods.\n-    \"\"\"\n-    vars_to_replace: Dict[Hashable, Variable] = {}\n-    vars_to_remove: List[Hashable] = []\n-    dims_to_replace: Dict[Hashable, Hashable] = {}\n-    error_msg = \"{} is not the name of an existing variable.\"\n-\n-    for dim, var_names in indexes.items():\n-        if isinstance(var_names, str) or not isinstance(var_names, Sequence):\n-            var_names = [var_names]\n-\n-        names: List[Hashable] = []\n-        codes: List[List[int]] = []\n-        levels: List[List[int]] = []\n-        current_index_variable = variables.get(dim)\n-\n-        for n in var_names:\n-            try:\n-                var = variables[n]\n-            except KeyError:\n-                raise ValueError(error_msg.format(n))\n-            if (\n-                current_index_variable is not None\n-                and var.dims != current_index_variable.dims\n-            ):\n-                raise ValueError(\n-                    \"dimension mismatch between %r %s and %r %s\"\n-                    % (dim, current_index_variable.dims, n, var.dims)\n-                )\n-\n-        if current_index_variable is not None and append:\n-            current_index = current_index_variable.to_index()\n-            if isinstance(current_index, pd.MultiIndex):\n-                names.extend(current_index.names)\n-                codes.extend(current_index.codes)\n-                levels.extend(current_index.levels)\n-            else:\n-                names.append(\"%s_level_0\" % dim)\n-                cat = pd.Categorical(current_index.values, ordered=True)\n-                codes.append(cat.codes)\n-                levels.append(cat.categories)\n-\n-        if not len(names) and len(var_names) == 1:\n-            idx = pd.Index(variables[var_names[0]].values)\n-\n-        else:  # MultiIndex\n-            for n in var_names:\n-                try:\n-                    var = variables[n]\n-                except KeyError:\n-                    raise ValueError(error_msg.format(n))\n-                names.append(n)\n-                cat = pd.Categorical(var.values, ordered=True)\n-                codes.append(cat.codes)\n-                levels.append(cat.categories)\n-\n-            idx = pd.MultiIndex(levels, codes, names=names)\n-            for n in names:\n-                dims_to_replace[n] = dim\n-\n-        vars_to_replace[dim] = IndexVariable(dim, idx)\n-        vars_to_remove.extend(var_names)\n-\n-    new_variables = {k: v for k, v in variables.items() if k not in vars_to_remove}\n-    new_variables.update(vars_to_replace)\n-\n-    # update dimensions if necessary  GH: 3512\n-    for k, v in new_variables.items():\n-        if any(d in dims_to_replace for d in v.dims):\n-            new_dims = [dims_to_replace.get(d, d) for d in v.dims]\n-            new_variables[k] = v._replace(dims=new_dims)\n-    new_coord_names = coord_names | set(vars_to_replace)\n-    new_coord_names -= set(vars_to_remove)\n-    return new_variables, new_coord_names\n-\n-\n-def split_indexes(\n-    dims_or_levels: Union[Hashable, Sequence[Hashable]],\n-    variables: Mapping[Hashable, Variable],\n-    coord_names: Set[Hashable],\n-    level_coords: Mapping[Hashable, Hashable],\n-    drop: bool = False,\n-) -> Tuple[Dict[Hashable, Variable], Set[Hashable]]:\n-    \"\"\"Extract (multi-)indexes (levels) as variables.\n-\n-    Not public API. Used in Dataset and DataArray reset_index\n-    methods.\n-    \"\"\"\n-    if isinstance(dims_or_levels, str) or not isinstance(dims_or_levels, Sequence):\n-        dims_or_levels = [dims_or_levels]\n-\n-    dim_levels: DefaultDict[Any, List[Hashable]] = defaultdict(list)\n-    dims = []\n-    for k in dims_or_levels:\n-        if k in level_coords:\n-            dim_levels[level_coords[k]].append(k)\n-        else:\n-            dims.append(k)\n-\n-    vars_to_replace = {}\n-    vars_to_create: Dict[Hashable, Variable] = {}\n-    vars_to_remove = []\n-\n-    for d in dims:\n-        index = variables[d].to_index()\n-        if isinstance(index, pd.MultiIndex):\n-            dim_levels[d] = index.names\n-        else:\n-            vars_to_remove.append(d)\n-            if not drop:\n-                vars_to_create[str(d) + \"_\"] = Variable(d, index)\n-\n-    for d, levs in dim_levels.items():\n-        index = variables[d].to_index()\n-        if len(levs) == index.nlevels:\n-            vars_to_remove.append(d)\n-        else:\n-            vars_to_replace[d] = IndexVariable(d, index.droplevel(levs))\n-\n-        if not drop:\n-            for lev in levs:\n-                idx = index.get_level_values(lev)\n-                vars_to_create[idx.name] = Variable(d, idx)\n-\n-    new_variables = dict(variables)\n-    for v in set(vars_to_remove):\n-        del new_variables[v]\n-    new_variables.update(vars_to_replace)\n-    new_variables.update(vars_to_create)\n-    new_coord_names = (coord_names | set(vars_to_create)) - set(vars_to_remove)\n-\n-    return new_variables, new_coord_names\n-\n-\n-def _assert_empty(args: tuple, msg: str = \"%s\") -> None:\n-    if args:\n-        raise ValueError(msg % args)\n-\n-\n-def as_dataset(obj: Any) -> \"Dataset\":\n-    \"\"\"Cast the given object to a Dataset.\n-\n-    Handles Datasets, DataArrays and dictionaries of variables. A new Dataset\n-    object is only created if the provided object is not already one.\n-    \"\"\"\n-    if hasattr(obj, \"to_dataset\"):\n-        obj = obj.to_dataset()\n-    if not isinstance(obj, Dataset):\n-        obj = Dataset(obj)\n-    return obj\n-\n-\n-class DataVariables(Mapping[Hashable, \"DataArray\"]):\n-    __slots__ = (\"_dataset\",)\n-\n-    def __init__(self, dataset: \"Dataset\"):\n-        self._dataset = dataset\n-\n-    def __iter__(self) -> Iterator[Hashable]:\n-        return (\n-            key\n-            for key in self._dataset._variables\n-            if key not in self._dataset._coord_names\n-        )\n-\n-    def __len__(self) -> int:\n-        return len(self._dataset._variables) - len(self._dataset._coord_names)\n-\n-    def __contains__(self, key: Hashable) -> bool:\n-        return key in self._dataset._variables and key not in self._dataset._coord_names\n-\n-    def __getitem__(self, key: Hashable) -> \"DataArray\":\n-        if key not in self._dataset._coord_names:\n-            return cast(\"DataArray\", self._dataset[key])\n-        raise KeyError(key)\n-\n-    def __repr__(self) -> str:\n-        return formatting.data_vars_repr(self)\n-\n-    @property\n-    def variables(self) -> Mapping[Hashable, Variable]:\n-        all_variables = self._dataset.variables\n-        return Frozen({k: all_variables[k] for k in self})\n-\n-    def _ipython_key_completions_(self):\n-        \"\"\"Provide method for the key-autocompletions in IPython. \"\"\"\n-        return [\n-            key\n-            for key in self._dataset._ipython_key_completions_()\n-            if key not in self._dataset._coord_names\n-        ]\n-\n-\n-class _LocIndexer:\n-    __slots__ = (\"dataset\",)\n-\n-    def __init__(self, dataset: \"Dataset\"):\n-        self.dataset = dataset\n-\n-    def __getitem__(self, key: Mapping[Hashable, Any]) -> \"Dataset\":\n-        if not utils.is_dict_like(key):\n-            raise TypeError(\"can only lookup dictionaries from Dataset.loc\")\n-        return self.dataset.sel(key)\n-\n-\n-class Dataset(Mapping, ImplementsDatasetReduce, DataWithCoords):\n-    \"\"\"A multi-dimensional, in memory, array database.\n-\n-    A dataset resembles an in-memory representation of a NetCDF file, and\n-    consists of variables, coordinates and attributes which together form a\n-    self describing dataset.\n-\n-    Dataset implements the mapping interface with keys given by variable names\n-    and values given by DataArray objects for each variable name.\n-\n-    One dimensional variables with name equal to their dimension are index\n-    coordinates used for label based indexing.\n-    \"\"\"\n-\n-    _attrs: Optional[Dict[Hashable, Any]]\n-    _cache: Dict[str, Any]\n-    _coord_names: Set[Hashable]\n-    _dims: Dict[Hashable, int]\n-    _encoding: Optional[Dict[Hashable, Any]]\n-    _indexes: Optional[Dict[Hashable, pd.Index]]\n-    _variables: Dict[Hashable, Variable]\n-\n-    __slots__ = (\n-        \"_attrs\",\n-        \"_cache\",\n-        \"_coord_names\",\n-        \"_dims\",\n-        \"_encoding\",\n-        \"_file_obj\",\n-        \"_indexes\",\n-        \"_variables\",\n-        \"__weakref__\",\n-    )\n-\n-    _groupby_cls = groupby.DatasetGroupBy\n-    _rolling_cls = rolling.DatasetRolling\n-    _coarsen_cls = rolling.DatasetCoarsen\n-    _resample_cls = resample.DatasetResample\n-\n-    def __init__(\n-        self,\n-        # could make a VariableArgs to use more generally, and refine these\n-        # categories\n-        data_vars: Mapping[Hashable, Any] = None,\n-        coords: Mapping[Hashable, Any] = None,\n-        attrs: Mapping[Hashable, Any] = None,\n-        compat=None,\n-    ):\n-        \"\"\"To load data from a file or file-like object, use the `open_dataset`\n-        function.\n-\n-        Parameters\n-        ----------\n-        data_vars : dict-like, optional\n-            A mapping from variable names to :py:class:`~xarray.DataArray`\n-            objects, :py:class:`~xarray.Variable` objects or to tuples of the\n-            form ``(dims, data[, attrs])`` which can be used as arguments to\n-            create a new ``Variable``. Each dimension must have the same length\n-            in all variables in which it appears.\n-\n-            The following notations are accepted:\n-\n-            - mapping {var name: DataArray}\n-            - mapping {var name: Variable}\n-            - mapping {var name: (dimension name, array-like)}\n-            - mapping {var name: (tuple of dimension names, array-like)}\n-            - mapping {dimension name: array-like}\n-              (it will be automatically moved to coords, see below)\n-\n-            Each dimension must have the same length in all variables in which\n-            it appears.\n-        coords : dict-like, optional\n-            Another mapping in similar form as the `data_vars` argument,\n-            except the each item is saved on the dataset as a \"coordinate\".\n-            These variables have an associated meaning: they describe\n-            constant/fixed/independent quantities, unlike the\n-            varying/measured/dependent quantities that belong in `variables`.\n-            Coordinates values may be given by 1-dimensional arrays or scalars,\n-            in which case `dims` do not need to be supplied: 1D arrays will be\n-            assumed to give index values along the dimension with the same\n-            name.\n-\n-            The following notations are accepted:\n-\n-            - mapping {coord name: DataArray}\n-            - mapping {coord name: Variable}\n-            - mapping {coord name: (dimension name, array-like)}\n-            - mapping {coord name: (tuple of dimension names, array-like)}\n-            - mapping {dimension name: array-like}\n-              (the dimension name is implicitly set to be the same as the coord name)\n-\n-            The last notation implies that the coord name is the same as the\n-            dimension name.\n-\n-        attrs : dict-like, optional\n-            Global attributes to save on this dataset.\n-        compat : deprecated\n-        \"\"\"\n-        if compat is not None:\n-            warnings.warn(\n-                \"The `compat` argument to Dataset is deprecated and will be \"\n-                \"removed in 0.15.\"\n-                \"Instead, use `merge` to control how variables are combined\",\n-                FutureWarning,\n-                stacklevel=2,\n-            )\n-        else:\n-            compat = \"broadcast_equals\"\n-\n-        # TODO(shoyer): expose indexes as a public argument in __init__\n-\n-        if data_vars is None:\n-            data_vars = {}\n-        if coords is None:\n-            coords = {}\n-\n-        both_data_and_coords = set(data_vars) & set(coords)\n-        if both_data_and_coords:\n-            raise ValueError(\n-                \"variables %r are found in both data_vars and coords\"\n-                % both_data_and_coords\n-            )\n-\n-        if isinstance(coords, Dataset):\n-            coords = coords.variables\n-\n-        variables, coord_names, dims, indexes = merge_data_and_coords(\n-            data_vars, coords, compat=compat\n-        )\n-\n-        self._attrs = dict(attrs) if attrs is not None else None\n-        self._file_obj = None\n-        self._encoding = None\n-        self._variables = variables\n-        self._coord_names = coord_names\n-        self._dims = dims\n-        self._indexes = indexes\n-\n-    @classmethod\n-    def load_store(cls, store, decoder=None) -> \"Dataset\":\n-        \"\"\"Create a new dataset from the contents of a backends.*DataStore\n-        object\n-        \"\"\"\n-        variables, attributes = store.load()\n-        if decoder:\n-            variables, attributes = decoder(variables, attributes)\n-        obj = cls(variables, attrs=attributes)\n-        obj._file_obj = store\n-        return obj\n-\n-    @property\n-    def variables(self) -> Mapping[Hashable, Variable]:\n-        \"\"\"Low level interface to Dataset contents as dict of Variable objects.\n-\n-        This ordered dictionary is frozen to prevent mutation that could\n-        violate Dataset invariants. It contains all variable objects\n-        constituting the Dataset, including both data variables and\n-        coordinates.\n-        \"\"\"\n-        return Frozen(self._variables)\n-\n-    @property\n-    def attrs(self) -> Dict[Hashable, Any]:\n-        \"\"\"Dictionary of global attributes on this dataset\n-        \"\"\"\n-        if self._attrs is None:\n-            self._attrs = {}\n-        return self._attrs\n-\n-    @attrs.setter\n-    def attrs(self, value: Mapping[Hashable, Any]) -> None:\n-        self._attrs = dict(value)\n-\n-    @property\n-    def encoding(self) -> Dict:\n-        \"\"\"Dictionary of global encoding attributes on this dataset\n-        \"\"\"\n-        if self._encoding is None:\n-            self._encoding = {}\n-        return self._encoding\n-\n-    @encoding.setter\n-    def encoding(self, value: Mapping) -> None:\n-        self._encoding = dict(value)\n-\n-    @property\n-    def dims(self) -> Mapping[Hashable, int]:\n-        \"\"\"Mapping from dimension names to lengths.\n-\n-        Cannot be modified directly, but is updated when adding new variables.\n-\n-        Note that type of this object differs from `DataArray.dims`.\n-        See `Dataset.sizes` and `DataArray.sizes` for consistently named\n-        properties.\n-        \"\"\"\n-        return Frozen(SortedKeysDict(self._dims))\n-\n-    @property\n-    def sizes(self) -> Mapping[Hashable, int]:\n-        \"\"\"Mapping from dimension names to lengths.\n-\n-        Cannot be modified directly, but is updated when adding new variables.\n-\n-        This is an alias for `Dataset.dims` provided for the benefit of\n-        consistency with `DataArray.sizes`.\n-\n-        See also\n-        --------\n-        DataArray.sizes\n-        \"\"\"\n-        return self.dims\n-\n-    def load(self, **kwargs) -> \"Dataset\":\n-        \"\"\"Manually trigger loading and/or computation of this dataset's data\n-        from disk or a remote source into memory and return this dataset.\n-        Unlike compute, the original dataset is modified and returned.\n-\n-        Normally, it should not be necessary to call this method in user code,\n-        because all xarray functions should either work on deferred data or\n-        load data automatically. However, this method can be necessary when\n-        working with many file objects on disk.\n-\n-        Parameters\n-        ----------\n-        **kwargs : dict\n-            Additional keyword arguments passed on to ``dask.array.compute``.\n-\n-        See Also\n-        --------\n-        dask.array.compute\n-        \"\"\"\n-        # access .data to coerce everything to numpy or dask arrays\n-        lazy_data = {\n-            k: v._data\n-            for k, v in self.variables.items()\n-            if isinstance(v._data, dask_array_type)\n-        }\n-        if lazy_data:\n-            import dask.array as da\n-\n-            # evaluate all the dask arrays simultaneously\n-            evaluated_data = da.compute(*lazy_data.values(), **kwargs)\n-\n-            for k, data in zip(lazy_data, evaluated_data):\n-                self.variables[k].data = data\n-\n-        # load everything else sequentially\n-        for k, v in self.variables.items():\n-            if k not in lazy_data:\n-                v.load()\n-\n-        return self\n-\n-    def __dask_tokenize__(self):\n-        from dask.base import normalize_token\n-\n-        return normalize_token(\n-            (type(self), self._variables, self._coord_names, self._attrs)\n-        )\n-\n-    def __dask_graph__(self):\n-        graphs = {k: v.__dask_graph__() for k, v in self.variables.items()}\n-        graphs = {k: v for k, v in graphs.items() if v is not None}\n-        if not graphs:\n-            return None\n-        else:\n-            try:\n-                from dask.highlevelgraph import HighLevelGraph\n-\n-                return HighLevelGraph.merge(*graphs.values())\n-            except ImportError:\n-                from dask import sharedict\n-\n-                return sharedict.merge(*graphs.values())\n-\n-    def __dask_keys__(self):\n-        import dask\n-\n-        return [\n-            v.__dask_keys__()\n-            for v in self.variables.values()\n-            if dask.is_dask_collection(v)\n-        ]\n-\n-    def __dask_layers__(self):\n-        import dask\n-\n-        return sum(\n-            [\n-                v.__dask_layers__()\n-                for v in self.variables.values()\n-                if dask.is_dask_collection(v)\n-            ],\n-            (),\n-        )\n-\n-    @property\n-    def __dask_optimize__(self):\n-        import dask.array as da\n-\n-        return da.Array.__dask_optimize__\n-\n-    @property\n-    def __dask_scheduler__(self):\n-        import dask.array as da\n-\n-        return da.Array.__dask_scheduler__\n-\n-    def __dask_postcompute__(self):\n-        import dask\n-\n-        info = [\n-            (True, k, v.__dask_postcompute__())\n-            if dask.is_dask_collection(v)\n-            else (False, k, v)\n-            for k, v in self._variables.items()\n-        ]\n-        args = (\n-            info,\n-            self._coord_names,\n-            self._dims,\n-            self._attrs,\n-            self._indexes,\n-            self._encoding,\n-            self._file_obj,\n-        )\n-        return self._dask_postcompute, args\n-\n-    def __dask_postpersist__(self):\n-        import dask\n-\n-        info = [\n-            (True, k, v.__dask_postpersist__())\n-            if dask.is_dask_collection(v)\n-            else (False, k, v)\n-            for k, v in self._variables.items()\n-        ]\n-        args = (\n-            info,\n-            self._coord_names,\n-            self._dims,\n-            self._attrs,\n-            self._indexes,\n-            self._encoding,\n-            self._file_obj,\n-        )\n-        return self._dask_postpersist, args\n-\n-    @staticmethod\n-    def _dask_postcompute(results, info, *args):\n-        variables = {}\n-        results2 = list(results[::-1])\n-        for is_dask, k, v in info:\n-            if is_dask:\n-                func, args2 = v\n-                r = results2.pop()\n-                result = func(r, *args2)\n-            else:\n-                result = v\n-            variables[k] = result\n-\n-        final = Dataset._construct_direct(variables, *args)\n-        return final\n-\n-    @staticmethod\n-    def _dask_postpersist(dsk, info, *args):\n-        variables = {}\n-        for is_dask, k, v in info:\n-            if is_dask:\n-                func, args2 = v\n-                result = func(dsk, *args2)\n-            else:\n-                result = v\n-            variables[k] = result\n-\n-        return Dataset._construct_direct(variables, *args)\n-\n-    def compute(self, **kwargs) -> \"Dataset\":\n-        \"\"\"Manually trigger loading and/or computation of this dataset's data\n-        from disk or a remote source into memory and return a new dataset.\n-        Unlike load, the original dataset is left unaltered.\n-\n-        Normally, it should not be necessary to call this method in user code,\n-        because all xarray functions should either work on deferred data or\n-        load data automatically. However, this method can be necessary when\n-        working with many file objects on disk.\n-\n-        Parameters\n-        ----------\n-        **kwargs : dict\n-            Additional keyword arguments passed on to ``dask.array.compute``.\n-\n-        See Also\n-        --------\n-        dask.array.compute\n-        \"\"\"\n-        new = self.copy(deep=False)\n-        return new.load(**kwargs)\n-\n-    def _persist_inplace(self, **kwargs) -> \"Dataset\":\n-        \"\"\"Persist all Dask arrays in memory\n-        \"\"\"\n-        # access .data to coerce everything to numpy or dask arrays\n-        lazy_data = {\n-            k: v._data\n-            for k, v in self.variables.items()\n-            if isinstance(v._data, dask_array_type)\n-        }\n-        if lazy_data:\n-            import dask\n-\n-            # evaluate all the dask arrays simultaneously\n-            evaluated_data = dask.persist(*lazy_data.values(), **kwargs)\n-\n-            for k, data in zip(lazy_data, evaluated_data):\n-                self.variables[k].data = data\n-\n-        return self\n-\n-    def persist(self, **kwargs) -> \"Dataset\":\n-        \"\"\" Trigger computation, keeping data as dask arrays\n-\n-        This operation can be used to trigger computation on underlying dask\n-        arrays, similar to ``.compute()`` or ``.load()``.  However this\n-        operation keeps the data as dask arrays. This is particularly useful\n-        when using the dask.distributed scheduler and you want to load a large\n-        amount of data into distributed memory.\n-\n-        Parameters\n-        ----------\n-        **kwargs : dict\n-            Additional keyword arguments passed on to ``dask.persist``.\n-\n-        See Also\n-        --------\n-        dask.persist\n-        \"\"\"\n-        new = self.copy(deep=False)\n-        return new._persist_inplace(**kwargs)\n-\n-    @classmethod\n-    def _construct_direct(\n-        cls,\n-        variables,\n-        coord_names,\n-        dims=None,\n-        attrs=None,\n-        indexes=None,\n-        encoding=None,\n-        file_obj=None,\n-    ):\n-        \"\"\"Shortcut around __init__ for internal use when we want to skip\n-        costly validation\n-        \"\"\"\n-        if dims is None:\n-            dims = calculate_dimensions(variables)\n-        obj = object.__new__(cls)\n-        obj._variables = variables\n-        obj._coord_names = coord_names\n-        obj._dims = dims\n-        obj._indexes = indexes\n-        obj._attrs = attrs\n-        obj._file_obj = file_obj\n-        obj._encoding = encoding\n-        return obj\n-\n-    def _replace(\n-        self,\n-        variables: Dict[Hashable, Variable] = None,\n-        coord_names: Set[Hashable] = None,\n-        dims: Dict[Any, int] = None,\n-        attrs: Union[Dict[Hashable, Any], None, Default] = _default,\n-        indexes: Union[Dict[Any, pd.Index], None, Default] = _default,\n-        encoding: Union[dict, None, Default] = _default,\n-        inplace: bool = False,\n-    ) -> \"Dataset\":\n-        \"\"\"Fastpath constructor for internal use.\n-\n-        Returns an object with optionally with replaced attributes.\n-\n-        Explicitly passed arguments are *not* copied when placed on the new\n-        dataset. It is up to the caller to ensure that they have the right type\n-        and are not used elsewhere.\n-        \"\"\"\n-        if inplace:\n-            if variables is not None:\n-                self._variables = variables\n-            if coord_names is not None:\n-                self._coord_names = coord_names\n-            if dims is not None:\n-                self._dims = dims\n-            if attrs is not _default:\n-                self._attrs = attrs  # type: ignore # FIXME need mypy 0.750\n-            if indexes is not _default:\n-                self._indexes = indexes  # type: ignore # FIXME need mypy 0.750\n-            if encoding is not _default:\n-                self._encoding = encoding  # type: ignore # FIXME need mypy 0.750\n-            obj = self\n-        else:\n-            if variables is None:\n-                variables = self._variables.copy()\n-            if coord_names is None:\n-                coord_names = self._coord_names.copy()\n-            if dims is None:\n-                dims = self._dims.copy()\n-            if attrs is _default:\n-                attrs = copy.copy(self._attrs)\n-            if indexes is _default:\n-                indexes = copy.copy(self._indexes)\n-            if encoding is _default:\n-                encoding = copy.copy(self._encoding)\n-            obj = self._construct_direct(\n-                variables, coord_names, dims, attrs, indexes, encoding\n-            )\n-        return obj\n-\n-    def _replace_with_new_dims(\n-        self,\n-        variables: Dict[Hashable, Variable],\n-        coord_names: set = None,\n-        attrs: Union[Dict[Hashable, Any], None, Default] = _default,\n-        indexes: Union[Dict[Hashable, pd.Index], None, Default] = _default,\n-        inplace: bool = False,\n-    ) -> \"Dataset\":\n-        \"\"\"Replace variables with recalculated dimensions.\"\"\"\n-        dims = calculate_dimensions(variables)\n-        return self._replace(\n-            variables, coord_names, dims, attrs, indexes, inplace=inplace\n-        )\n-\n-    def _replace_vars_and_dims(\n-        self,\n-        variables: Dict[Hashable, Variable],\n-        coord_names: set = None,\n-        dims: Dict[Hashable, int] = None,\n-        attrs: Union[Dict[Hashable, Any], None, Default] = _default,\n-        inplace: bool = False,\n-    ) -> \"Dataset\":\n-        \"\"\"Deprecated version of _replace_with_new_dims().\n-\n-        Unlike _replace_with_new_dims(), this method always recalculates\n-        indexes from variables.\n-        \"\"\"\n-        if dims is None:\n-            dims = calculate_dimensions(variables)\n-        return self._replace(\n-            variables, coord_names, dims, attrs, indexes=None, inplace=inplace\n-        )\n-\n-    def _overwrite_indexes(self, indexes: Mapping[Any, pd.Index]) -> \"Dataset\":\n-        if not indexes:\n-            return self\n-\n-        variables = self._variables.copy()\n-        new_indexes = dict(self.indexes)\n-        for name, idx in indexes.items():\n-            variables[name] = IndexVariable(name, idx)\n-            new_indexes[name] = idx\n-        obj = self._replace(variables, indexes=new_indexes)\n-\n-        # switch from dimension to level names, if necessary\n-        dim_names: Dict[Hashable, str] = {}\n-        for dim, idx in indexes.items():\n-            if not isinstance(idx, pd.MultiIndex) and idx.name != dim:\n-                dim_names[dim] = idx.name\n-        if dim_names:\n-            obj = obj.rename(dim_names)\n-        return obj\n-\n-    def copy(self, deep: bool = False, data: Mapping = None) -> \"Dataset\":\n-        \"\"\"Returns a copy of this dataset.\n-\n-        If `deep=True`, a deep copy is made of each of the component variables.\n-        Otherwise, a shallow copy of each of the component variable is made, so\n-        that the underlying memory region of the new dataset is the same as in\n-        the original dataset.\n-\n-        Use `data` to create a new object with the same structure as\n-        original but entirely new data.\n-\n-        Parameters\n-        ----------\n-        deep : bool, optional\n-            Whether each component variable is loaded into memory and copied onto\n-            the new object. Default is False.\n-        data : dict-like, optional\n-            Data to use in the new object. Each item in `data` must have same\n-            shape as corresponding data variable in original. When `data` is\n-            used, `deep` is ignored for the data variables and only used for\n-            coords.\n-\n-        Returns\n-        -------\n-        object : Dataset\n-            New object with dimensions, attributes, coordinates, name, encoding,\n-            and optionally data copied from original.\n-\n-        Examples\n-        --------\n-\n-        Shallow copy versus deep copy\n-\n-        >>> da = xr.DataArray(np.random.randn(2, 3))\n-        >>> ds = xr.Dataset({'foo': da, 'bar': ('x', [-1, 2])},\n-                            coords={'x': ['one', 'two']})\n-        >>> ds.copy()\n-        <xarray.Dataset>\n-        Dimensions:  (dim_0: 2, dim_1: 3, x: 2)\n-        Coordinates:\n-        * x        (x) <U3 'one' 'two'\n-        Dimensions without coordinates: dim_0, dim_1\n-        Data variables:\n-            foo      (dim_0, dim_1) float64 -0.8079 0.3897 -1.862 -0.6091 -1.051 -0.3003\n-            bar      (x) int64 -1 2\n-        >>> ds_0 = ds.copy(deep=False)\n-        >>> ds_0['foo'][0, 0] = 7\n-        >>> ds_0\n-        <xarray.Dataset>\n-        Dimensions:  (dim_0: 2, dim_1: 3, x: 2)\n-        Coordinates:\n-        * x        (x) <U3 'one' 'two'\n-        Dimensions without coordinates: dim_0, dim_1\n-        Data variables:\n-            foo      (dim_0, dim_1) float64 7.0 0.3897 -1.862 -0.6091 -1.051 -0.3003\n-            bar      (x) int64 -1 2\n-        >>> ds\n-        <xarray.Dataset>\n-        Dimensions:  (dim_0: 2, dim_1: 3, x: 2)\n-        Coordinates:\n-        * x        (x) <U3 'one' 'two'\n-        Dimensions without coordinates: dim_0, dim_1\n-        Data variables:\n-            foo      (dim_0, dim_1) float64 7.0 0.3897 -1.862 -0.6091 -1.051 -0.3003\n-            bar      (x) int64 -1 2\n-\n-        Changing the data using the ``data`` argument maintains the\n-        structure of the original object, but with the new data. Original\n-        object is unaffected.\n-\n-        >>> ds.copy(data={'foo': np.arange(6).reshape(2, 3), 'bar': ['a', 'b']})\n-        <xarray.Dataset>\n-        Dimensions:  (dim_0: 2, dim_1: 3, x: 2)\n-        Coordinates:\n-        * x        (x) <U3 'one' 'two'\n-        Dimensions without coordinates: dim_0, dim_1\n-        Data variables:\n-            foo      (dim_0, dim_1) int64 0 1 2 3 4 5\n-            bar      (x) <U1 'a' 'b'\n-        >>> ds\n-        <xarray.Dataset>\n-        Dimensions:  (dim_0: 2, dim_1: 3, x: 2)\n-        Coordinates:\n-        * x        (x) <U3 'one' 'two'\n-        Dimensions without coordinates: dim_0, dim_1\n-        Data variables:\n-            foo      (dim_0, dim_1) float64 7.0 0.3897 -1.862 -0.6091 -1.051 -0.3003\n-            bar      (x) int64 -1 2\n-\n-        See Also\n-        --------\n-        pandas.DataFrame.copy\n-        \"\"\"\n-        if data is None:\n-            variables = {k: v.copy(deep=deep) for k, v in self._variables.items()}\n-        elif not utils.is_dict_like(data):\n-            raise ValueError(\"Data must be dict-like\")\n-        else:\n-            var_keys = set(self.data_vars.keys())\n-            data_keys = set(data.keys())\n-            keys_not_in_vars = data_keys - var_keys\n-            if keys_not_in_vars:\n-                raise ValueError(\n-                    \"Data must only contain variables in original \"\n-                    \"dataset. Extra variables: {}\".format(keys_not_in_vars)\n-                )\n-            keys_missing_from_data = var_keys - data_keys\n-            if keys_missing_from_data:\n-                raise ValueError(\n-                    \"Data must contain all variables in original \"\n-                    \"dataset. Data is missing {}\".format(keys_missing_from_data)\n-                )\n-            variables = {\n-                k: v.copy(deep=deep, data=data.get(k))\n-                for k, v in self._variables.items()\n-            }\n-\n-        attrs = copy.deepcopy(self._attrs) if deep else copy.copy(self._attrs)\n-\n-        return self._replace(variables, attrs=attrs)\n-\n-    @property\n-    def _level_coords(self) -> Dict[str, Hashable]:\n-        \"\"\"Return a mapping of all MultiIndex levels and their corresponding\n-        coordinate name.\n-        \"\"\"\n-        level_coords: Dict[str, Hashable] = {}\n-        for name, index in self.indexes.items():\n-            if isinstance(index, pd.MultiIndex):\n-                level_names = index.names\n-                (dim,) = self.variables[name].dims\n-                level_coords.update({lname: dim for lname in level_names})\n-        return level_coords\n-\n-    def _copy_listed(self, names: Iterable[Hashable]) -> \"Dataset\":\n-        \"\"\"Create a new Dataset with the listed variables from this dataset and\n-        the all relevant coordinates. Skips all validation.\n-        \"\"\"\n-        variables: Dict[Hashable, Variable] = {}\n-        coord_names = set()\n-        indexes: Dict[Hashable, pd.Index] = {}\n-\n-        for name in names:\n-            try:\n-                variables[name] = self._variables[name]\n-            except KeyError:\n-                ref_name, var_name, var = _get_virtual_variable(\n-                    self._variables, name, self._level_coords, self.dims\n-                )\n-                variables[var_name] = var\n-                if ref_name in self._coord_names or ref_name in self.dims:\n-                    coord_names.add(var_name)\n-                if (var_name,) == var.dims:\n-                    indexes[var_name] = var.to_index()\n-\n-        needed_dims: Set[Hashable] = set()\n-        for v in variables.values():\n-            needed_dims.update(v.dims)\n-\n-        dims = {k: self.dims[k] for k in needed_dims}\n-\n-        for k in self._coord_names:\n-            if set(self.variables[k].dims) <= needed_dims:\n-                variables[k] = self._variables[k]\n-                coord_names.add(k)\n-                if k in self.indexes:\n-                    indexes[k] = self.indexes[k]\n-\n-        return self._replace(variables, coord_names, dims, indexes=indexes)\n-\n-    def _construct_dataarray(self, name: Hashable) -> \"DataArray\":\n-        \"\"\"Construct a DataArray by indexing this dataset\n-        \"\"\"\n-        from .dataarray import DataArray\n-\n-        try:\n-            variable = self._variables[name]\n-        except KeyError:\n-            _, name, variable = _get_virtual_variable(\n-                self._variables, name, self._level_coords, self.dims\n-            )\n-\n-        needed_dims = set(variable.dims)\n-\n-        coords: Dict[Hashable, Variable] = {}\n-        for k in self.coords:\n-            if set(self.variables[k].dims) <= needed_dims:\n-                coords[k] = self.variables[k]\n-\n-        if self._indexes is None:\n-            indexes = None\n-        else:\n-            indexes = {k: v for k, v in self._indexes.items() if k in coords}\n-\n-        return DataArray(variable, coords, name=name, indexes=indexes, fastpath=True)\n-\n-    def __copy__(self) -> \"Dataset\":\n-        return self.copy(deep=False)\n-\n-    def __deepcopy__(self, memo=None) -> \"Dataset\":\n-        # memo does nothing but is required for compatibility with\n-        # copy.deepcopy\n-        return self.copy(deep=True)\n-\n-    @property\n-    def _attr_sources(self) -> List[Mapping[Hashable, Any]]:\n-        \"\"\"List of places to look-up items for attribute-style access\n-        \"\"\"\n-        return self._item_sources + [self.attrs]\n-\n-    @property\n-    def _item_sources(self) -> List[Mapping[Hashable, Any]]:\n-        \"\"\"List of places to look-up items for key-completion\n-        \"\"\"\n-        return [\n-            self.data_vars,\n-            self.coords,\n-            {d: self[d] for d in self.dims},\n-            LevelCoordinatesSource(self),\n-        ]\n-\n-    def __contains__(self, key: object) -> bool:\n-        \"\"\"The 'in' operator will return true or false depending on whether\n-        'key' is an array in the dataset or not.\n-        \"\"\"\n-        return key in self._variables\n-\n-    def __len__(self) -> int:\n-        return len(self.data_vars)\n-\n-    def __bool__(self) -> bool:\n-        return bool(self.data_vars)\n-\n-    def __iter__(self) -> Iterator[Hashable]:\n-        return iter(self.data_vars)\n-\n-    def __array__(self, dtype=None):\n-        raise TypeError(\n-            \"cannot directly convert an xarray.Dataset into a \"\n-            \"numpy array. Instead, create an xarray.DataArray \"\n-            \"first, either with indexing on the Dataset or by \"\n-            \"invoking the `to_array()` method.\"\n-        )\n-\n-    @property\n-    def nbytes(self) -> int:\n-        return sum(v.nbytes for v in self.variables.values())\n-\n-    @property\n-    def loc(self) -> _LocIndexer:\n-        \"\"\"Attribute for location based indexing. Only supports __getitem__,\n-        and only when the key is a dict of the form {dim: labels}.\n-        \"\"\"\n-        return _LocIndexer(self)\n-\n-    def __getitem__(self, key: Any) -> \"Union[DataArray, Dataset]\":\n-        \"\"\"Access variables or coordinates this dataset as a\n-        :py:class:`~xarray.DataArray`.\n-\n-        Indexing with a list of names will return a new ``Dataset`` object.\n-        \"\"\"\n-        # TODO(shoyer): type this properly: https://github.com/python/mypy/issues/7328\n-        if utils.is_dict_like(key):\n-            return self.isel(**cast(Mapping, key))\n-\n-        if hashable(key):\n-            return self._construct_dataarray(key)\n-        else:\n-            return self._copy_listed(np.asarray(key))\n-\n-    def __setitem__(self, key: Hashable, value) -> None:\n-        \"\"\"Add an array to this dataset.\n-\n-        If value is a `DataArray`, call its `select_vars()` method, rename it\n-        to `key` and merge the contents of the resulting dataset into this\n-        dataset.\n-\n-        If value is an `Variable` object (or tuple of form\n-        ``(dims, data[, attrs])``), add it to this dataset as a new\n-        variable.\n-        \"\"\"\n-        if utils.is_dict_like(key):\n-            raise NotImplementedError(\n-                \"cannot yet use a dictionary as a key \" \"to set Dataset values\"\n-            )\n-\n-        self.update({key: value})\n-\n-    def __delitem__(self, key: Hashable) -> None:\n-        \"\"\"Remove a variable from this dataset.\n-        \"\"\"\n-        del self._variables[key]\n-        self._coord_names.discard(key)\n-        if key in self.indexes:\n-            assert self._indexes is not None\n-            del self._indexes[key]\n-        self._dims = calculate_dimensions(self._variables)\n-\n-    # mutable objects should not be hashable\n-    # https://github.com/python/mypy/issues/4266\n-    __hash__ = None  # type: ignore\n-\n-    def _all_compat(self, other: \"Dataset\", compat_str: str) -> bool:\n-        \"\"\"Helper function for equals and identical\n-        \"\"\"\n-\n-        # some stores (e.g., scipy) do not seem to preserve order, so don't\n-        # require matching order for equality\n-        def compat(x: Variable, y: Variable) -> bool:\n-            return getattr(x, compat_str)(y)\n-\n-        return self._coord_names == other._coord_names and utils.dict_equiv(\n-            self._variables, other._variables, compat=compat\n-        )\n-\n-    def broadcast_equals(self, other: \"Dataset\") -> bool:\n-        \"\"\"Two Datasets are broadcast equal if they are equal after\n-        broadcasting all variables against each other.\n-\n-        For example, variables that are scalar in one dataset but non-scalar in\n-        the other dataset can still be broadcast equal if the the non-scalar\n-        variable is a constant.\n-\n-        See Also\n-        --------\n-        Dataset.equals\n-        Dataset.identical\n-        \"\"\"\n-        try:\n-            return self._all_compat(other, \"broadcast_equals\")\n-        except (TypeError, AttributeError):\n-            return False\n-\n-    def equals(self, other: \"Dataset\") -> bool:\n-        \"\"\"Two Datasets are equal if they have matching variables and\n-        coordinates, all of which are equal.\n-\n-        Datasets can still be equal (like pandas objects) if they have NaN\n-        values in the same locations.\n-\n-        This method is necessary because `v1 == v2` for ``Dataset``\n-        does element-wise comparisons (like numpy.ndarrays).\n-\n-        See Also\n-        --------\n-        Dataset.broadcast_equals\n-        Dataset.identical\n-        \"\"\"\n-        try:\n-            return self._all_compat(other, \"equals\")\n-        except (TypeError, AttributeError):\n-            return False\n-\n-    def identical(self, other: \"Dataset\") -> bool:\n-        \"\"\"Like equals, but also checks all dataset attributes and the\n-        attributes on all variables and coordinates.\n-\n-        See Also\n-        --------\n-        Dataset.broadcast_equals\n-        Dataset.equals\n-        \"\"\"\n-        try:\n-            return utils.dict_equiv(self.attrs, other.attrs) and self._all_compat(\n-                other, \"identical\"\n-            )\n-        except (TypeError, AttributeError):\n-            return False\n-\n-    @property\n-    def indexes(self) -> Indexes:\n-        \"\"\"Mapping of pandas.Index objects used for label based indexing\n-        \"\"\"\n-        if self._indexes is None:\n-            self._indexes = default_indexes(self._variables, self._dims)\n-        return Indexes(self._indexes)\n-\n-    @property\n-    def coords(self) -> DatasetCoordinates:\n-        \"\"\"Dictionary of xarray.DataArray objects corresponding to coordinate\n-        variables\n-        \"\"\"\n-        return DatasetCoordinates(self)\n-\n-    @property\n-    def data_vars(self) -> DataVariables:\n-        \"\"\"Dictionary of DataArray objects corresponding to data variables\n-        \"\"\"\n-        return DataVariables(self)\n-\n-    def set_coords(\n-        self, names: \"Union[Hashable, Iterable[Hashable]]\", inplace: bool = None\n-    ) -> \"Dataset\":\n-        \"\"\"Given names of one or more variables, set them as coordinates\n-\n-        Parameters\n-        ----------\n-        names : hashable or iterable of hashables\n-            Name(s) of variables in this dataset to convert into coordinates.\n-\n-        Returns\n-        -------\n-        Dataset\n-\n-        See also\n-        --------\n-        Dataset.swap_dims\n-        \"\"\"\n-        # TODO: allow inserting new coordinates with this method, like\n-        # DataFrame.set_index?\n-        # nb. check in self._variables, not self.data_vars to insure that the\n-        # operation is idempotent\n-        _check_inplace(inplace)\n-        if isinstance(names, str) or not isinstance(names, Iterable):\n-            names = [names]\n-        else:\n-            names = list(names)\n-        self._assert_all_in_dataset(names)\n-        obj = self.copy()\n-        obj._coord_names.update(names)\n-        return obj\n-\n-    def reset_coords(\n-        self,\n-        names: \"Union[Hashable, Iterable[Hashable], None]\" = None,\n-        drop: bool = False,\n-        inplace: bool = None,\n-    ) -> \"Dataset\":\n-        \"\"\"Given names of coordinates, reset them to become variables\n-\n-        Parameters\n-        ----------\n-        names : hashable or iterable of hashables, optional\n-            Name(s) of non-index coordinates in this dataset to reset into\n-            variables. By default, all non-index coordinates are reset.\n-        drop : bool, optional\n-            If True, remove coordinates instead of converting them into\n-            variables.\n-\n-        Returns\n-        -------\n-        Dataset\n-        \"\"\"\n-        _check_inplace(inplace)\n-        if names is None:\n-            names = self._coord_names - set(self.dims)\n-        else:\n-            if isinstance(names, str) or not isinstance(names, Iterable):\n-                names = [names]\n-            else:\n-                names = list(names)\n-            self._assert_all_in_dataset(names)\n-            bad_coords = set(names) & set(self.dims)\n-            if bad_coords:\n-                raise ValueError(\n-                    \"cannot remove index coordinates with reset_coords: %s\" % bad_coords\n-                )\n-        obj = self.copy()\n-        obj._coord_names.difference_update(names)\n-        if drop:\n-            for name in names:\n-                del obj._variables[name]\n-        return obj\n-\n-    def dump_to_store(self, store: \"AbstractDataStore\", **kwargs) -> None:\n-        \"\"\"Store dataset contents to a backends.*DataStore object.\n-        \"\"\"\n-        from ..backends.api import dump_to_store\n-\n-        # TODO: rename and/or cleanup this method to make it more consistent\n-        # with to_netcdf()\n-        dump_to_store(self, store, **kwargs)\n-\n-    def to_netcdf(\n-        self,\n-        path=None,\n-        mode: str = \"w\",\n-        format: str = None,\n-        group: str = None,\n-        engine: str = None,\n-        encoding: Mapping = None,\n-        unlimited_dims: Iterable[Hashable] = None,\n-        compute: bool = True,\n-        invalid_netcdf: bool = False,\n-    ) -> Union[bytes, \"Delayed\", None]:\n-        \"\"\"Write dataset contents to a netCDF file.\n-\n-        Parameters\n-        ----------\n-        path : str, Path or file-like object, optional\n-            Path to which to save this dataset. File-like objects are only\n-            supported by the scipy engine. If no path is provided, this\n-            function returns the resulting netCDF file as bytes; in this case,\n-            we need to use scipy, which does not support netCDF version 4 (the\n-            default format becomes NETCDF3_64BIT).\n-        mode : {'w', 'a'}, optional\n-            Write ('w') or append ('a') mode. If mode='w', any existing file at\n-            this location will be overwritten. If mode='a', existing variables\n-            will be overwritten.\n-        format : {'NETCDF4', 'NETCDF4_CLASSIC', 'NETCDF3_64BIT',\n-                  'NETCDF3_CLASSIC'}, optional\n-            File format for the resulting netCDF file:\n-\n-            * NETCDF4: Data is stored in an HDF5 file, using netCDF4 API\n-              features.\n-            * NETCDF4_CLASSIC: Data is stored in an HDF5 file, using only\n-              netCDF 3 compatible API features.\n-            * NETCDF3_64BIT: 64-bit offset version of the netCDF 3 file format,\n-              which fully supports 2+ GB files, but is only compatible with\n-              clients linked against netCDF version 3.6.0 or later.\n-            * NETCDF3_CLASSIC: The classic netCDF 3 file format. It does not\n-              handle 2+ GB files very well.\n-\n-            All formats are supported by the netCDF4-python library.\n-            scipy.io.netcdf only supports the last two formats.\n-\n-            The default format is NETCDF4 if you are saving a file to disk and\n-            have the netCDF4-python library available. Otherwise, xarray falls\n-            back to using scipy to write netCDF files and defaults to the\n-            NETCDF3_64BIT format (scipy does not support netCDF4).\n-        group : str, optional\n-            Path to the netCDF4 group in the given file to open (only works for\n-            format='NETCDF4'). The group(s) will be created if necessary.\n-        engine : {'netcdf4', 'scipy', 'h5netcdf'}, optional\n-            Engine to use when writing netCDF files. If not provided, the\n-            default engine is chosen based on available dependencies, with a\n-            preference for 'netcdf4' if writing to a file on disk.\n-        encoding : dict, optional\n-            Nested dictionary with variable names as keys and dictionaries of\n-            variable specific encodings as values, e.g.,\n-            ``{'my_variable': {'dtype': 'int16', 'scale_factor': 0.1,\n-            'zlib': True}, ...}``\n-\n-            The `h5netcdf` engine supports both the NetCDF4-style compression\n-            encoding parameters ``{'zlib': True, 'complevel': 9}`` and the h5py\n-            ones ``{'compression': 'gzip', 'compression_opts': 9}``.\n-            This allows using any compression plugin installed in the HDF5\n-            library, e.g. LZF.\n-\n-        unlimited_dims : iterable of hashable, optional\n-            Dimension(s) that should be serialized as unlimited dimensions.\n-            By default, no dimensions are treated as unlimited dimensions.\n-            Note that unlimited_dims may also be set via\n-            ``dataset.encoding['unlimited_dims']``.\n-        compute: boolean\n-            If true compute immediately, otherwise return a\n-            ``dask.delayed.Delayed`` object that can be computed later.\n-        invalid_netcdf: boolean\n-            Only valid along with engine='h5netcdf'. If True, allow writing\n-            hdf5 files which are valid netcdf as described in\n-            https://github.com/shoyer/h5netcdf. Default: False.\n-        \"\"\"\n-        if encoding is None:\n-            encoding = {}\n-        from ..backends.api import to_netcdf\n-\n-        return to_netcdf(\n-            self,\n-            path,\n-            mode,\n-            format=format,\n-            group=group,\n-            engine=engine,\n-            encoding=encoding,\n-            unlimited_dims=unlimited_dims,\n-            compute=compute,\n-            invalid_netcdf=invalid_netcdf,\n-        )\n-\n-    def to_zarr(\n-        self,\n-        store: Union[MutableMapping, str, Path] = None,\n-        mode: str = None,\n-        synchronizer=None,\n-        group: str = None,\n-        encoding: Mapping = None,\n-        compute: bool = True,\n-        consolidated: bool = False,\n-        append_dim: Hashable = None,\n-    ) -> \"ZarrStore\":\n-        \"\"\"Write dataset contents to a zarr group.\n-\n-        .. note:: Experimental\n-                  The Zarr backend is new and experimental. Please report any\n-                  unexpected behavior via github issues.\n-\n-        Parameters\n-        ----------\n-        store : MutableMapping, str or Path, optional\n-            Store or path to directory in file system.\n-        mode : {'w', 'w-', 'a', None}\n-            Persistence mode: 'w' means create (overwrite if exists);\n-            'w-' means create (fail if exists);\n-            'a' means append (create if does not exist).\n-            If ``append_dim`` is set, ``mode`` can be omitted as it is\n-            internally set to ``'a'``. Otherwise, ``mode`` will default to\n-            `w-` if not set.\n-        synchronizer : object, optional\n-            Array synchronizer\n-        group : str, optional\n-            Group path. (a.k.a. `path` in zarr terminology.)\n-        encoding : dict, optional\n-            Nested dictionary with variable names as keys and dictionaries of\n-            variable specific encodings as values, e.g.,\n-            ``{'my_variable': {'dtype': 'int16', 'scale_factor': 0.1,}, ...}``\n-        compute: bool, optional\n-            If True compute immediately, otherwise return a\n-            ``dask.delayed.Delayed`` object that can be computed later.\n-        consolidated: bool, optional\n-            If True, apply zarr's `consolidate_metadata` function to the store\n-            after writing.\n-        append_dim: hashable, optional\n-            If set, the dimension on which the data will be appended.\n-\n-        References\n-        ----------\n-        https://zarr.readthedocs.io/\n-        \"\"\"\n-        if encoding is None:\n-            encoding = {}\n-        if (mode == \"a\") or (append_dim is not None):\n-            if mode is None:\n-                mode = \"a\"\n-            elif mode != \"a\":\n-                raise ValueError(\n-                    \"append_dim was set along with mode='{}', either set \"\n-                    \"mode='a' or don't set it.\".format(mode)\n-                )\n-        elif mode is None:\n-            mode = \"w-\"\n-        if mode not in [\"w\", \"w-\", \"a\"]:\n-            # TODO: figure out how to handle 'r+'\n-            raise ValueError(\n-                \"The only supported options for mode are 'w',\" \"'w-' and 'a'.\"\n-            )\n-        from ..backends.api import to_zarr\n-\n-        return to_zarr(\n-            self,\n-            store=store,\n-            mode=mode,\n-            synchronizer=synchronizer,\n-            group=group,\n-            encoding=encoding,\n-            compute=compute,\n-            consolidated=consolidated,\n-            append_dim=append_dim,\n-        )\n-\n-    def __repr__(self) -> str:\n-        return formatting.dataset_repr(self)\n-\n-    def _repr_html_(self):\n-        if OPTIONS[\"display_style\"] == \"text\":\n-            return f\"<pre>{escape(repr(self))}</pre>\"\n-        return formatting_html.dataset_repr(self)\n-\n-    def info(self, buf=None) -> None:\n-        \"\"\"\n-        Concise summary of a Dataset variables and attributes.\n-\n-        Parameters\n-        ----------\n-        buf : writable buffer, defaults to sys.stdout\n-\n-        See Also\n-        --------\n-        pandas.DataFrame.assign\n-        ncdump: netCDF's ncdump\n-        \"\"\"\n-        if buf is None:  # pragma: no cover\n-            buf = sys.stdout\n-\n-        lines = []\n-        lines.append(\"xarray.Dataset {\")\n-        lines.append(\"dimensions:\")\n-        for name, size in self.dims.items():\n-            lines.append(f\"\\t{name} = {size} ;\")\n-        lines.append(\"\\nvariables:\")\n-        for name, da in self.variables.items():\n-            dims = \", \".join(da.dims)\n-            lines.append(f\"\\t{da.dtype} {name}({dims}) ;\")\n-            for k, v in da.attrs.items():\n-                lines.append(f\"\\t\\t{name}:{k} = {v} ;\")\n-        lines.append(\"\\n// global attributes:\")\n-        for k, v in self.attrs.items():\n-            lines.append(f\"\\t:{k} = {v} ;\")\n-        lines.append(\"}\")\n-\n-        buf.write(\"\\n\".join(lines))\n-\n-    @property\n-    def chunks(self) -> Mapping[Hashable, Tuple[int, ...]]:\n-        \"\"\"Block dimensions for this dataset's data or None if it's not a dask\n-        array.\n-        \"\"\"\n-        chunks: Dict[Hashable, Tuple[int, ...]] = {}\n-        for v in self.variables.values():\n-            if v.chunks is not None:\n-                for dim, c in zip(v.dims, v.chunks):\n-                    if dim in chunks and c != chunks[dim]:\n-                        raise ValueError(\n-                            f\"Object has inconsistent chunks along dimension {dim}. \"\n-                            \"This can be fixed by calling unify_chunks().\"\n-                        )\n-                    chunks[dim] = c\n-        return Frozen(SortedKeysDict(chunks))\n-\n-    def chunk(\n-        self,\n-        chunks: Union[\n-            None, Number, Mapping[Hashable, Union[None, Number, Tuple[Number, ...]]]\n-        ] = None,\n-        name_prefix: str = \"xarray-\",\n-        token: str = None,\n-        lock: bool = False,\n-    ) -> \"Dataset\":\n-        \"\"\"Coerce all arrays in this dataset into dask arrays with the given\n-        chunks.\n-\n-        Non-dask arrays in this dataset will be converted to dask arrays. Dask\n-        arrays will be rechunked to the given chunk sizes.\n-\n-        If neither chunks is not provided for one or more dimensions, chunk\n-        sizes along that dimension will not be updated; non-dask arrays will be\n-        converted into dask arrays with a single block.\n-\n-        Parameters\n-        ----------\n-        chunks : int or mapping, optional\n-            Chunk sizes along each dimension, e.g., ``5`` or\n-            ``{'x': 5, 'y': 5}``.\n-        name_prefix : str, optional\n-            Prefix for the name of any new dask arrays.\n-        token : str, optional\n-            Token uniquely identifying this dataset.\n-        lock : optional\n-            Passed on to :py:func:`dask.array.from_array`, if the array is not\n-            already as dask array.\n-\n-        Returns\n-        -------\n-        chunked : xarray.Dataset\n-        \"\"\"\n-        from dask.base import tokenize\n-\n-        if isinstance(chunks, Number):\n-            chunks = dict.fromkeys(self.dims, chunks)\n-\n-        if chunks is not None:\n-            bad_dims = chunks.keys() - self.dims.keys()\n-            if bad_dims:\n-                raise ValueError(\n-                    \"some chunks keys are not dimensions on this \"\n-                    \"object: %s\" % bad_dims\n-                )\n-\n-        def selkeys(dict_, keys):\n-            if dict_ is None:\n-                return None\n-            return {d: dict_[d] for d in keys if d in dict_}\n-\n-        def maybe_chunk(name, var, chunks):\n-            chunks = selkeys(chunks, var.dims)\n-            if not chunks:\n-                chunks = None\n-            if var.ndim > 0:\n-                token2 = tokenize(name, token if token else var._data)\n-                name2 = f\"{name_prefix}{name}-{token2}\"\n-                return var.chunk(chunks, name=name2, lock=lock)\n-            else:\n-                return var\n-\n-        variables = {k: maybe_chunk(k, v, chunks) for k, v in self.variables.items()}\n-        return self._replace(variables)\n-\n-    def _validate_indexers(\n-        self, indexers: Mapping[Hashable, Any]\n-    ) -> Iterator[Tuple[Hashable, Union[int, slice, np.ndarray, Variable]]]:\n-        \"\"\" Here we make sure\n-        + indexer has a valid keys\n-        + indexer is in a valid data type\n-        + string indexers are cast to the appropriate date type if the\n-          associated index is a DatetimeIndex or CFTimeIndex\n-        \"\"\"\n-        from .dataarray import DataArray\n-\n-        invalid = indexers.keys() - self.dims.keys()\n-        if invalid:\n-            raise ValueError(\"dimensions %r do not exist\" % invalid)\n-\n-        # all indexers should be int, slice, np.ndarrays, or Variable\n-        for k, v in indexers.items():\n-            if isinstance(v, (int, slice, Variable)):\n-                yield k, v\n-            elif isinstance(v, DataArray):\n-                yield k, v.variable\n-            elif isinstance(v, tuple):\n-                yield k, as_variable(v)\n-            elif isinstance(v, Dataset):\n-                raise TypeError(\"cannot use a Dataset as an indexer\")\n-            elif isinstance(v, Sequence) and len(v) == 0:\n-                yield k, np.empty((0,), dtype=\"int64\")\n-            else:\n-                v = np.asarray(v)\n-\n-                if v.dtype.kind in \"US\":\n-                    index = self.indexes[k]\n-                    if isinstance(index, pd.DatetimeIndex):\n-                        v = v.astype(\"datetime64[ns]\")\n-                    elif isinstance(index, xr.CFTimeIndex):\n-                        v = _parse_array_of_cftime_strings(v, index.date_type)\n-\n-                if v.ndim > 1:\n-                    raise IndexError(\n-                        \"Unlabeled multi-dimensional array cannot be \"\n-                        \"used for indexing: {}\".format(k)\n-                    )\n-                yield k, v\n-\n-    def _validate_interp_indexers(\n-        self, indexers: Mapping[Hashable, Any]\n-    ) -> Iterator[Tuple[Hashable, Variable]]:\n-        \"\"\"Variant of _validate_indexers to be used for interpolation\n-        \"\"\"\n-        for k, v in self._validate_indexers(indexers):\n-            if isinstance(v, Variable):\n-                if v.ndim == 1:\n-                    yield k, v.to_index_variable()\n-                else:\n-                    yield k, v\n-            elif isinstance(v, int):\n-                yield k, Variable((), v)\n-            elif isinstance(v, np.ndarray):\n-                if v.ndim == 0:\n-                    yield k, Variable((), v)\n-                elif v.ndim == 1:\n-                    yield k, IndexVariable((k,), v)\n-                else:\n-                    raise AssertionError()  # Already tested by _validate_indexers\n-            else:\n-                raise TypeError(type(v))\n-\n-    def _get_indexers_coords_and_indexes(self, indexers):\n-        \"\"\"Extract coordinates and indexes from indexers.\n-\n-        Only coordinate with a name different from any of self.variables will\n-        be attached.\n-        \"\"\"\n-        from .dataarray import DataArray\n-\n-        coords_list = []\n-        for k, v in indexers.items():\n-            if isinstance(v, DataArray):\n-                if v.dtype.kind == \"b\":\n-                    if v.ndim != 1:  # we only support 1-d boolean array\n-                        raise ValueError(\n-                            \"{:d}d-boolean array is used for indexing along \"\n-                            \"dimension {!r}, but only 1d boolean arrays are \"\n-                            \"supported.\".format(v.ndim, k)\n-                        )\n-                    # Make sure in case of boolean DataArray, its\n-                    # coordinate also should be indexed.\n-                    v_coords = v[v.values.nonzero()[0]].coords\n-                else:\n-                    v_coords = v.coords\n-                coords_list.append(v_coords)\n-\n-        # we don't need to call align() explicitly or check indexes for\n-        # alignment, because merge_variables already checks for exact alignment\n-        # between dimension coordinates\n-        coords, indexes = merge_coordinates_without_align(coords_list)\n-        assert_coordinate_consistent(self, coords)\n-\n-        # silently drop the conflicted variables.\n-        attached_coords = {k: v for k, v in coords.items() if k not in self._variables}\n-        attached_indexes = {\n-            k: v for k, v in indexes.items() if k not in self._variables\n-        }\n-        return attached_coords, attached_indexes\n-\n-    def isel(\n-        self,\n-        indexers: Mapping[Hashable, Any] = None,\n-        drop: bool = False,\n-        **indexers_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new dataset with each array indexed along the specified\n-        dimension(s).\n-\n-        This method selects values from each array using its `__getitem__`\n-        method, except this method does not require knowing the order of\n-        each array's dimensions.\n-\n-        Parameters\n-        ----------\n-        indexers : dict, optional\n-            A dict with keys matching dimensions and values given\n-            by integers, slice objects or arrays.\n-            indexer can be a integer, slice, array-like or DataArray.\n-            If DataArrays are passed as indexers, xarray-style indexing will be\n-            carried out. See :ref:`indexing` for the details.\n-            One of indexers or indexers_kwargs must be provided.\n-        drop : bool, optional\n-            If ``drop=True``, drop coordinates variables indexed by integers\n-            instead of making them scalar.\n-        **indexers_kwargs : {dim: indexer, ...}, optional\n-            The keyword arguments form of ``indexers``.\n-            One of indexers or indexers_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        obj : Dataset\n-            A new Dataset with the same contents as this dataset, except each\n-            array and dimension is indexed by the appropriate indexers.\n-            If indexer DataArrays have coordinates that do not conflict with\n-            this object, then these coordinates will be attached.\n-            In general, each array's data will be a view of the array's data\n-            in this dataset, unless vectorized indexing was triggered by using\n-            an array indexer, in which case the data will be a copy.\n-\n-        See Also\n-        --------\n-        Dataset.sel\n-        DataArray.isel\n-        \"\"\"\n-        indexers = either_dict_or_kwargs(indexers, indexers_kwargs, \"isel\")\n-        if any(is_fancy_indexer(idx) for idx in indexers.values()):\n-            return self._isel_fancy(indexers, drop=drop)\n-\n-        # Much faster algorithm for when all indexers are ints, slices, one-dimensional\n-        # lists, or zero or one-dimensional np.ndarray's\n-        invalid = indexers.keys() - self.dims.keys()\n-        if invalid:\n-            raise ValueError(\"dimensions %r do not exist\" % invalid)\n-\n-        variables = {}\n-        dims: Dict[Hashable, Tuple[int, ...]] = {}\n-        coord_names = self._coord_names.copy()\n-        indexes = self._indexes.copy() if self._indexes is not None else None\n-\n-        for var_name, var_value in self._variables.items():\n-            var_indexers = {k: v for k, v in indexers.items() if k in var_value.dims}\n-            if var_indexers:\n-                var_value = var_value.isel(var_indexers)\n-                if drop and var_value.ndim == 0 and var_name in coord_names:\n-                    coord_names.remove(var_name)\n-                    if indexes:\n-                        indexes.pop(var_name, None)\n-                    continue\n-                if indexes and var_name in indexes:\n-                    if var_value.ndim == 1:\n-                        indexes[var_name] = var_value.to_index()\n-                    else:\n-                        del indexes[var_name]\n-            variables[var_name] = var_value\n-            dims.update(zip(var_value.dims, var_value.shape))\n-\n-        return self._construct_direct(\n-            variables=variables,\n-            coord_names=coord_names,\n-            dims=dims,\n-            attrs=self._attrs,\n-            indexes=indexes,\n-            encoding=self._encoding,\n-            file_obj=self._file_obj,\n-        )\n-\n-    def _isel_fancy(self, indexers: Mapping[Hashable, Any], *, drop: bool) -> \"Dataset\":\n-        # Note: we need to preserve the original indexers variable in order to merge the\n-        # coords below\n-        indexers_list = list(self._validate_indexers(indexers))\n-\n-        variables: Dict[Hashable, Variable] = {}\n-        indexes: Dict[Hashable, pd.Index] = {}\n-\n-        for name, var in self.variables.items():\n-            var_indexers = {k: v for k, v in indexers_list if k in var.dims}\n-            if drop and name in var_indexers:\n-                continue  # drop this variable\n-\n-            if name in self.indexes:\n-                new_var, new_index = isel_variable_and_index(\n-                    name, var, self.indexes[name], var_indexers\n-                )\n-                if new_index is not None:\n-                    indexes[name] = new_index\n-            elif var_indexers:\n-                new_var = var.isel(indexers=var_indexers)\n-            else:\n-                new_var = var.copy(deep=False)\n-\n-            variables[name] = new_var\n-\n-        coord_names = self._coord_names & variables.keys()\n-        selected = self._replace_with_new_dims(variables, coord_names, indexes)\n-\n-        # Extract coordinates from indexers\n-        coord_vars, new_indexes = selected._get_indexers_coords_and_indexes(indexers)\n-        variables.update(coord_vars)\n-        indexes.update(new_indexes)\n-        coord_names = self._coord_names & variables.keys() | coord_vars.keys()\n-        return self._replace_with_new_dims(variables, coord_names, indexes=indexes)\n-\n-    def sel(\n-        self,\n-        indexers: Mapping[Hashable, Any] = None,\n-        method: str = None,\n-        tolerance: Number = None,\n-        drop: bool = False,\n-        **indexers_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new dataset with each array indexed by tick labels\n-        along the specified dimension(s).\n-\n-        In contrast to `Dataset.isel`, indexers for this method should use\n-        labels instead of integers.\n-\n-        Under the hood, this method is powered by using pandas's powerful Index\n-        objects. This makes label based indexing essentially just as fast as\n-        using integer indexing.\n-\n-        It also means this method uses pandas's (well documented) logic for\n-        indexing. This means you can use string shortcuts for datetime indexes\n-        (e.g., '2000-01' to select all values in January 2000). It also means\n-        that slices are treated as inclusive of both the start and stop values,\n-        unlike normal Python indexing.\n-\n-        Parameters\n-        ----------\n-        indexers : dict, optional\n-            A dict with keys matching dimensions and values given\n-            by scalars, slices or arrays of tick labels. For dimensions with\n-            multi-index, the indexer may also be a dict-like object with keys\n-            matching index level names.\n-            If DataArrays are passed as indexers, xarray-style indexing will be\n-            carried out. See :ref:`indexing` for the details.\n-            One of indexers or indexers_kwargs must be provided.\n-        method : {None, 'nearest', 'pad'/'ffill', 'backfill'/'bfill'}, optional\n-            Method to use for inexact matches:\n-\n-            * None (default): only exact matches\n-            * pad / ffill: propagate last valid index value forward\n-            * backfill / bfill: propagate next valid index value backward\n-            * nearest: use nearest valid index value\n-        tolerance : optional\n-            Maximum distance between original and new labels for inexact\n-            matches. The values of the index at the matching locations must\n-            satisfy the equation ``abs(index[indexer] - target) <= tolerance``.\n-        drop : bool, optional\n-            If ``drop=True``, drop coordinates variables in `indexers` instead\n-            of making them scalar.\n-        **indexers_kwargs : {dim: indexer, ...}, optional\n-            The keyword arguments form of ``indexers``.\n-            One of indexers or indexers_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        obj : Dataset\n-            A new Dataset with the same contents as this dataset, except each\n-            variable and dimension is indexed by the appropriate indexers.\n-            If indexer DataArrays have coordinates that do not conflict with\n-            this object, then these coordinates will be attached.\n-            In general, each array's data will be a view of the array's data\n-            in this dataset, unless vectorized indexing was triggered by using\n-            an array indexer, in which case the data will be a copy.\n-\n-\n-        See Also\n-        --------\n-        Dataset.isel\n-        DataArray.sel\n-        \"\"\"\n-        indexers = either_dict_or_kwargs(indexers, indexers_kwargs, \"sel\")\n-        pos_indexers, new_indexes = remap_label_indexers(\n-            self, indexers=indexers, method=method, tolerance=tolerance\n-        )\n-        result = self.isel(indexers=pos_indexers, drop=drop)\n-        return result._overwrite_indexes(new_indexes)\n-\n-    def head(\n-        self,\n-        indexers: Union[Mapping[Hashable, int], int] = None,\n-        **indexers_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new dataset with the first `n` values of each array\n-        for the specified dimension(s).\n-\n-        Parameters\n-        ----------\n-        indexers : dict or int, default: 5\n-            A dict with keys matching dimensions and integer values `n`\n-            or a single integer `n` applied over all dimensions.\n-            One of indexers or indexers_kwargs must be provided.\n-        **indexers_kwargs : {dim: n, ...}, optional\n-            The keyword arguments form of ``indexers``.\n-            One of indexers or indexers_kwargs must be provided.\n-\n-\n-        See Also\n-        --------\n-        Dataset.tail\n-        Dataset.thin\n-        DataArray.head\n-        \"\"\"\n-        if not indexers_kwargs:\n-            if indexers is None:\n-                indexers = 5\n-            if not isinstance(indexers, int) and not is_dict_like(indexers):\n-                raise TypeError(\"indexers must be either dict-like or a single integer\")\n-        if isinstance(indexers, int):\n-            indexers = {dim: indexers for dim in self.dims}\n-        indexers = either_dict_or_kwargs(indexers, indexers_kwargs, \"head\")\n-        for k, v in indexers.items():\n-            if not isinstance(v, int):\n-                raise TypeError(\n-                    \"expected integer type indexer for \"\n-                    \"dimension %r, found %r\" % (k, type(v))\n-                )\n-            elif v < 0:\n-                raise ValueError(\n-                    \"expected positive integer as indexer \"\n-                    \"for dimension %r, found %s\" % (k, v)\n-                )\n-        indexers_slices = {k: slice(val) for k, val in indexers.items()}\n-        return self.isel(indexers_slices)\n-\n-    def tail(\n-        self,\n-        indexers: Union[Mapping[Hashable, int], int] = None,\n-        **indexers_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new dataset with the last `n` values of each array\n-        for the specified dimension(s).\n-\n-        Parameters\n-        ----------\n-        indexers : dict or int, default: 5\n-            A dict with keys matching dimensions and integer values `n`\n-            or a single integer `n` applied over all dimensions.\n-            One of indexers or indexers_kwargs must be provided.\n-        **indexers_kwargs : {dim: n, ...}, optional\n-            The keyword arguments form of ``indexers``.\n-            One of indexers or indexers_kwargs must be provided.\n-\n-\n-        See Also\n-        --------\n-        Dataset.head\n-        Dataset.thin\n-        DataArray.tail\n-        \"\"\"\n-        if not indexers_kwargs:\n-            if indexers is None:\n-                indexers = 5\n-            if not isinstance(indexers, int) and not is_dict_like(indexers):\n-                raise TypeError(\"indexers must be either dict-like or a single integer\")\n-        if isinstance(indexers, int):\n-            indexers = {dim: indexers for dim in self.dims}\n-        indexers = either_dict_or_kwargs(indexers, indexers_kwargs, \"tail\")\n-        for k, v in indexers.items():\n-            if not isinstance(v, int):\n-                raise TypeError(\n-                    \"expected integer type indexer for \"\n-                    \"dimension %r, found %r\" % (k, type(v))\n-                )\n-            elif v < 0:\n-                raise ValueError(\n-                    \"expected positive integer as indexer \"\n-                    \"for dimension %r, found %s\" % (k, v)\n-                )\n-        indexers_slices = {\n-            k: slice(-val, None) if val != 0 else slice(val)\n-            for k, val in indexers.items()\n-        }\n-        return self.isel(indexers_slices)\n-\n-    def thin(\n-        self,\n-        indexers: Union[Mapping[Hashable, int], int] = None,\n-        **indexers_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new dataset with each array indexed along every `n`-th\n-        value for the specified dimension(s)\n-\n-        Parameters\n-        ----------\n-        indexers : dict or int\n-            A dict with keys matching dimensions and integer values `n`\n-            or a single integer `n` applied over all dimensions.\n-            One of indexers or indexers_kwargs must be provided.\n-        ``**indexers_kwargs`` : {dim: n, ...}, optional\n-            The keyword arguments form of ``indexers``.\n-            One of indexers or indexers_kwargs must be provided.\n-\n-\n-        See Also\n-        --------\n-        Dataset.head\n-        Dataset.tail\n-        DataArray.thin\n-        \"\"\"\n-        if (\n-            not indexers_kwargs\n-            and not isinstance(indexers, int)\n-            and not is_dict_like(indexers)\n-        ):\n-            raise TypeError(\"indexers must be either dict-like or a single integer\")\n-        if isinstance(indexers, int):\n-            indexers = {dim: indexers for dim in self.dims}\n-        indexers = either_dict_or_kwargs(indexers, indexers_kwargs, \"thin\")\n-        for k, v in indexers.items():\n-            if not isinstance(v, int):\n-                raise TypeError(\n-                    \"expected integer type indexer for \"\n-                    \"dimension %r, found %r\" % (k, type(v))\n-                )\n-            elif v < 0:\n-                raise ValueError(\n-                    \"expected positive integer as indexer \"\n-                    \"for dimension %r, found %s\" % (k, v)\n-                )\n-            elif v == 0:\n-                raise ValueError(\"step cannot be zero\")\n-        indexers_slices = {k: slice(None, None, val) for k, val in indexers.items()}\n-        return self.isel(indexers_slices)\n-\n-    def broadcast_like(\n-        self, other: Union[\"Dataset\", \"DataArray\"], exclude: Iterable[Hashable] = None\n-    ) -> \"Dataset\":\n-        \"\"\"Broadcast this DataArray against another Dataset or DataArray.\n-        This is equivalent to xr.broadcast(other, self)[1]\n-\n-        Parameters\n-        ----------\n-        other : Dataset or DataArray\n-            Object against which to broadcast this array.\n-        exclude : iterable of hashable, optional\n-            Dimensions that must not be broadcasted\n-\n-        \"\"\"\n-        if exclude is None:\n-            exclude = set()\n-        else:\n-            exclude = set(exclude)\n-        args = align(other, self, join=\"outer\", copy=False, exclude=exclude)\n-\n-        dims_map, common_coords = _get_broadcast_dims_map_common_coords(args, exclude)\n-\n-        return _broadcast_helper(args[1], exclude, dims_map, common_coords)\n-\n-    def reindex_like(\n-        self,\n-        other: Union[\"Dataset\", \"DataArray\"],\n-        method: str = None,\n-        tolerance: Number = None,\n-        copy: bool = True,\n-        fill_value: Any = dtypes.NA,\n-    ) -> \"Dataset\":\n-        \"\"\"Conform this object onto the indexes of another object, filling in\n-        missing values with ``fill_value``. The default fill value is NaN.\n-\n-        Parameters\n-        ----------\n-        other : Dataset or DataArray\n-            Object with an 'indexes' attribute giving a mapping from dimension\n-            names to pandas.Index objects, which provides coordinates upon\n-            which to index the variables in this dataset. The indexes on this\n-            other object need not be the same as the indexes on this\n-            dataset. Any mis-matched index values will be filled in with\n-            NaN, and any mis-matched dimension names will simply be ignored.\n-        method : {None, 'nearest', 'pad'/'ffill', 'backfill'/'bfill'}, optional\n-            Method to use for filling index values from other not found in this\n-            dataset:\n-\n-            * None (default): don't fill gaps\n-            * pad / ffill: propagate last valid index value forward\n-            * backfill / bfill: propagate next valid index value backward\n-            * nearest: use nearest valid index value\n-        tolerance : optional\n-            Maximum distance between original and new labels for inexact\n-            matches. The values of the index at the matching locations must\n-            satisfy the equation ``abs(index[indexer] - target) <= tolerance``.\n-        copy : bool, optional\n-            If ``copy=True``, data in the return value is always copied. If\n-            ``copy=False`` and reindexing is unnecessary, or can be performed\n-            with only slice operations, then the output may share memory with\n-            the input. In either case, a new xarray object is always returned.\n-        fill_value : scalar, optional\n-            Value to use for newly missing values\n-\n-        Returns\n-        -------\n-        reindexed : Dataset\n-            Another dataset, with this dataset's data but coordinates from the\n-            other object.\n-\n-        See Also\n-        --------\n-        Dataset.reindex\n-        align\n-        \"\"\"\n-        indexers = alignment.reindex_like_indexers(self, other)\n-        return self.reindex(\n-            indexers=indexers,\n-            method=method,\n-            copy=copy,\n-            fill_value=fill_value,\n-            tolerance=tolerance,\n-        )\n-\n-    def reindex(\n-        self,\n-        indexers: Mapping[Hashable, Any] = None,\n-        method: str = None,\n-        tolerance: Number = None,\n-        copy: bool = True,\n-        fill_value: Any = dtypes.NA,\n-        **indexers_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Conform this object onto a new set of indexes, filling in\n-        missing values with ``fill_value``. The default fill value is NaN.\n-\n-        Parameters\n-        ----------\n-        indexers : dict. optional\n-            Dictionary with keys given by dimension names and values given by\n-            arrays of coordinates tick labels. Any mis-matched coordinate\n-            values will be filled in with NaN, and any mis-matched dimension\n-            names will simply be ignored.\n-            One of indexers or indexers_kwargs must be provided.\n-        method : {None, 'nearest', 'pad'/'ffill', 'backfill'/'bfill'}, optional\n-            Method to use for filling index values in ``indexers`` not found in\n-            this dataset:\n-\n-            * None (default): don't fill gaps\n-            * pad / ffill: propagate last valid index value forward\n-            * backfill / bfill: propagate next valid index value backward\n-            * nearest: use nearest valid index value\n-        tolerance : optional\n-            Maximum distance between original and new labels for inexact\n-            matches. The values of the index at the matching locations must\n-            satisfy the equation ``abs(index[indexer] - target) <= tolerance``.\n-        copy : bool, optional\n-            If ``copy=True``, data in the return value is always copied. If\n-            ``copy=False`` and reindexing is unnecessary, or can be performed\n-            with only slice operations, then the output may share memory with\n-            the input. In either case, a new xarray object is always returned.\n-        fill_value : scalar, optional\n-            Value to use for newly missing values\n-        sparse: use sparse-array. By default, False\n-        **indexers_kwargs : {dim: indexer, ...}, optional\n-            Keyword arguments in the same form as ``indexers``.\n-            One of indexers or indexers_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        reindexed : Dataset\n-            Another dataset, with this dataset's data but replaced coordinates.\n-\n-        See Also\n-        --------\n-        Dataset.reindex_like\n-        align\n-        pandas.Index.get_indexer\n-\n-        Examples\n-        --------\n-\n-        Create a dataset with some fictional data.\n-\n-        >>> import xarray as xr\n-        >>> import pandas as pd\n-        >>> x = xr.Dataset(\n-        ...     {\n-        ...         \"temperature\": (\"station\", 20 * np.random.rand(4)),\n-        ...         \"pressure\": (\"station\", 500 * np.random.rand(4))\n-        ...     },\n-        ...     coords={\"station\": [\"boston\", \"nyc\", \"seattle\", \"denver\"]})\n-        >>> x\n-        <xarray.Dataset>\n-        Dimensions:      (station: 4)\n-        Coordinates:\n-        * station      (station) <U7 'boston' 'nyc' 'seattle' 'denver'\n-        Data variables:\n-            temperature  (station) float64 18.84 14.59 19.22 17.16\n-            pressure     (station) float64 324.1 194.3 122.8 244.3\n-        >>> x.indexes\n-        station: Index(['boston', 'nyc', 'seattle', 'denver'], dtype='object', name='station')\n-\n-        Create a new index and reindex the dataset. By default values in the new index that\n-        do not have corresponding records in the dataset are assigned `NaN`.\n-\n-        >>> new_index = ['boston', 'austin', 'seattle', 'lincoln']\n-        >>> x.reindex({'station': new_index})\n-        <xarray.Dataset>\n-        Dimensions:      (station: 4)\n-        Coordinates:\n-        * station      (station) object 'boston' 'austin' 'seattle' 'lincoln'\n-        Data variables:\n-            temperature  (station) float64 18.84 nan 19.22 nan\n-            pressure     (station) float64 324.1 nan 122.8 nan\n-\n-        We can fill in the missing values by passing a value to the keyword `fill_value`.\n-\n-        >>> x.reindex({'station': new_index}, fill_value=0)\n-        <xarray.Dataset>\n-        Dimensions:      (station: 4)\n-        Coordinates:\n-        * station      (station) object 'boston' 'austin' 'seattle' 'lincoln'\n-        Data variables:\n-            temperature  (station) float64 18.84 0.0 19.22 0.0\n-            pressure     (station) float64 324.1 0.0 122.8 0.0\n-\n-        Because the index is not monotonically increasing or decreasing, we cannot use arguments\n-        to the keyword method to fill the `NaN` values.\n-\n-        >>> x.reindex({'station': new_index}, method='nearest')\n-        Traceback (most recent call last):\n-        ...\n-            raise ValueError('index must be monotonic increasing or decreasing')\n-        ValueError: index must be monotonic increasing or decreasing\n-\n-        To further illustrate the filling functionality in reindex, we will create a\n-        dataset with a monotonically increasing index (for example, a sequence of dates).\n-\n-        >>> x2 = xr.Dataset(\n-        ...     {\n-        ...         \"temperature\": (\"time\", [15.57, 12.77, np.nan, 0.3081, 16.59, 15.12]),\n-        ...         \"pressure\": (\"time\", 500 * np.random.rand(6))\n-        ...     },\n-        ...     coords={\"time\": pd.date_range('01/01/2019', periods=6, freq='D')})\n-        >>> x2\n-        <xarray.Dataset>\n-        Dimensions:      (time: 6)\n-        Coordinates:\n-        * time         (time) datetime64[ns] 2019-01-01 2019-01-02 ... 2019-01-06\n-        Data variables:\n-            temperature  (time) float64 15.57 12.77 nan 0.3081 16.59 15.12\n-            pressure     (time) float64 103.4 122.7 452.0 444.0 399.2 486.0\n-\n-        Suppose we decide to expand the dataset to cover a wider date range.\n-\n-        >>> time_index2 = pd.date_range('12/29/2018', periods=10, freq='D')\n-        >>> x2.reindex({'time': time_index2})\n-        <xarray.Dataset>\n-        Dimensions:      (time: 10)\n-        Coordinates:\n-        * time         (time) datetime64[ns] 2018-12-29 2018-12-30 ... 2019-01-07\n-        Data variables:\n-            temperature  (time) float64 nan nan nan 15.57 ... 0.3081 16.59 15.12 nan\n-            pressure     (time) float64 nan nan nan 103.4 ... 444.0 399.2 486.0 nan\n-\n-        The index entries that did not have a value in the original data frame (for example, `2018-12-29`)\n-        are by default filled with NaN. If desired, we can fill in the missing values using one of several options.\n-\n-        For example, to back-propagate the last valid value to fill the `NaN` values,\n-        pass `bfill` as an argument to the `method` keyword.\n-\n-        >>> x3 = x2.reindex({'time': time_index2}, method='bfill')\n-        >>> x3\n-        <xarray.Dataset>\n-        Dimensions:      (time: 10)\n-        Coordinates:\n-        * time         (time) datetime64[ns] 2018-12-29 2018-12-30 ... 2019-01-07\n-        Data variables:\n-            temperature  (time) float64 15.57 15.57 15.57 15.57 ... 16.59 15.12 nan\n-            pressure     (time) float64 103.4 103.4 103.4 103.4 ... 399.2 486.0 nan\n-\n-        Please note that the `NaN` value present in the original dataset (at index value `2019-01-03`)\n-        will not be filled by any of the value propagation schemes.\n-\n-        >>> x2.where(x2.temperature.isnull(), drop=True)\n-        <xarray.Dataset>\n-        Dimensions:      (time: 1)\n-        Coordinates:\n-        * time         (time) datetime64[ns] 2019-01-03\n-        Data variables:\n-            temperature  (time) float64 nan\n-            pressure     (time) float64 452.0\n-        >>> x3.where(x3.temperature.isnull(), drop=True)\n-        <xarray.Dataset>\n-        Dimensions:      (time: 2)\n-        Coordinates:\n-        * time         (time) datetime64[ns] 2019-01-03 2019-01-07\n-        Data variables:\n-            temperature  (time) float64 nan nan\n-            pressure     (time) float64 452.0 nan\n-\n-        This is because filling while reindexing does not look at dataset values, but only compares\n-        the original and desired indexes. If you do want to fill in the `NaN` values present in the\n-        original dataset, use the :py:meth:`~Dataset.fillna()` method.\n-\n-        \"\"\"\n-        return self._reindex(\n-            indexers,\n-            method,\n-            tolerance,\n-            copy,\n-            fill_value,\n-            sparse=False,\n-            **indexers_kwargs,\n-        )\n-\n-    def _reindex(\n-        self,\n-        indexers: Mapping[Hashable, Any] = None,\n-        method: str = None,\n-        tolerance: Number = None,\n-        copy: bool = True,\n-        fill_value: Any = dtypes.NA,\n-        sparse: bool = False,\n-        **indexers_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"\n-        same to _reindex but support sparse option\n-        \"\"\"\n-        indexers = utils.either_dict_or_kwargs(indexers, indexers_kwargs, \"reindex\")\n-\n-        bad_dims = [d for d in indexers if d not in self.dims]\n-        if bad_dims:\n-            raise ValueError(\"invalid reindex dimensions: %s\" % bad_dims)\n-\n-        variables, indexes = alignment.reindex_variables(\n-            self.variables,\n-            self.sizes,\n-            self.indexes,\n-            indexers,\n-            method,\n-            tolerance,\n-            copy=copy,\n-            fill_value=fill_value,\n-            sparse=sparse,\n-        )\n-        coord_names = set(self._coord_names)\n-        coord_names.update(indexers)\n-        return self._replace_with_new_dims(variables, coord_names, indexes=indexes)\n-\n-    def interp(\n-        self,\n-        coords: Mapping[Hashable, Any] = None,\n-        method: str = \"linear\",\n-        assume_sorted: bool = False,\n-        kwargs: Mapping[str, Any] = None,\n-        **coords_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\" Multidimensional interpolation of Dataset.\n-\n-        Parameters\n-        ----------\n-        coords : dict, optional\n-            Mapping from dimension names to the new coordinates.\n-            New coordinate can be a scalar, array-like or DataArray.\n-            If DataArrays are passed as new coordates, their dimensions are\n-            used for the broadcasting.\n-        method: string, optional.\n-            {'linear', 'nearest'} for multidimensional array,\n-            {'linear', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic'}\n-            for 1-dimensional array. 'linear' is used by default.\n-        assume_sorted: boolean, optional\n-            If False, values of coordinates that are interpolated over can be\n-            in any order and they are sorted first. If True, interpolated\n-            coordinates are assumed to be an array of monotonically increasing\n-            values.\n-        kwargs: dictionary, optional\n-            Additional keyword passed to scipy's interpolator.\n-        **coords_kwargs : {dim: coordinate, ...}, optional\n-            The keyword arguments form of ``coords``.\n-            One of coords or coords_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        interpolated: xr.Dataset\n-            New dataset on the new coordinates.\n-\n-        Notes\n-        -----\n-        scipy is required.\n-\n-        See Also\n-        --------\n-        scipy.interpolate.interp1d\n-        scipy.interpolate.interpn\n-        \"\"\"\n-        from . import missing\n-\n-        if kwargs is None:\n-            kwargs = {}\n-\n-        coords = either_dict_or_kwargs(coords, coords_kwargs, \"interp\")\n-        indexers = dict(self._validate_interp_indexers(coords))\n-\n-        obj = self if assume_sorted else self.sortby([k for k in coords])\n-\n-        def maybe_variable(obj, k):\n-            # workaround to get variable for dimension without coordinate.\n-            try:\n-                return obj._variables[k]\n-            except KeyError:\n-                return as_variable((k, range(obj.dims[k])))\n-\n-        def _validate_interp_indexer(x, new_x):\n-            # In the case of datetimes, the restrictions placed on indexers\n-            # used with interp are stronger than those which are placed on\n-            # isel, so we need an additional check after _validate_indexers.\n-            if _contains_datetime_like_objects(\n-                x\n-            ) and not _contains_datetime_like_objects(new_x):\n-                raise TypeError(\n-                    \"When interpolating over a datetime-like \"\n-                    \"coordinate, the coordinates to \"\n-                    \"interpolate to must be either datetime \"\n-                    \"strings or datetimes. \"\n-                    \"Instead got\\n{}\".format(new_x)\n-                )\n-            return x, new_x\n-\n-        variables: Dict[Hashable, Variable] = {}\n-        for name, var in obj._variables.items():\n-            if name in indexers:\n-                continue\n-\n-            if var.dtype.kind in \"uifc\":\n-                var_indexers = {\n-                    k: _validate_interp_indexer(maybe_variable(obj, k), v)\n-                    for k, v in indexers.items()\n-                    if k in var.dims\n-                }\n-                variables[name] = missing.interp(var, var_indexers, method, **kwargs)\n-            elif all(d not in indexers for d in var.dims):\n-                # keep unrelated object array\n-                variables[name] = var\n-\n-        coord_names = obj._coord_names & variables.keys()\n-        indexes = {k: v for k, v in obj.indexes.items() if k not in indexers}\n-        selected = self._replace_with_new_dims(\n-            variables.copy(), coord_names, indexes=indexes\n-        )\n-\n-        # attach indexer as coordinate\n-        variables.update(indexers)\n-        for k, v in indexers.items():\n-            assert isinstance(v, Variable)\n-            if v.dims == (k,):\n-                indexes[k] = v.to_index()\n-\n-        # Extract coordinates from indexers\n-        coord_vars, new_indexes = selected._get_indexers_coords_and_indexes(coords)\n-        variables.update(coord_vars)\n-        indexes.update(new_indexes)\n-\n-        coord_names = obj._coord_names & variables.keys() | coord_vars.keys()\n-        return self._replace_with_new_dims(variables, coord_names, indexes=indexes)\n-\n-    def interp_like(\n-        self,\n-        other: Union[\"Dataset\", \"DataArray\"],\n-        method: str = \"linear\",\n-        assume_sorted: bool = False,\n-        kwargs: Mapping[str, Any] = None,\n-    ) -> \"Dataset\":\n-        \"\"\"Interpolate this object onto the coordinates of another object,\n-        filling the out of range values with NaN.\n-\n-        Parameters\n-        ----------\n-        other : Dataset or DataArray\n-            Object with an 'indexes' attribute giving a mapping from dimension\n-            names to an 1d array-like, which provides coordinates upon\n-            which to index the variables in this dataset.\n-        method: string, optional.\n-            {'linear', 'nearest'} for multidimensional array,\n-            {'linear', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic'}\n-            for 1-dimensional array. 'linear' is used by default.\n-        assume_sorted: boolean, optional\n-            If False, values of coordinates that are interpolated over can be\n-            in any order and they are sorted first. If True, interpolated\n-            coordinates are assumed to be an array of monotonically increasing\n-            values.\n-        kwargs: dictionary, optional\n-            Additional keyword passed to scipy's interpolator.\n-\n-        Returns\n-        -------\n-        interpolated: xr.Dataset\n-            Another dataset by interpolating this dataset's data along the\n-            coordinates of the other object.\n-\n-        Notes\n-        -----\n-        scipy is required.\n-        If the dataset has object-type coordinates, reindex is used for these\n-        coordinates instead of the interpolation.\n-\n-        See Also\n-        --------\n-        Dataset.interp\n-        Dataset.reindex_like\n-        \"\"\"\n-        if kwargs is None:\n-            kwargs = {}\n-        coords = alignment.reindex_like_indexers(self, other)\n-\n-        numeric_coords: Dict[Hashable, pd.Index] = {}\n-        object_coords: Dict[Hashable, pd.Index] = {}\n-        for k, v in coords.items():\n-            if v.dtype.kind in \"uifcMm\":\n-                numeric_coords[k] = v\n-            else:\n-                object_coords[k] = v\n-\n-        ds = self\n-        if object_coords:\n-            # We do not support interpolation along object coordinate.\n-            # reindex instead.\n-            ds = self.reindex(object_coords)\n-        return ds.interp(numeric_coords, method, assume_sorted, kwargs)\n-\n-    # Helper methods for rename()\n-    def _rename_vars(self, name_dict, dims_dict):\n-        variables = {}\n-        coord_names = set()\n-        for k, v in self.variables.items():\n-            var = v.copy(deep=False)\n-            var.dims = tuple(dims_dict.get(dim, dim) for dim in v.dims)\n-            name = name_dict.get(k, k)\n-            if name in variables:\n-                raise ValueError(f\"the new name {name!r} conflicts\")\n-            variables[name] = var\n-            if k in self._coord_names:\n-                coord_names.add(name)\n-        return variables, coord_names\n-\n-    def _rename_dims(self, name_dict):\n-        return {name_dict.get(k, k): v for k, v in self.dims.items()}\n-\n-    def _rename_indexes(self, name_dict, dims_set):\n-        if self._indexes is None:\n-            return None\n-        indexes = {}\n-        for k, v in self.indexes.items():\n-            new_name = name_dict.get(k, k)\n-            if new_name not in dims_set:\n-                continue\n-            if isinstance(v, pd.MultiIndex):\n-                new_names = [name_dict.get(k, k) for k in v.names]\n-                index = v.rename(names=new_names)\n-            else:\n-                index = v.rename(new_name)\n-            indexes[new_name] = index\n-        return indexes\n-\n-    def _rename_all(self, name_dict, dims_dict):\n-        variables, coord_names = self._rename_vars(name_dict, dims_dict)\n-        dims = self._rename_dims(dims_dict)\n-        indexes = self._rename_indexes(name_dict, dims.keys())\n-        return variables, coord_names, dims, indexes\n-\n-    def rename(\n-        self,\n-        name_dict: Mapping[Hashable, Hashable] = None,\n-        inplace: bool = None,\n-        **names: Hashable,\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new object with renamed variables and dimensions.\n-\n-        Parameters\n-        ----------\n-        name_dict : dict-like, optional\n-            Dictionary whose keys are current variable or dimension names and\n-            whose values are the desired names.\n-        **names, optional\n-            Keyword form of ``name_dict``.\n-            One of name_dict or names must be provided.\n-\n-        Returns\n-        -------\n-        renamed : Dataset\n-            Dataset with renamed variables and dimensions.\n-\n-        See Also\n-        --------\n-        Dataset.swap_dims\n-        Dataset.rename_vars\n-        Dataset.rename_dims\n-        DataArray.rename\n-        \"\"\"\n-        _check_inplace(inplace)\n-        name_dict = either_dict_or_kwargs(name_dict, names, \"rename\")\n-        for k in name_dict.keys():\n-            if k not in self and k not in self.dims:\n-                raise ValueError(\n-                    \"cannot rename %r because it is not a \"\n-                    \"variable or dimension in this dataset\" % k\n-                )\n-\n-        variables, coord_names, dims, indexes = self._rename_all(\n-            name_dict=name_dict, dims_dict=name_dict\n-        )\n-        assert_unique_multiindex_level_names(variables)\n-        return self._replace(variables, coord_names, dims=dims, indexes=indexes)\n-\n-    def rename_dims(\n-        self, dims_dict: Mapping[Hashable, Hashable] = None, **dims: Hashable\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new object with renamed dimensions only.\n-\n-        Parameters\n-        ----------\n-        dims_dict : dict-like, optional\n-            Dictionary whose keys are current dimension names and\n-            whose values are the desired names. The desired names must\n-            not be the name of an existing dimension or Variable in the Dataset.\n-        **dims, optional\n-            Keyword form of ``dims_dict``.\n-            One of dims_dict or dims must be provided.\n-\n-        Returns\n-        -------\n-        renamed : Dataset\n-            Dataset with renamed dimensions.\n-\n-        See Also\n-        --------\n-        Dataset.swap_dims\n-        Dataset.rename\n-        Dataset.rename_vars\n-        DataArray.rename\n-        \"\"\"\n-        dims_dict = either_dict_or_kwargs(dims_dict, dims, \"rename_dims\")\n-        for k, v in dims_dict.items():\n-            if k not in self.dims:\n-                raise ValueError(\n-                    \"cannot rename %r because it is not a \"\n-                    \"dimension in this dataset\" % k\n-                )\n-            if v in self.dims or v in self:\n-                raise ValueError(\n-                    f\"Cannot rename {k} to {v} because {v} already exists. \"\n-                    \"Try using swap_dims instead.\"\n-                )\n-\n-        variables, coord_names, sizes, indexes = self._rename_all(\n-            name_dict={}, dims_dict=dims_dict\n-        )\n-        return self._replace(variables, coord_names, dims=sizes, indexes=indexes)\n-\n-    def rename_vars(\n-        self, name_dict: Mapping[Hashable, Hashable] = None, **names: Hashable\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new object with renamed variables including coordinates\n-\n-        Parameters\n-        ----------\n-        name_dict : dict-like, optional\n-            Dictionary whose keys are current variable or coordinate names and\n-            whose values are the desired names.\n-        **names, optional\n-            Keyword form of ``name_dict``.\n-            One of name_dict or names must be provided.\n-\n-        Returns\n-        -------\n-        renamed : Dataset\n-            Dataset with renamed variables including coordinates\n-\n-        See Also\n-        --------\n-        Dataset.swap_dims\n-        Dataset.rename\n-        Dataset.rename_dims\n-        DataArray.rename\n-        \"\"\"\n-        name_dict = either_dict_or_kwargs(name_dict, names, \"rename_vars\")\n-        for k in name_dict:\n-            if k not in self:\n-                raise ValueError(\n-                    \"cannot rename %r because it is not a \"\n-                    \"variable or coordinate in this dataset\" % k\n-                )\n-        variables, coord_names, dims, indexes = self._rename_all(\n-            name_dict=name_dict, dims_dict={}\n-        )\n-        return self._replace(variables, coord_names, dims=dims, indexes=indexes)\n-\n-    def swap_dims(\n-        self, dims_dict: Mapping[Hashable, Hashable], inplace: bool = None\n-    ) -> \"Dataset\":\n-        \"\"\"Returns a new object with swapped dimensions.\n-\n-        Parameters\n-        ----------\n-        dims_dict : dict-like\n-            Dictionary whose keys are current dimension names and whose values\n-            are new names.\n-\n-        Returns\n-        -------\n-        swapped : Dataset\n-            Dataset with swapped dimensions.\n-\n-        Examples\n-        --------\n-        >>> ds = xr.Dataset(data_vars={\"a\": (\"x\", [5, 7]), \"b\": (\"x\", [0.1, 2.4])},\n-                            coords={\"x\": [\"a\", \"b\"], \"y\": (\"x\", [0, 1])})\n-        >>> ds\n-        <xarray.Dataset>\n-        Dimensions:  (x: 2)\n-        Coordinates:\n-          * x        (x) <U1 'a' 'b'\n-            y        (x) int64 0 1\n-        Data variables:\n-            a        (x) int64 5 7\n-            b        (x) float64 0.1 2.4\n-        >>> ds.swap_dims({\"x\": \"y\"})\n-        <xarray.Dataset>\n-        Dimensions:  (y: 2)\n-        Coordinates:\n-            x        (y) <U1 'a' 'b'\n-          * y        (y) int64 0 1\n-        Data variables:\n-            a        (y) int64 5 7\n-            b        (y) float64 0.1 2.4\n-        >>> ds.swap_dims({\"x\": \"z\"})\n-        <xarray.Dataset>\n-        Dimensions:  (z: 2)\n-        Coordinates:\n-            x        (z) <U1 'a' 'b'\n-            y        (z) int64 0 1\n-        Dimensions without coordinates: z\n-        Data variables:\n-            a        (z) int64 5 7\n-            b        (z) float64 0.1 2.4\n-\n-        See Also\n-        --------\n-\n-        Dataset.rename\n-        DataArray.swap_dims\n-        \"\"\"\n-        # TODO: deprecate this method in favor of a (less confusing)\n-        # rename_dims() method that only renames dimensions.\n-        _check_inplace(inplace)\n-        for k, v in dims_dict.items():\n-            if k not in self.dims:\n-                raise ValueError(\n-                    \"cannot swap from dimension %r because it is \"\n-                    \"not an existing dimension\" % k\n-                )\n-            if v in self.variables and self.variables[v].dims != (k,):\n-                raise ValueError(\n-                    \"replacement dimension %r is not a 1D \"\n-                    \"variable along the old dimension %r\" % (v, k)\n-                )\n-\n-        result_dims = {dims_dict.get(dim, dim) for dim in self.dims}\n-\n-        coord_names = self._coord_names.copy()\n-        coord_names.update({dim for dim in dims_dict.values() if dim in self.variables})\n-\n-        variables: Dict[Hashable, Variable] = {}\n-        indexes: Dict[Hashable, pd.Index] = {}\n-        for k, v in self.variables.items():\n-            dims = tuple(dims_dict.get(dim, dim) for dim in v.dims)\n-            if k in result_dims:\n-                var = v.to_index_variable()\n-                if k in self.indexes:\n-                    indexes[k] = self.indexes[k]\n-                else:\n-                    indexes[k] = var.to_index()\n-            else:\n-                var = v.to_base_variable()\n-            var.dims = dims\n-            variables[k] = var\n-\n-        return self._replace_with_new_dims(variables, coord_names, indexes=indexes)\n-\n-    def expand_dims(\n-        self,\n-        dim: Union[None, Hashable, Sequence[Hashable], Mapping[Hashable, Any]] = None,\n-        axis: Union[None, int, Sequence[int]] = None,\n-        **dim_kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Return a new object with an additional axis (or axes) inserted at\n-        the corresponding position in the array shape.  The new object is a\n-        view into the underlying array, not a copy.\n-\n-        If dim is already a scalar coordinate, it will be promoted to a 1D\n-        coordinate consisting of a single value.\n-\n-        Parameters\n-        ----------\n-        dim : hashable, sequence of hashable, mapping, or None\n-            Dimensions to include on the new variable. If provided as hashable\n-            or sequence of hashable, then dimensions are inserted with length\n-            1. If provided as a mapping, then the keys are the new dimensions\n-            and the values are either integers (giving the length of the new\n-            dimensions) or array-like (giving the coordinates of the new\n-            dimensions).\n-        axis : integer, sequence of integers, or None\n-            Axis position(s) where new axis is to be inserted (position(s) on\n-            the result array). If a list (or tuple) of integers is passed,\n-            multiple axes are inserted. In this case, dim arguments should be\n-            same length list. If axis=None is passed, all the axes will be\n-            inserted to the start of the result array.\n-        **dim_kwargs : int or sequence/ndarray\n-            The keywords are arbitrary dimensions being inserted and the values\n-            are either the lengths of the new dims (if int is given), or their\n-            coordinates. Note, this is an alternative to passing a dict to the\n-            dim kwarg and will only be used if dim is None.\n-\n-        Returns\n-        -------\n-        expanded : same type as caller\n-            This object, but with an additional dimension(s).\n-        \"\"\"\n-        if dim is None:\n-            pass\n-        elif isinstance(dim, Mapping):\n-            # We're later going to modify dim in place; don't tamper with\n-            # the input\n-            dim = dict(dim)\n-        elif isinstance(dim, int):\n-            raise TypeError(\n-                \"dim should be hashable or sequence of hashables or mapping\"\n-            )\n-        elif isinstance(dim, str) or not isinstance(dim, Sequence):\n-            dim = {dim: 1}\n-        elif isinstance(dim, Sequence):\n-            if len(dim) != len(set(dim)):\n-                raise ValueError(\"dims should not contain duplicate values.\")\n-            dim = {d: 1 for d in dim}\n-\n-        dim = either_dict_or_kwargs(dim, dim_kwargs, \"expand_dims\")\n-        assert isinstance(dim, MutableMapping)\n-\n-        if axis is None:\n-            axis = list(range(len(dim)))\n-        elif not isinstance(axis, Sequence):\n-            axis = [axis]\n-\n-        if len(dim) != len(axis):\n-            raise ValueError(\"lengths of dim and axis should be identical.\")\n-        for d in dim:\n-            if d in self.dims:\n-                raise ValueError(f\"Dimension {d} already exists.\")\n-            if d in self._variables and not utils.is_scalar(self._variables[d]):\n-                raise ValueError(\n-                    \"{dim} already exists as coordinate or\"\n-                    \" variable name.\".format(dim=d)\n-                )\n-\n-        variables: Dict[Hashable, Variable] = {}\n-        coord_names = self._coord_names.copy()\n-        # If dim is a dict, then ensure that the values are either integers\n-        # or iterables.\n-        for k, v in dim.items():\n-            if hasattr(v, \"__iter__\"):\n-                # If the value for the new dimension is an iterable, then\n-                # save the coordinates to the variables dict, and set the\n-                # value within the dim dict to the length of the iterable\n-                # for later use.\n-                variables[k] = xr.IndexVariable((k,), v)\n-                coord_names.add(k)\n-                dim[k] = variables[k].size\n-            elif isinstance(v, int):\n-                pass  # Do nothing if the dimensions value is just an int\n-            else:\n-                raise TypeError(\n-                    \"The value of new dimension {k} must be \"\n-                    \"an iterable or an int\".format(k=k)\n-                )\n-\n-        for k, v in self._variables.items():\n-            if k not in dim:\n-                if k in coord_names:  # Do not change coordinates\n-                    variables[k] = v\n-                else:\n-                    result_ndim = len(v.dims) + len(axis)\n-                    for a in axis:\n-                        if a < -result_ndim or result_ndim - 1 < a:\n-                            raise IndexError(\n-                                f\"Axis {a} of variable {k} is out of bounds of the \"\n-                                f\"expanded dimension size {result_ndim}\"\n-                            )\n-\n-                    axis_pos = [a if a >= 0 else result_ndim + a for a in axis]\n-                    if len(axis_pos) != len(set(axis_pos)):\n-                        raise ValueError(\"axis should not contain duplicate values\")\n-                    # We need to sort them to make sure `axis` equals to the\n-                    # axis positions of the result array.\n-                    zip_axis_dim = sorted(zip(axis_pos, dim.items()))\n-\n-                    all_dims = list(zip(v.dims, v.shape))\n-                    for d, c in zip_axis_dim:\n-                        all_dims.insert(d, c)\n-                    variables[k] = v.set_dims(dict(all_dims))\n-            else:\n-                # If dims includes a label of a non-dimension coordinate,\n-                # it will be promoted to a 1D coordinate with a single value.\n-                variables[k] = v.set_dims(k).to_index_variable()\n-\n-        new_dims = self._dims.copy()\n-        new_dims.update(dim)\n-\n-        return self._replace_vars_and_dims(\n-            variables, dims=new_dims, coord_names=coord_names\n-        )\n-\n-    def set_index(\n-        self,\n-        indexes: Mapping[Hashable, Union[Hashable, Sequence[Hashable]]] = None,\n-        append: bool = False,\n-        inplace: bool = None,\n-        **indexes_kwargs: Union[Hashable, Sequence[Hashable]],\n-    ) -> \"Dataset\":\n-        \"\"\"Set Dataset (multi-)indexes using one or more existing coordinates\n-        or variables.\n-\n-        Parameters\n-        ----------\n-        indexes : {dim: index, ...}\n-            Mapping from names matching dimensions and values given\n-            by (lists of) the names of existing coordinates or variables to set\n-            as new (multi-)index.\n-        append : bool, optional\n-            If True, append the supplied index(es) to the existing index(es).\n-            Otherwise replace the existing index(es) (default).\n-        **indexes_kwargs: optional\n-            The keyword arguments form of ``indexes``.\n-            One of indexes or indexes_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        obj : Dataset\n-            Another dataset, with this dataset's data but replaced coordinates.\n-\n-        Examples\n-        --------\n-        >>> arr = xr.DataArray(data=np.ones((2, 3)),\n-        ...                    dims=['x', 'y'],\n-        ...                    coords={'x':\n-        ...                        range(2), 'y':\n-        ...                        range(3), 'a': ('x', [3, 4])\n-        ...                    })\n-        >>> ds = xr.Dataset({'v': arr})\n-        >>> ds\n-        <xarray.Dataset>\n-        Dimensions:  (x: 2, y: 3)\n-        Coordinates:\n-          * x        (x) int64 0 1\n-          * y        (y) int64 0 1 2\n-            a        (x) int64 3 4\n-        Data variables:\n-            v        (x, y) float64 1.0 1.0 1.0 1.0 1.0 1.0\n-        >>> ds.set_index(x='a')\n-        <xarray.Dataset>\n-        Dimensions:  (x: 2, y: 3)\n-        Coordinates:\n-          * x        (x) int64 3 4\n-          * y        (y) int64 0 1 2\n-        Data variables:\n-            v        (x, y) float64 1.0 1.0 1.0 1.0 1.0 1.0\n-\n-        See Also\n-        --------\n-        Dataset.reset_index\n-        Dataset.swap_dims\n-        \"\"\"\n-        _check_inplace(inplace)\n-        indexes = either_dict_or_kwargs(indexes, indexes_kwargs, \"set_index\")\n-        variables, coord_names = merge_indexes(\n-            indexes, self._variables, self._coord_names, append=append\n-        )\n-        return self._replace_vars_and_dims(variables, coord_names=coord_names)\n-\n-    def reset_index(\n-        self,\n-        dims_or_levels: Union[Hashable, Sequence[Hashable]],\n-        drop: bool = False,\n-        inplace: bool = None,\n-    ) -> \"Dataset\":\n-        \"\"\"Reset the specified index(es) or multi-index level(s).\n-\n-        Parameters\n-        ----------\n-        dims_or_levels : str or list\n-            Name(s) of the dimension(s) and/or multi-index level(s) that will\n-            be reset.\n-        drop : bool, optional\n-            If True, remove the specified indexes and/or multi-index levels\n-            instead of extracting them as new coordinates (default: False).\n-\n-        Returns\n-        -------\n-        obj : Dataset\n-            Another dataset, with this dataset's data but replaced coordinates.\n-\n-        See Also\n-        --------\n-        Dataset.set_index\n-        \"\"\"\n-        _check_inplace(inplace)\n-        variables, coord_names = split_indexes(\n-            dims_or_levels,\n-            self._variables,\n-            self._coord_names,\n-            cast(Mapping[Hashable, Hashable], self._level_coords),\n-            drop=drop,\n-        )\n-        return self._replace_vars_and_dims(variables, coord_names=coord_names)\n-\n-    def reorder_levels(\n-        self,\n-        dim_order: Mapping[Hashable, Sequence[int]] = None,\n-        inplace: bool = None,\n-        **dim_order_kwargs: Sequence[int],\n-    ) -> \"Dataset\":\n-        \"\"\"Rearrange index levels using input order.\n-\n-        Parameters\n-        ----------\n-        dim_order : optional\n-            Mapping from names matching dimensions and values given\n-            by lists representing new level orders. Every given dimension\n-            must have a multi-index.\n-        **dim_order_kwargs: optional\n-            The keyword arguments form of ``dim_order``.\n-            One of dim_order or dim_order_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        obj : Dataset\n-            Another dataset, with this dataset's data but replaced\n-            coordinates.\n-        \"\"\"\n-        _check_inplace(inplace)\n-        dim_order = either_dict_or_kwargs(dim_order, dim_order_kwargs, \"reorder_levels\")\n-        variables = self._variables.copy()\n-        indexes = dict(self.indexes)\n-        for dim, order in dim_order.items():\n-            coord = self._variables[dim]\n-            index = self.indexes[dim]\n-            if not isinstance(index, pd.MultiIndex):\n-                raise ValueError(f\"coordinate {dim} has no MultiIndex\")\n-            new_index = index.reorder_levels(order)\n-            variables[dim] = IndexVariable(coord.dims, new_index)\n-            indexes[dim] = new_index\n-\n-        return self._replace(variables, indexes=indexes)\n-\n-    def _stack_once(self, dims, new_dim):\n-        variables = {}\n-        for name, var in self.variables.items():\n-            if name not in dims:\n-                if any(d in var.dims for d in dims):\n-                    add_dims = [d for d in dims if d not in var.dims]\n-                    vdims = list(var.dims) + add_dims\n-                    shape = [self.dims[d] for d in vdims]\n-                    exp_var = var.set_dims(vdims, shape)\n-                    stacked_var = exp_var.stack(**{new_dim: dims})\n-                    variables[name] = stacked_var\n-                else:\n-                    variables[name] = var.copy(deep=False)\n-\n-        # consider dropping levels that are unused?\n-        levels = [self.get_index(dim) for dim in dims]\n-        idx = utils.multiindex_from_product_levels(levels, names=dims)\n-        variables[new_dim] = IndexVariable(new_dim, idx)\n-\n-        coord_names = set(self._coord_names) - set(dims) | {new_dim}\n-\n-        indexes = {k: v for k, v in self.indexes.items() if k not in dims}\n-        indexes[new_dim] = idx\n-\n-        return self._replace_with_new_dims(\n-            variables, coord_names=coord_names, indexes=indexes\n-        )\n-\n-    def stack(\n-        self,\n-        dimensions: Mapping[Hashable, Sequence[Hashable]] = None,\n-        **dimensions_kwargs: Sequence[Hashable],\n-    ) -> \"Dataset\":\n-        \"\"\"\n-        Stack any number of existing dimensions into a single new dimension.\n-\n-        New dimensions will be added at the end, and the corresponding\n-        coordinate variables will be combined into a MultiIndex.\n-\n-        Parameters\n-        ----------\n-        dimensions : Mapping of the form new_name=(dim1, dim2, ...)\n-            Names of new dimensions, and the existing dimensions that they\n-            replace.\n-        **dimensions_kwargs:\n-            The keyword arguments form of ``dimensions``.\n-            One of dimensions or dimensions_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        stacked : Dataset\n-            Dataset with stacked data.\n-\n-        See also\n-        --------\n-        Dataset.unstack\n-        \"\"\"\n-        dimensions = either_dict_or_kwargs(dimensions, dimensions_kwargs, \"stack\")\n-        result = self\n-        for new_dim, dims in dimensions.items():\n-            result = result._stack_once(dims, new_dim)\n-        return result\n-\n-    def to_stacked_array(\n-        self,\n-        new_dim: Hashable,\n-        sample_dims: Sequence[Hashable],\n-        variable_dim: str = \"variable\",\n-        name: Hashable = None,\n-    ) -> \"DataArray\":\n-        \"\"\"Combine variables of differing dimensionality into a DataArray\n-        without broadcasting.\n-\n-        This method is similar to Dataset.to_array but does not broadcast the\n-        variables.\n-\n-        Parameters\n-        ----------\n-        new_dim : Hashable\n-            Name of the new stacked coordinate\n-        sample_dims : Sequence[Hashable]\n-            Dimensions that **will not** be stacked. Each array in the dataset\n-            must share these dimensions. For machine learning applications,\n-            these define the dimensions over which samples are drawn.\n-        variable_dim : str, optional\n-            Name of the level in the stacked coordinate which corresponds to\n-            the variables.\n-        name : str, optional\n-            Name of the new data array.\n-\n-        Returns\n-        -------\n-        stacked : DataArray\n-            DataArray with the specified dimensions and data variables\n-            stacked together. The stacked coordinate is named ``new_dim``\n-            and represented by a MultiIndex object with a level containing the\n-            data variable names. The name of this level is controlled using\n-            the ``variable_dim`` argument.\n-\n-        See Also\n-        --------\n-        Dataset.to_array\n-        Dataset.stack\n-        DataArray.to_unstacked_dataset\n-\n-        Examples\n-        --------\n-        >>> data = Dataset(\n-        ...     data_vars={'a': (('x', 'y'), [[0, 1, 2], [3, 4, 5]]),\n-        ...                'b': ('x', [6, 7])},\n-        ...     coords={'y': ['u', 'v', 'w']}\n-        ... )\n-\n-        >>> data\n-        <xarray.Dataset>\n-        Dimensions:  (x: 2, y: 3)\n-        Coordinates:\n-        * y        (y) <U1 'u' 'v' 'w'\n-        Dimensions without coordinates: x\n-        Data variables:\n-            a        (x, y) int64 0 1 2 3 4 5\n-            b        (x) int64 6 7\n-\n-        >>> data.to_stacked_array(\"z\", sample_dims=['x'])\n-        <xarray.DataArray (x: 2, z: 4)>\n-        array([[0, 1, 2, 6],\n-            [3, 4, 5, 7]])\n-        Coordinates:\n-        * z         (z) MultiIndex\n-        - variable  (z) object 'a' 'a' 'a' 'b'\n-        - y         (z) object 'u' 'v' 'w' nan\n-        Dimensions without coordinates: x\n-\n-        \"\"\"\n-        stacking_dims = tuple(dim for dim in self.dims if dim not in sample_dims)\n-\n-        for variable in self:\n-            dims = self[variable].dims\n-            dims_include_sample_dims = set(sample_dims) <= set(dims)\n-            if not dims_include_sample_dims:\n-                raise ValueError(\n-                    \"All variables in the dataset must contain the \"\n-                    \"dimensions {}.\".format(dims)\n-                )\n-\n-        def ensure_stackable(val):\n-            assign_coords = {variable_dim: val.name}\n-            for dim in stacking_dims:\n-                if dim not in val.dims:\n-                    assign_coords[dim] = None\n-\n-            expand_dims = set(stacking_dims).difference(set(val.dims))\n-            expand_dims.add(variable_dim)\n-            # must be list for .expand_dims\n-            expand_dims = list(expand_dims)\n-\n-            return (\n-                val.assign_coords(**assign_coords)\n-                .expand_dims(expand_dims)\n-                .stack({new_dim: (variable_dim,) + stacking_dims})\n-            )\n-\n-        # concatenate the arrays\n-        stackable_vars = [ensure_stackable(self[key]) for key in self.data_vars]\n-        data_array = xr.concat(stackable_vars, dim=new_dim)\n-\n-        # coerce the levels of the MultiIndex to have the same type as the\n-        # input dimensions. This code is messy, so it might be better to just\n-        # input a dummy value for the singleton dimension.\n-        idx = data_array.indexes[new_dim]\n-        levels = [idx.levels[0]] + [\n-            level.astype(self[level.name].dtype) for level in idx.levels[1:]\n-        ]\n-        new_idx = idx.set_levels(levels)\n-        data_array[new_dim] = IndexVariable(new_dim, new_idx)\n-\n-        if name is not None:\n-            data_array.name = name\n-\n-        return data_array\n-\n-    def _unstack_once(self, dim: Hashable, fill_value, sparse) -> \"Dataset\":\n-        index = self.get_index(dim)\n-        index = index.remove_unused_levels()\n-        full_idx = pd.MultiIndex.from_product(index.levels, names=index.names)\n-\n-        # take a shortcut in case the MultiIndex was not modified.\n-        if index.equals(full_idx):\n-            obj = self\n-        else:\n-            obj = self._reindex(\n-                {dim: full_idx}, copy=False, fill_value=fill_value, sparse=sparse\n-            )\n-\n-        new_dim_names = index.names\n-        new_dim_sizes = [lev.size for lev in index.levels]\n-\n-        variables: Dict[Hashable, Variable] = {}\n-        indexes = {k: v for k, v in self.indexes.items() if k != dim}\n-\n-        for name, var in obj.variables.items():\n-            if name != dim:\n-                if dim in var.dims:\n-                    new_dims = dict(zip(new_dim_names, new_dim_sizes))\n-                    variables[name] = var.unstack({dim: new_dims})\n-                else:\n-                    variables[name] = var\n-\n-        for name, lev in zip(new_dim_names, index.levels):\n-            variables[name] = IndexVariable(name, lev)\n-            indexes[name] = lev\n-\n-        coord_names = set(self._coord_names) - {dim} | set(new_dim_names)\n-\n-        return self._replace_with_new_dims(\n-            variables, coord_names=coord_names, indexes=indexes\n-        )\n-\n-    def unstack(\n-        self,\n-        dim: Union[Hashable, Iterable[Hashable]] = None,\n-        fill_value: Any = dtypes.NA,\n-        sparse: bool = False,\n-    ) -> \"Dataset\":\n-        \"\"\"\n-        Unstack existing dimensions corresponding to MultiIndexes into\n-        multiple new dimensions.\n-\n-        New dimensions will be added at the end.\n-\n-        Parameters\n-        ----------\n-        dim : Hashable or iterable of Hashable, optional\n-            Dimension(s) over which to unstack. By default unstacks all\n-            MultiIndexes.\n-        fill_value: value to be filled. By default, np.nan\n-        sparse: use sparse-array if True\n-\n-        Returns\n-        -------\n-        unstacked : Dataset\n-            Dataset with unstacked data.\n-\n-        See also\n-        --------\n-        Dataset.stack\n-        \"\"\"\n-        if dim is None:\n-            dims = [\n-                d for d in self.dims if isinstance(self.get_index(d), pd.MultiIndex)\n-            ]\n-        else:\n-            if isinstance(dim, str) or not isinstance(dim, Iterable):\n-                dims = [dim]\n-            else:\n-                dims = list(dim)\n-\n-            missing_dims = [d for d in dims if d not in self.dims]\n-            if missing_dims:\n-                raise ValueError(\n-                    \"Dataset does not contain the dimensions: %s\" % missing_dims\n-                )\n-\n-            non_multi_dims = [\n-                d for d in dims if not isinstance(self.get_index(d), pd.MultiIndex)\n-            ]\n-            if non_multi_dims:\n-                raise ValueError(\n-                    \"cannot unstack dimensions that do not \"\n-                    \"have a MultiIndex: %s\" % non_multi_dims\n-                )\n-\n-        result = self.copy(deep=False)\n-        for dim in dims:\n-            result = result._unstack_once(dim, fill_value, sparse)\n-        return result\n-\n-    def update(self, other: \"CoercibleMapping\", inplace: bool = None) -> \"Dataset\":\n-        \"\"\"Update this dataset's variables with those from another dataset.\n-\n-        Parameters\n-        ----------\n-        other : Dataset or castable to Dataset\n-            Variables with which to update this dataset. One of:\n-\n-            - Dataset\n-            - mapping {var name: DataArray}\n-            - mapping {var name: Variable}\n-            - mapping {var name: (dimension name, array-like)}\n-            - mapping {var name: (tuple of dimension names, array-like)}\n-\n-\n-        Returns\n-        -------\n-        updated : Dataset\n-            Updated dataset.\n-\n-        Raises\n-        ------\n-        ValueError\n-            If any dimensions would have inconsistent sizes in the updated\n-            dataset.\n-        \"\"\"\n-        _check_inplace(inplace)\n-        merge_result = dataset_update_method(self, other)\n-        return self._replace(inplace=True, **merge_result._asdict())\n-\n-    def merge(\n-        self,\n-        other: \"CoercibleMapping\",\n-        inplace: bool = None,\n-        overwrite_vars: Union[Hashable, Iterable[Hashable]] = frozenset(),\n-        compat: str = \"no_conflicts\",\n-        join: str = \"outer\",\n-        fill_value: Any = dtypes.NA,\n-    ) -> \"Dataset\":\n-        \"\"\"Merge the arrays of two datasets into a single dataset.\n-\n-        This method generally does not allow for overriding data, with the\n-        exception of attributes, which are ignored on the second dataset.\n-        Variables with the same name are checked for conflicts via the equals\n-        or identical methods.\n-\n-        Parameters\n-        ----------\n-        other : Dataset or castable to Dataset\n-            Dataset or variables to merge with this dataset.\n-        overwrite_vars : Hashable or iterable of Hashable, optional\n-            If provided, update variables of these name(s) without checking for\n-            conflicts in this dataset.\n-        compat : {'broadcast_equals', 'equals', 'identical',\n-                  'no_conflicts'}, optional\n-            String indicating how to compare variables of the same name for\n-            potential conflicts:\n-\n-            - 'broadcast_equals': all values must be equal when variables are\n-              broadcast against each other to ensure common dimensions.\n-            - 'equals': all values and dimensions must be the same.\n-            - 'identical': all values, dimensions and attributes must be the\n-              same.\n-            - 'no_conflicts': only values which are not null in both datasets\n-              must be equal. The returned dataset then contains the combination\n-              of all non-null values.\n-\n-        join : {'outer', 'inner', 'left', 'right', 'exact'}, optional\n-            Method for joining ``self`` and ``other`` along shared dimensions:\n-\n-            - 'outer': use the union of the indexes\n-            - 'inner': use the intersection of the indexes\n-            - 'left': use indexes from ``self``\n-            - 'right': use indexes from ``other``\n-            - 'exact': error instead of aligning non-equal indexes\n-        fill_value: scalar, optional\n-            Value to use for newly missing values\n-\n-        Returns\n-        -------\n-        merged : Dataset\n-            Merged dataset.\n-\n-        Raises\n-        ------\n-        MergeError\n-            If any variables conflict (see ``compat``).\n-        \"\"\"\n-        _check_inplace(inplace)\n-        merge_result = dataset_merge_method(\n-            self,\n-            other,\n-            overwrite_vars=overwrite_vars,\n-            compat=compat,\n-            join=join,\n-            fill_value=fill_value,\n-        )\n-        return self._replace(**merge_result._asdict())\n-\n-    def _assert_all_in_dataset(\n-        self, names: Iterable[Hashable], virtual_okay: bool = False\n-    ) -> None:\n-        bad_names = set(names) - set(self._variables)\n-        if virtual_okay:\n-            bad_names -= self.virtual_variables\n-        if bad_names:\n-            raise ValueError(\n-                \"One or more of the specified variables \"\n-                \"cannot be found in this dataset\"\n-            )\n-\n-    def drop_vars(\n-        self, names: Union[Hashable, Iterable[Hashable]], *, errors: str = \"raise\"\n-    ) -> \"Dataset\":\n-        \"\"\"Drop variables from this dataset.\n-\n-        Parameters\n-        ----------\n-        names : hashable or iterable of hashables\n-            Name(s) of variables to drop.\n-        errors: {'raise', 'ignore'}, optional\n-            If 'raise' (default), raises a ValueError error if any of the variable\n-            passed are not in the dataset. If 'ignore', any given names that are in the\n-            dataset are dropped and no error is raised.\n-\n-        Returns\n-        -------\n-        dropped : Dataset\n-\n-        \"\"\"\n-        # the Iterable check is required for mypy\n-        if is_scalar(names) or not isinstance(names, Iterable):\n-            names = {names}\n-        else:\n-            names = set(names)\n-        if errors == \"raise\":\n-            self._assert_all_in_dataset(names)\n-\n-        variables = {k: v for k, v in self._variables.items() if k not in names}\n-        coord_names = {k for k in self._coord_names if k in variables}\n-        indexes = {k: v for k, v in self.indexes.items() if k not in names}\n-        return self._replace_with_new_dims(\n-            variables, coord_names=coord_names, indexes=indexes\n-        )\n-\n-    def drop(self, labels=None, dim=None, *, errors=\"raise\", **labels_kwargs):\n-        \"\"\"Backward compatible method based on `drop_vars` and `drop_sel`\n-\n-        Using either `drop_vars` or `drop_sel` is encouraged\n-\n-        See Also\n-        --------\n-        Dataset.drop_vars\n-        Dataset.drop_sel\n-        \"\"\"\n-        if errors not in [\"raise\", \"ignore\"]:\n-            raise ValueError('errors must be either \"raise\" or \"ignore\"')\n-\n-        if is_dict_like(labels) and not isinstance(labels, dict):\n-            warnings.warn(\n-                \"dropping coordinates using `drop` is be deprecated; use drop_vars.\",\n-                FutureWarning,\n-                stacklevel=2,\n-            )\n-            return self.drop_vars(labels, errors=errors)\n-\n-        if labels_kwargs or isinstance(labels, dict):\n-            if dim is not None:\n-                raise ValueError(\"cannot specify dim and dict-like arguments.\")\n-            labels = either_dict_or_kwargs(labels, labels_kwargs, \"drop\")\n-\n-        if dim is None and (is_list_like(labels) or is_scalar(labels)):\n-            warnings.warn(\n-                \"dropping variables using `drop` will be deprecated; using drop_vars is encouraged.\",\n-                PendingDeprecationWarning,\n-                stacklevel=2,\n-            )\n-            return self.drop_vars(labels, errors=errors)\n-        if dim is not None:\n-            warnings.warn(\n-                \"dropping labels using list-like labels is deprecated; using \"\n-                \"dict-like arguments with `drop_sel`, e.g. `ds.drop_sel(dim=[labels]).\",\n-                DeprecationWarning,\n-                stacklevel=2,\n-            )\n-            return self.drop_sel({dim: labels}, errors=errors, **labels_kwargs)\n-\n-        warnings.warn(\n-            \"dropping labels using `drop` will be deprecated; using drop_sel is encouraged.\",\n-            PendingDeprecationWarning,\n-            stacklevel=2,\n-        )\n-        return self.drop_sel(labels, errors=errors)\n-\n-    def drop_sel(self, labels=None, *, errors=\"raise\", **labels_kwargs):\n-        \"\"\"Drop index labels from this dataset.\n-\n-        Parameters\n-        ----------\n-        labels : Mapping[Hashable, Any]\n-            Index labels to drop\n-        errors: {'raise', 'ignore'}, optional\n-            If 'raise' (default), raises a ValueError error if\n-            any of the index labels passed are not\n-            in the dataset. If 'ignore', any given labels that are in the\n-            dataset are dropped and no error is raised.\n-        **labels_kwargs : {dim: label, ...}, optional\n-            The keyword arguments form of ``dim`` and ``labels``\n-\n-        Returns\n-        -------\n-        dropped : Dataset\n-\n-        Examples\n-        --------\n-        >>> data = np.random.randn(2, 3)\n-        >>> labels = ['a', 'b', 'c']\n-        >>> ds = xr.Dataset({'A': (['x', 'y'], data), 'y': labels})\n-        >>> ds.drop_sel(y=['a', 'c'])\n-        <xarray.Dataset>\n-        Dimensions:  (x: 2, y: 1)\n-        Coordinates:\n-          * y        (y) <U1 'b'\n-        Dimensions without coordinates: x\n-        Data variables:\n-            A        (x, y) float64 -0.3454 0.1734\n-        >>> ds.drop_sel(y='b')\n-        <xarray.Dataset>\n-        Dimensions:  (x: 2, y: 2)\n-        Coordinates:\n-          * y        (y) <U1 'a' 'c'\n-        Dimensions without coordinates: x\n-        Data variables:\n-            A        (x, y) float64 -0.3944 -1.418 1.423 -1.041\n-        \"\"\"\n-        if errors not in [\"raise\", \"ignore\"]:\n-            raise ValueError('errors must be either \"raise\" or \"ignore\"')\n-\n-        labels = either_dict_or_kwargs(labels, labels_kwargs, \"drop\")\n-\n-        ds = self\n-        for dim, labels_for_dim in labels.items():\n-            # Don't cast to set, as it would harm performance when labels\n-            # is a large numpy array\n-            if utils.is_scalar(labels_for_dim):\n-                labels_for_dim = [labels_for_dim]\n-            labels_for_dim = np.asarray(labels_for_dim)\n-            try:\n-                index = self.indexes[dim]\n-            except KeyError:\n-                raise ValueError(\"dimension %r does not have coordinate labels\" % dim)\n-            new_index = index.drop(labels_for_dim, errors=errors)\n-            ds = ds.loc[{dim: new_index}]\n-        return ds\n-\n-    def drop_dims(\n-        self, drop_dims: Union[Hashable, Iterable[Hashable]], *, errors: str = \"raise\"\n-    ) -> \"Dataset\":\n-        \"\"\"Drop dimensions and associated variables from this dataset.\n-\n-        Parameters\n-        ----------\n-        drop_dims : hashable or iterable of hashable\n-            Dimension or dimensions to drop.\n-        errors: {'raise', 'ignore'}, optional\n-            If 'raise' (default), raises a ValueError error if any of the\n-            dimensions passed are not in the dataset. If 'ignore', any given\n-            labels that are in the dataset are dropped and no error is raised.\n-\n-        Returns\n-        -------\n-        obj : Dataset\n-            The dataset without the given dimensions (or any variables\n-            containing those dimensions)\n-        errors: {'raise', 'ignore'}, optional\n-            If 'raise' (default), raises a ValueError error if\n-            any of the dimensions passed are not\n-            in the dataset. If 'ignore', any given dimensions that are in the\n-            dataset are dropped and no error is raised.\n-        \"\"\"\n-        if errors not in [\"raise\", \"ignore\"]:\n-            raise ValueError('errors must be either \"raise\" or \"ignore\"')\n-\n-        if isinstance(drop_dims, str) or not isinstance(drop_dims, Iterable):\n-            drop_dims = {drop_dims}\n-        else:\n-            drop_dims = set(drop_dims)\n-\n-        if errors == \"raise\":\n-            missing_dims = drop_dims - set(self.dims)\n-            if missing_dims:\n-                raise ValueError(\n-                    \"Dataset does not contain the dimensions: %s\" % missing_dims\n-                )\n-\n-        drop_vars = {k for k, v in self._variables.items() if set(v.dims) & drop_dims}\n-        return self.drop_vars(drop_vars)\n-\n-    def transpose(self, *dims: Hashable) -> \"Dataset\":\n-        \"\"\"Return a new Dataset object with all array dimensions transposed.\n-\n-        Although the order of dimensions on each array will change, the dataset\n-        dimensions themselves will remain in fixed (sorted) order.\n-\n-        Parameters\n-        ----------\n-        *dims : Hashable, optional\n-            By default, reverse the dimensions on each array. Otherwise,\n-            reorder the dimensions to this order.\n-\n-        Returns\n-        -------\n-        transposed : Dataset\n-            Each array in the dataset (including) coordinates will be\n-            transposed to the given order.\n-\n-        Notes\n-        -----\n-        This operation returns a view of each array's data. It is\n-        lazy for dask-backed DataArrays but not for numpy-backed DataArrays\n-        -- the data will be fully loaded into memory.\n-\n-        See Also\n-        --------\n-        numpy.transpose\n-        DataArray.transpose\n-        \"\"\"\n-        if dims:\n-            if set(dims) ^ set(self.dims) and ... not in dims:\n-                raise ValueError(\n-                    \"arguments to transpose (%s) must be \"\n-                    \"permuted dataset dimensions (%s)\" % (dims, tuple(self.dims))\n-                )\n-        ds = self.copy()\n-        for name, var in self._variables.items():\n-            var_dims = tuple(dim for dim in dims if dim in (var.dims + (...,)))\n-            ds._variables[name] = var.transpose(*var_dims)\n-        return ds\n-\n-    def dropna(\n-        self,\n-        dim: Hashable,\n-        how: str = \"any\",\n-        thresh: int = None,\n-        subset: Iterable[Hashable] = None,\n-    ):\n-        \"\"\"Returns a new dataset with dropped labels for missing values along\n-        the provided dimension.\n-\n-        Parameters\n-        ----------\n-        dim : Hashable\n-            Dimension along which to drop missing values. Dropping along\n-            multiple dimensions simultaneously is not yet supported.\n-        how : {'any', 'all'}, optional\n-            * any : if any NA values are present, drop that label\n-            * all : if all values are NA, drop that label\n-        thresh : int, default None\n-            If supplied, require this many non-NA values.\n-        subset : iterable of hashable, optional\n-            Which variables to check for missing values. By default, all\n-            variables in the dataset are checked.\n-\n-        Returns\n-        -------\n-        Dataset\n-        \"\"\"\n-        # TODO: consider supporting multiple dimensions? Or not, given that\n-        # there are some ugly edge cases, e.g., pandas's dropna differs\n-        # depending on the order of the supplied axes.\n-\n-        if dim not in self.dims:\n-            raise ValueError(\"%s must be a single dataset dimension\" % dim)\n-\n-        if subset is None:\n-            subset = iter(self.data_vars)\n-\n-        count = np.zeros(self.dims[dim], dtype=np.int64)\n-        size = 0\n-\n-        for k in subset:\n-            array = self._variables[k]\n-            if dim in array.dims:\n-                dims = [d for d in array.dims if d != dim]\n-                count += np.asarray(array.count(dims))  # type: ignore\n-                size += np.prod([self.dims[d] for d in dims])\n-\n-        if thresh is not None:\n-            mask = count >= thresh\n-        elif how == \"any\":\n-            mask = count == size\n-        elif how == \"all\":\n-            mask = count > 0\n-        elif how is not None:\n-            raise ValueError(\"invalid how option: %s\" % how)\n-        else:\n-            raise TypeError(\"must specify how or thresh\")\n-\n-        return self.isel({dim: mask})\n-\n-    def fillna(self, value: Any) -> \"Dataset\":\n-        \"\"\"Fill missing values in this object.\n-\n-        This operation follows the normal broadcasting and alignment rules that\n-        xarray uses for binary arithmetic, except the result is aligned to this\n-        object (``join='left'``) instead of aligned to the intersection of\n-        index coordinates (``join='inner'``).\n-\n-        Parameters\n-        ----------\n-        value : scalar, ndarray, DataArray, dict or Dataset\n-            Used to fill all matching missing values in this dataset's data\n-            variables. Scalars, ndarrays or DataArrays arguments are used to\n-            fill all data with aligned coordinates (for DataArrays).\n-            Dictionaries or datasets match data variables and then align\n-            coordinates if necessary.\n-\n-        Returns\n-        -------\n-        Dataset\n-\n-        Examples\n-        --------\n-\n-        >>> import numpy as np\n-        >>> import xarray as xr\n-        >>> ds = xr.Dataset(\n-        ...     {\n-        ...         \"A\": (\"x\", [np.nan, 2, np.nan, 0]),\n-        ...         \"B\": (\"x\", [3, 4, np.nan, 1]),\n-        ...         \"C\": (\"x\", [np.nan, np.nan, np.nan, 5]),\n-        ...         \"D\": (\"x\", [np.nan, 3, np.nan, 4])\n-        ...     },\n-        ...     coords={\"x\": [0, 1, 2, 3]})\n-        >>> ds\n-        <xarray.Dataset>\n-        Dimensions:  (x: 4)\n-        Coordinates:\n-        * x        (x) int64 0 1 2 3\n-        Data variables:\n-            A        (x) float64 nan 2.0 nan 0.0\n-            B        (x) float64 3.0 4.0 nan 1.0\n-            C        (x) float64 nan nan nan 5.0\n-            D        (x) float64 nan 3.0 nan 4.0\n-\n-        Replace all `NaN` values with 0s.\n-\n-        >>> ds.fillna(0)\n-        <xarray.Dataset>\n-        Dimensions:  (x: 4)\n-        Coordinates:\n-        * x        (x) int64 0 1 2 3\n-        Data variables:\n-            A        (x) float64 0.0 2.0 0.0 0.0\n-            B        (x) float64 3.0 4.0 0.0 1.0\n-            C        (x) float64 0.0 0.0 0.0 5.0\n-            D        (x) float64 0.0 3.0 0.0 4.0\n-\n-        Replace all `NaN` elements in column \u2018A\u2019, \u2018B\u2019, \u2018C\u2019, and \u2018D\u2019, with 0, 1, 2, and 3 respectively.\n-\n-        >>> values = {'A': 0, 'B': 1, 'C': 2, 'D': 3}\n-        >>> ds.fillna(value=values)\n-        <xarray.Dataset>\n-        Dimensions:  (x: 4)\n-        Coordinates:\n-        * x        (x) int64 0 1 2 3\n-        Data variables:\n-            A        (x) float64 0.0 2.0 0.0 0.0\n-            B        (x) float64 3.0 4.0 1.0 1.0\n-            C        (x) float64 2.0 2.0 2.0 5.0\n-            D        (x) float64 3.0 3.0 3.0 4.0\n-        \"\"\"\n-        if utils.is_dict_like(value):\n-            value_keys = getattr(value, \"data_vars\", value).keys()\n-            if not set(value_keys) <= set(self.data_vars.keys()):\n-                raise ValueError(\n-                    \"all variables in the argument to `fillna` \"\n-                    \"must be contained in the original dataset\"\n-                )\n-        out = ops.fillna(self, value)\n-        return out\n-\n-    def interpolate_na(\n-        self,\n-        dim: Hashable = None,\n-        method: str = \"linear\",\n-        limit: int = None,\n-        use_coordinate: Union[bool, Hashable] = True,\n-        max_gap: Union[int, float, str, pd.Timedelta, np.timedelta64] = None,\n-        **kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Fill in NaNs by interpolating according to different methods.\n-\n-        Parameters\n-        ----------\n-        dim : str\n-            Specifies the dimension along which to interpolate.\n-\n-        method : str, optional\n-            String indicating which method to use for interpolation:\n-\n-            - 'linear': linear interpolation (Default). Additional keyword\n-              arguments are passed to :py:func:`numpy.interp`\n-            - 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'polynomial':\n-              are passed to :py:func:`scipy.interpolate.interp1d`. If\n-              ``method='polynomial'``, the ``order`` keyword argument must also be\n-              provided.\n-            - 'barycentric', 'krog', 'pchip', 'spline', 'akima': use their\n-              respective :py:class:`scipy.interpolate` classes.\n-\n-        use_coordinate : bool, str, default True\n-            Specifies which index to use as the x values in the interpolation\n-            formulated as `y = f(x)`. If False, values are treated as if\n-            eqaully-spaced along ``dim``. If True, the IndexVariable `dim` is\n-            used. If ``use_coordinate`` is a string, it specifies the name of a\n-            coordinate variariable to use as the index.\n-        limit : int, default None\n-            Maximum number of consecutive NaNs to fill. Must be greater than 0\n-            or None for no limit. This filling is done regardless of the size of\n-            the gap in the data. To only interpolate over gaps less than a given length,\n-            see ``max_gap``.\n-        max_gap: int, float, str, pandas.Timedelta, numpy.timedelta64, default None.\n-            Maximum size of gap, a continuous sequence of NaNs, that will be filled.\n-            Use None for no limit. When interpolating along a datetime64 dimension\n-            and ``use_coordinate=True``, ``max_gap`` can be one of the following:\n-\n-            - a string that is valid input for pandas.to_timedelta\n-            - a :py:class:`numpy.timedelta64` object\n-            - a :py:class:`pandas.Timedelta` object\n-\n-            Otherwise, ``max_gap`` must be an int or a float. Use of ``max_gap`` with unlabeled\n-            dimensions has not been implemented yet. Gap length is defined as the difference\n-            between coordinate values at the first data point after a gap and the last value\n-            before a gap. For gaps at the beginning (end), gap length is defined as the difference\n-            between coordinate values at the first (last) valid data point and the first (last) NaN.\n-            For example, consider::\n-\n-                <xarray.DataArray (x: 9)>\n-                array([nan, nan, nan,  1., nan, nan,  4., nan, nan])\n-                Coordinates:\n-                  * x        (x) int64 0 1 2 3 4 5 6 7 8\n-\n-            The gap lengths are 3-0 = 3; 6-3 = 3; and 8-6 = 2 respectively\n-        kwargs : dict, optional\n-            parameters passed verbatim to the underlying interpolation function\n-\n-        Returns\n-        -------\n-        interpolated: Dataset\n-            Filled in Dataset.\n-\n-        See also\n-        --------\n-        numpy.interp\n-        scipy.interpolate\n-        \"\"\"\n-        from .missing import interp_na, _apply_over_vars_with_dim\n-\n-        new = _apply_over_vars_with_dim(\n-            interp_na,\n-            self,\n-            dim=dim,\n-            method=method,\n-            limit=limit,\n-            use_coordinate=use_coordinate,\n-            max_gap=max_gap,\n-            **kwargs,\n-        )\n-        return new\n-\n-    def ffill(self, dim: Hashable, limit: int = None) -> \"Dataset\":\n-        \"\"\"Fill NaN values by propogating values forward\n-\n-        *Requires bottleneck.*\n-\n-        Parameters\n-        ----------\n-        dim : Hashable\n-            Specifies the dimension along which to propagate values when\n-            filling.\n-        limit : int, default None\n-            The maximum number of consecutive NaN values to forward fill. In\n-            other words, if there is a gap with more than this number of\n-            consecutive NaNs, it will only be partially filled. Must be greater\n-            than 0 or None for no limit.\n-\n-        Returns\n-        -------\n-        Dataset\n-        \"\"\"\n-        from .missing import ffill, _apply_over_vars_with_dim\n-\n-        new = _apply_over_vars_with_dim(ffill, self, dim=dim, limit=limit)\n-        return new\n-\n-    def bfill(self, dim: Hashable, limit: int = None) -> \"Dataset\":\n-        \"\"\"Fill NaN values by propogating values backward\n-\n-        *Requires bottleneck.*\n-\n-        Parameters\n-        ----------\n-        dim : str\n-            Specifies the dimension along which to propagate values when\n-            filling.\n-        limit : int, default None\n-            The maximum number of consecutive NaN values to backward fill. In\n-            other words, if there is a gap with more than this number of\n-            consecutive NaNs, it will only be partially filled. Must be greater\n-            than 0 or None for no limit.\n-\n-        Returns\n-        -------\n-        Dataset\n-        \"\"\"\n-        from .missing import bfill, _apply_over_vars_with_dim\n-\n-        new = _apply_over_vars_with_dim(bfill, self, dim=dim, limit=limit)\n-        return new\n-\n-    def combine_first(self, other: \"Dataset\") -> \"Dataset\":\n-        \"\"\"Combine two Datasets, default to data_vars of self.\n-\n-        The new coordinates follow the normal broadcasting and alignment rules\n-        of ``join='outer'``.  Vacant cells in the expanded coordinates are\n-        filled with np.nan.\n-\n-        Parameters\n-        ----------\n-        other : Dataset\n-            Used to fill all matching missing values in this array.\n-\n-        Returns\n-        -------\n-        DataArray\n-        \"\"\"\n-        out = ops.fillna(self, other, join=\"outer\", dataset_join=\"outer\")\n-        return out\n-\n-    def reduce(\n-        self,\n-        func: Callable,\n-        dim: Union[Hashable, Iterable[Hashable]] = None,\n-        keep_attrs: bool = None,\n-        keepdims: bool = False,\n-        numeric_only: bool = False,\n-        allow_lazy: bool = None,\n-        **kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Reduce this dataset by applying `func` along some dimension(s).\n-\n-        Parameters\n-        ----------\n-        func : callable\n-            Function which can be called in the form\n-            `f(x, axis=axis, **kwargs)` to return the result of reducing an\n-            np.ndarray over an integer valued axis.\n-        dim : str or sequence of str, optional\n-            Dimension(s) over which to apply `func`.  By default `func` is\n-            applied over all dimensions.\n-        keep_attrs : bool, optional\n-            If True, the dataset's attributes (`attrs`) will be copied from\n-            the original object to the new one.  If False (default), the new\n-            object will be returned without attributes.\n-        keepdims : bool, default False\n-            If True, the dimensions which are reduced are left in the result\n-            as dimensions of size one. Coordinates that use these dimensions\n-            are removed.\n-        numeric_only : bool, optional\n-            If True, only apply ``func`` to variables with a numeric dtype.\n-        **kwargs : Any\n-            Additional keyword arguments passed on to ``func``.\n-\n-        Returns\n-        -------\n-        reduced : Dataset\n-            Dataset with this object's DataArrays replaced with new DataArrays\n-            of summarized data and the indicated dimension(s) removed.\n-        \"\"\"\n-        if dim is None or dim is ...:\n-            dims = set(self.dims)\n-        elif isinstance(dim, str) or not isinstance(dim, Iterable):\n-            dims = {dim}\n-        else:\n-            dims = set(dim)\n-\n-        missing_dimensions = [d for d in dims if d not in self.dims]\n-        if missing_dimensions:\n-            raise ValueError(\n-                \"Dataset does not contain the dimensions: %s\" % missing_dimensions\n-            )\n-\n-        if keep_attrs is None:\n-            keep_attrs = _get_keep_attrs(default=False)\n-\n-        variables: Dict[Hashable, Variable] = {}\n-        for name, var in self._variables.items():\n-            reduce_dims = [d for d in var.dims if d in dims]\n-            if name in self.coords:\n-                if not reduce_dims:\n-                    variables[name] = var\n-            else:\n-                if (\n-                    not numeric_only\n-                    or np.issubdtype(var.dtype, np.number)\n-                    or (var.dtype == np.bool_)\n-                ):\n-                    if len(reduce_dims) == 1:\n-                        # unpack dimensions for the benefit of functions\n-                        # like np.argmin which can't handle tuple arguments\n-                        (reduce_dims,) = reduce_dims\n-                    elif len(reduce_dims) == var.ndim:\n-                        # prefer to aggregate over axis=None rather than\n-                        # axis=(0, 1) if they will be equivalent, because\n-                        # the former is often more efficient\n-                        reduce_dims = None  # type: ignore\n-                    variables[name] = var.reduce(\n-                        func,\n-                        dim=reduce_dims,\n-                        keep_attrs=keep_attrs,\n-                        keepdims=keepdims,\n-                        allow_lazy=allow_lazy,\n-                        **kwargs,\n-                    )\n-\n-        coord_names = {k for k in self.coords if k in variables}\n-        indexes = {k: v for k, v in self.indexes.items() if k in variables}\n-        attrs = self.attrs if keep_attrs else None\n-        return self._replace_with_new_dims(\n-            variables, coord_names=coord_names, attrs=attrs, indexes=indexes\n-        )\n-\n-    def map(\n-        self,\n-        func: Callable,\n-        keep_attrs: bool = None,\n-        args: Iterable[Any] = (),\n-        **kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"Apply a function to each variable in this dataset\n-\n-        Parameters\n-        ----------\n-        func : callable\n-            Function which can be called in the form `func(x, *args, **kwargs)`\n-            to transform each DataArray `x` in this dataset into another\n-            DataArray.\n-        keep_attrs : bool, optional\n-            If True, the dataset's attributes (`attrs`) will be copied from\n-            the original object to the new one. If False, the new object will\n-            be returned without attributes.\n-        args : tuple, optional\n-            Positional arguments passed on to `func`.\n-        **kwargs : Any\n-            Keyword arguments passed on to `func`.\n-\n-        Returns\n-        -------\n-        applied : Dataset\n-            Resulting dataset from applying ``func`` to each data variable.\n-\n-        Examples\n-        --------\n-        >>> da = xr.DataArray(np.random.randn(2, 3))\n-        >>> ds = xr.Dataset({'foo': da, 'bar': ('x', [-1, 2])})\n-        >>> ds\n-        <xarray.Dataset>\n-        Dimensions:  (dim_0: 2, dim_1: 3, x: 2)\n-        Dimensions without coordinates: dim_0, dim_1, x\n-        Data variables:\n-            foo      (dim_0, dim_1) float64 -0.3751 -1.951 -1.945 0.2948 0.711 -0.3948\n-            bar      (x) int64 -1 2\n-        >>> ds.map(np.fabs)\n-        <xarray.Dataset>\n-        Dimensions:  (dim_0: 2, dim_1: 3, x: 2)\n-        Dimensions without coordinates: dim_0, dim_1, x\n-        Data variables:\n-            foo      (dim_0, dim_1) float64 0.3751 1.951 1.945 0.2948 0.711 0.3948\n-            bar      (x) float64 1.0 2.0\n-        \"\"\"\n-        variables = {\n-            k: maybe_wrap_array(v, func(v, *args, **kwargs))\n-            for k, v in self.data_vars.items()\n-        }\n-        if keep_attrs is None:\n-            keep_attrs = _get_keep_attrs(default=False)\n-        attrs = self.attrs if keep_attrs else None\n-        return type(self)(variables, attrs=attrs)\n-\n-    def apply(\n-        self,\n-        func: Callable,\n-        keep_attrs: bool = None,\n-        args: Iterable[Any] = (),\n-        **kwargs: Any,\n-    ) -> \"Dataset\":\n-        \"\"\"\n-        Backward compatible implementation of ``map``\n-\n-        See Also\n-        --------\n-        Dataset.map\n-        \"\"\"\n-        warnings.warn(\n-            \"Dataset.apply may be deprecated in the future. Using Dataset.map is encouraged\",\n-            PendingDeprecationWarning,\n-            stacklevel=2,\n-        )\n-        return self.map(func, keep_attrs, args, **kwargs)\n-\n-    def assign(\n-        self, variables: Mapping[Hashable, Any] = None, **variables_kwargs: Hashable\n-    ) -> \"Dataset\":\n-        \"\"\"Assign new data variables to a Dataset, returning a new object\n-        with all the original variables in addition to the new ones.\n-\n-        Parameters\n-        ----------\n-        variables : mapping, value pairs\n-            Mapping from variables names to the new values. If the new values\n-            are callable, they are computed on the Dataset and assigned to new\n-            data variables. If the values are not callable, (e.g. a DataArray,\n-            scalar, or array), they are simply assigned.\n-        **variables_kwargs:\n-            The keyword arguments form of ``variables``.\n-            One of variables or variables_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        ds : Dataset\n-            A new Dataset with the new variables in addition to all the\n-            existing variables.\n-\n-        Notes\n-        -----\n-        Since ``kwargs`` is a dictionary, the order of your arguments may not\n-        be preserved, and so the order of the new variables is not well\n-        defined. Assigning multiple variables within the same ``assign`` is\n-        possible, but you cannot reference other variables created within the\n-        same ``assign`` call.\n-\n-        See Also\n-        --------\n-        pandas.DataFrame.assign\n-\n-        Examples\n-        --------\n-        >>> import numpy as np\n-        >>> import xarray as xr\n-        >>> x = xr.Dataset(\n-        ...     {\n-        ...         \"temperature_c\": ((\"lat\", \"lon\"), 20 * np.random.rand(4).reshape(2, 2)),\n-        ...         \"precipitation\": ((\"lat\", \"lon\"), np.random.rand(4).reshape(2, 2)),\n-        ...     },\n-        ...     coords={\"lat\": [10, 20], \"lon\": [150, 160]},\n-        ... )\n-        >>> x\n-        <xarray.Dataset>\n-        Dimensions:        (lat: 2, lon: 2)\n-        Coordinates:\n-        * lat            (lat) int64 10 20\n-        * lon            (lon) int64 150 160\n-        Data variables:\n-            temperature_c  (lat, lon) float64 18.04 12.51 17.64 9.313\n-            precipitation  (lat, lon) float64 0.4751 0.6827 0.3697 0.03524\n-\n-        Where the value is a callable, evaluated on dataset:\n-\n-        >>> x.assign(temperature_f = lambda x: x.temperature_c * 9 / 5 + 32)\n-        <xarray.Dataset>\n-        Dimensions:        (lat: 2, lon: 2)\n-        Coordinates:\n-        * lat            (lat) int64 10 20\n-        * lon            (lon) int64 150 160\n-        Data variables:\n-            temperature_c  (lat, lon) float64 18.04 12.51 17.64 9.313\n-            precipitation  (lat, lon) float64 0.4751 0.6827 0.3697 0.03524\n-            temperature_f  (lat, lon) float64 64.47 54.51 63.75 48.76\n-\n-        Alternatively, the same behavior can be achieved by directly referencing an existing dataarray:\n-\n-        >>> x.assign(temperature_f=x[\"temperature_c\"] * 9 / 5 + 32)\n-        <xarray.Dataset>\n-        Dimensions:        (lat: 2, lon: 2)\n-        Coordinates:\n-        * lat            (lat) int64 10 20\n-        * lon            (lon) int64 150 160\n-        Data variables:\n-            temperature_c  (lat, lon) float64 18.04 12.51 17.64 9.313\n-            precipitation  (lat, lon) float64 0.4751 0.6827 0.3697 0.03524\n-            temperature_f  (lat, lon) float64 64.47 54.51 63.75 48.76\n-\n-        \"\"\"\n-        variables = either_dict_or_kwargs(variables, variables_kwargs, \"assign\")\n-        data = self.copy()\n-        # do all calculations first...\n-        results = data._calc_assign_results(variables)\n-        # ... and then assign\n-        data.update(results)\n-        return data\n-\n-    def to_array(self, dim=\"variable\", name=None):\n-        \"\"\"Convert this dataset into an xarray.DataArray\n-\n-        The data variables of this dataset will be broadcast against each other\n-        and stacked along the first axis of the new array. All coordinates of\n-        this dataset will remain coordinates.\n-\n-        Parameters\n-        ----------\n-        dim : str, optional\n-            Name of the new dimension.\n-        name : str, optional\n-            Name of the new data array.\n-\n-        Returns\n-        -------\n-        array : xarray.DataArray\n-        \"\"\"\n-        from .dataarray import DataArray\n-\n-        data_vars = [self.variables[k] for k in self.data_vars]\n-        broadcast_vars = broadcast_variables(*data_vars)\n-        data = duck_array_ops.stack([b.data for b in broadcast_vars], axis=0)\n-\n-        coords = dict(self.coords)\n-        coords[dim] = list(self.data_vars)\n-        indexes = propagate_indexes(self._indexes)\n-\n-        dims = (dim,) + broadcast_vars[0].dims\n-\n-        return DataArray(\n-            data, coords, dims, attrs=self.attrs, name=name, indexes=indexes\n-        )\n-\n-    def _to_dataframe(self, ordered_dims):\n-        columns = [k for k in self.variables if k not in self.dims]\n-        data = [\n-            self._variables[k].set_dims(ordered_dims).values.reshape(-1)\n-            for k in columns\n-        ]\n-        index = self.coords.to_index(ordered_dims)\n-        return pd.DataFrame(dict(zip(columns, data)), index=index)\n-\n-    def to_dataframe(self):\n-        \"\"\"Convert this dataset into a pandas.DataFrame.\n-\n-        Non-index variables in this dataset form the columns of the\n-        DataFrame. The DataFrame is be indexed by the Cartesian product of\n-        this dataset's indices.\n-        \"\"\"\n-        return self._to_dataframe(self.dims)\n-\n-    def _set_sparse_data_from_dataframe(\n-        self, dataframe: pd.DataFrame, dims: tuple, shape: Tuple[int, ...]\n-    ) -> None:\n-        from sparse import COO\n-\n-        idx = dataframe.index\n-        if isinstance(idx, pd.MultiIndex):\n-            try:\n-                codes = idx.codes\n-            except AttributeError:\n-                # deprecated since pandas 0.24\n-                codes = idx.labels\n-            coords = np.stack([np.asarray(code) for code in codes], axis=0)\n-            is_sorted = idx.is_lexsorted\n-        else:\n-            coords = np.arange(idx.size).reshape(1, -1)\n-            is_sorted = True\n-\n-        for name, series in dataframe.items():\n-            # Cast to a NumPy array first, in case the Series is a pandas\n-            # Extension array (which doesn't have a valid NumPy dtype)\n-            values = np.asarray(series)\n-\n-            # In virtually all real use cases, the sparse array will now have\n-            # missing values and needs a fill_value. For consistency, don't\n-            # special case the rare exceptions (e.g., dtype=int without a\n-            # MultiIndex).\n-            dtype, fill_value = dtypes.maybe_promote(values.dtype)\n-            values = np.asarray(values, dtype=dtype)\n-\n-            data = COO(\n-                coords,\n-                values,\n-                shape,\n-                has_duplicates=False,\n-                sorted=is_sorted,\n-                fill_value=fill_value,\n-            )\n-            self[name] = (dims, data)\n-\n-    def _set_numpy_data_from_dataframe(\n-        self, dataframe: pd.DataFrame, dims: tuple, shape: Tuple[int, ...]\n-    ) -> None:\n-        idx = dataframe.index\n-        if isinstance(idx, pd.MultiIndex):\n-            # expand the DataFrame to include the product of all levels\n-            full_idx = pd.MultiIndex.from_product(idx.levels, names=idx.names)\n-            dataframe = dataframe.reindex(full_idx)\n-\n-        for name, series in dataframe.items():\n-            data = np.asarray(series).reshape(shape)\n-            self[name] = (dims, data)\n-\n-    @classmethod\n-    def from_dataframe(cls, dataframe: pd.DataFrame, sparse: bool = False) -> \"Dataset\":\n-        \"\"\"Convert a pandas.DataFrame into an xarray.Dataset\n-\n-        Each column will be converted into an independent variable in the\n-        Dataset. If the dataframe's index is a MultiIndex, it will be expanded\n-        into a tensor product of one-dimensional indices (filling in missing\n-        values with NaN). This method will produce a Dataset very similar to\n-        that on which the 'to_dataframe' method was called, except with\n-        possibly redundant dimensions (since all dataset variables will have\n-        the same dimensionality)\n-\n-        Parameters\n-        ----------\n-        dataframe : pandas.DataFrame\n-            DataFrame from which to copy data and indices.\n-        sparse : bool\n-            If true, create a sparse arrays instead of dense numpy arrays. This\n-            can potentially save a large amount of memory if the DataFrame has\n-            a MultiIndex. Requires the sparse package (sparse.pydata.org).\n-\n-        Returns\n-        -------\n-        New Dataset.\n-\n-        See also\n-        --------\n-        xarray.DataArray.from_series\n-        \"\"\"\n-        # TODO: Add an option to remove dimensions along which the variables\n-        # are constant, to enable consistent serialization to/from a dataframe,\n-        # even if some variables have different dimensionality.\n-\n-        if not dataframe.columns.is_unique:\n-            raise ValueError(\"cannot convert DataFrame with non-unique columns\")\n-\n-        idx = dataframe.index\n-        obj = cls()\n-\n-        if isinstance(idx, pd.MultiIndex):\n-            dims = tuple(\n-                name if name is not None else \"level_%i\" % n\n-                for n, name in enumerate(idx.names)\n-            )\n-            for dim, lev in zip(dims, idx.levels):\n-                obj[dim] = (dim, lev)\n-            shape = tuple(lev.size for lev in idx.levels)\n-        else:\n-            index_name = idx.name if idx.name is not None else \"index\"\n-            dims = (index_name,)\n-            obj[index_name] = (dims, idx)\n-            shape = (idx.size,)\n-\n-        if sparse:\n-            obj._set_sparse_data_from_dataframe(dataframe, dims, shape)\n-        else:\n-            obj._set_numpy_data_from_dataframe(dataframe, dims, shape)\n-        return obj\n-\n-    def to_dask_dataframe(self, dim_order=None, set_index=False):\n-        \"\"\"\n-        Convert this dataset into a dask.dataframe.DataFrame.\n-\n-        The dimensions, coordinates and data variables in this dataset form\n-        the columns of the DataFrame.\n-\n-        Parameters\n-        ----------\n-        dim_order : list, optional\n-            Hierarchical dimension order for the resulting dataframe. All\n-            arrays are transposed to this order and then written out as flat\n-            vectors in contiguous order, so the last dimension in this list\n-            will be contiguous in the resulting DataFrame. This has a major\n-            influence on which operations are efficient on the resulting dask\n-            dataframe.\n-\n-            If provided, must include all dimensions on this dataset. By\n-            default, dimensions are sorted alphabetically.\n-        set_index : bool, optional\n-            If set_index=True, the dask DataFrame is indexed by this dataset's\n-            coordinate. Since dask DataFrames to not support multi-indexes,\n-            set_index only works if the dataset only contains one dimension.\n-\n-        Returns\n-        -------\n-        dask.dataframe.DataFrame\n-        \"\"\"\n-\n-        import dask.array as da\n-        import dask.dataframe as dd\n-\n-        if dim_order is None:\n-            dim_order = list(self.dims)\n-        elif set(dim_order) != set(self.dims):\n-            raise ValueError(\n-                \"dim_order {} does not match the set of dimensions on this \"\n-                \"Dataset: {}\".format(dim_order, list(self.dims))\n-            )\n-\n-        ordered_dims = {k: self.dims[k] for k in dim_order}\n-\n-        columns = list(ordered_dims)\n-        columns.extend(k for k in self.coords if k not in self.dims)\n-        columns.extend(self.data_vars)\n-\n-        series_list = []\n-        for name in columns:\n-            try:\n-                var = self.variables[name]\n-            except KeyError:\n-                # dimension without a matching coordinate\n-                size = self.dims[name]\n-                data = da.arange(size, chunks=size, dtype=np.int64)\n-                var = Variable((name,), data)\n-\n-            # IndexVariable objects have a dummy .chunk() method\n-            if isinstance(var, IndexVariable):\n-                var = var.to_base_variable()\n-\n-            dask_array = var.set_dims(ordered_dims).chunk(self.chunks).data\n-            series = dd.from_array(dask_array.reshape(-1), columns=[name])\n-            series_list.append(series)\n-\n-        df = dd.concat(series_list, axis=1)\n-\n-        if set_index:\n-            if len(dim_order) == 1:\n-                (dim,) = dim_order\n-                df = df.set_index(dim)\n-            else:\n-                # triggers an error about multi-indexes, even if only one\n-                # dimension is passed\n-                df = df.set_index(dim_order)\n-\n-        return df\n-\n-    def to_dict(self, data=True):\n-        \"\"\"\n-        Convert this dataset to a dictionary following xarray naming\n-        conventions.\n-\n-        Converts all variables and attributes to native Python objects\n-        Useful for coverting to json. To avoid datetime incompatibility\n-        use decode_times=False kwarg in xarrray.open_dataset.\n-\n-        Parameters\n-        ----------\n-        data : bool, optional\n-            Whether to include the actual data in the dictionary. When set to\n-            False, returns just the schema.\n-\n-        See also\n-        --------\n-        Dataset.from_dict\n-        \"\"\"\n-        d = {\n-            \"coords\": {},\n-            \"attrs\": decode_numpy_dict_values(self.attrs),\n-            \"dims\": dict(self.dims),\n-            \"data_vars\": {},\n-        }\n-        for k in self.coords:\n-            d[\"coords\"].update({k: self[k].variable.to_dict(data=data)})\n-        for k in self.data_vars:\n-            d[\"data_vars\"].update({k: self[k].variable.to_dict(data=data)})\n-        return d\n-\n-    @classmethod\n-    def from_dict(cls, d):\n-        \"\"\"\n-        Convert a dictionary into an xarray.Dataset.\n-\n-        Input dict can take several forms::\n-\n-            d = {'t': {'dims': ('t'), 'data': t},\n-                 'a': {'dims': ('t'), 'data': x},\n-                 'b': {'dims': ('t'), 'data': y}}\n-\n-            d = {'coords': {'t': {'dims': 't', 'data': t,\n-                                  'attrs': {'units':'s'}}},\n-                 'attrs': {'title': 'air temperature'},\n-                 'dims': 't',\n-                 'data_vars': {'a': {'dims': 't', 'data': x, },\n-                               'b': {'dims': 't', 'data': y}}}\n-\n-        where 't' is the name of the dimesion, 'a' and 'b' are names of data\n-        variables and t, x, and y are lists, numpy.arrays or pandas objects.\n-\n-        Parameters\n-        ----------\n-        d : dict, with a minimum structure of {'var_0': {'dims': [..], \\\n-                                                         'data': [..]}, \\\n-                                               ...}\n-\n-        Returns\n-        -------\n-        obj : xarray.Dataset\n-\n-        See also\n-        --------\n-        Dataset.to_dict\n-        DataArray.from_dict\n-        \"\"\"\n-\n-        if not {\"coords\", \"data_vars\"}.issubset(set(d)):\n-            variables = d.items()\n-        else:\n-            import itertools\n-\n-            variables = itertools.chain(\n-                d.get(\"coords\", {}).items(), d.get(\"data_vars\", {}).items()\n-            )\n-        try:\n-            variable_dict = {\n-                k: (v[\"dims\"], v[\"data\"], v.get(\"attrs\")) for k, v in variables\n-            }\n-        except KeyError as e:\n-            raise ValueError(\n-                \"cannot convert dict without the key \"\n-                \"'{dims_data}'\".format(dims_data=str(e.args[0]))\n-            )\n-        obj = cls(variable_dict)\n-\n-        # what if coords aren't dims?\n-        coords = set(d.get(\"coords\", {})) - set(d.get(\"dims\", {}))\n-        obj = obj.set_coords(coords)\n-\n-        obj.attrs.update(d.get(\"attrs\", {}))\n-\n-        return obj\n-\n-    @staticmethod\n-    def _unary_op(f, keep_attrs=False):\n-        @functools.wraps(f)\n-        def func(self, *args, **kwargs):\n-            variables = {}\n-            for k, v in self._variables.items():\n-                if k in self._coord_names:\n-                    variables[k] = v\n-                else:\n-                    variables[k] = f(v, *args, **kwargs)\n-            attrs = self._attrs if keep_attrs else None\n-            return self._replace_with_new_dims(variables, attrs=attrs)\n-\n-        return func\n-\n-    @staticmethod\n-    def _binary_op(f, reflexive=False, join=None):\n-        @functools.wraps(f)\n-        def func(self, other):\n-            from .dataarray import DataArray\n-\n-            if isinstance(other, groupby.GroupBy):\n-                return NotImplemented\n-            align_type = OPTIONS[\"arithmetic_join\"] if join is None else join\n-            if isinstance(other, (DataArray, Dataset)):\n-                self, other = align(self, other, join=align_type, copy=False)\n-            g = f if not reflexive else lambda x, y: f(y, x)\n-            ds = self._calculate_binary_op(g, other, join=align_type)\n-            return ds\n-\n-        return func\n-\n-    @staticmethod\n-    def _inplace_binary_op(f):\n-        @functools.wraps(f)\n-        def func(self, other):\n-            from .dataarray import DataArray\n-\n-            if isinstance(other, groupby.GroupBy):\n-                raise TypeError(\n-                    \"in-place operations between a Dataset and \"\n-                    \"a grouped object are not permitted\"\n-                )\n-            # we don't actually modify arrays in-place with in-place Dataset\n-            # arithmetic -- this lets us automatically align things\n-            if isinstance(other, (DataArray, Dataset)):\n-                other = other.reindex_like(self, copy=False)\n-            g = ops.inplace_to_noninplace_op(f)\n-            ds = self._calculate_binary_op(g, other, inplace=True)\n-            self._replace_with_new_dims(\n-                ds._variables,\n-                ds._coord_names,\n-                attrs=ds._attrs,\n-                indexes=ds._indexes,\n-                inplace=True,\n-            )\n-            return self\n-\n-        return func\n-\n-    def _calculate_binary_op(self, f, other, join=\"inner\", inplace=False):\n-        def apply_over_both(lhs_data_vars, rhs_data_vars, lhs_vars, rhs_vars):\n-            if inplace and set(lhs_data_vars) != set(rhs_data_vars):\n-                raise ValueError(\n-                    \"datasets must have the same data variables \"\n-                    \"for in-place arithmetic operations: %s, %s\"\n-                    % (list(lhs_data_vars), list(rhs_data_vars))\n-                )\n-\n-            dest_vars = {}\n-\n-            for k in lhs_data_vars:\n-                if k in rhs_data_vars:\n-                    dest_vars[k] = f(lhs_vars[k], rhs_vars[k])\n-                elif join in [\"left\", \"outer\"]:\n-                    dest_vars[k] = f(lhs_vars[k], np.nan)\n-            for k in rhs_data_vars:\n-                if k not in dest_vars and join in [\"right\", \"outer\"]:\n-                    dest_vars[k] = f(rhs_vars[k], np.nan)\n-            return dest_vars\n-\n-        if utils.is_dict_like(other) and not isinstance(other, Dataset):\n-            # can't use our shortcut of doing the binary operation with\n-            # Variable objects, so apply over our data vars instead.\n-            new_data_vars = apply_over_both(\n-                self.data_vars, other, self.data_vars, other\n-            )\n-            return Dataset(new_data_vars)\n-\n-        other_coords = getattr(other, \"coords\", None)\n-        ds = self.coords.merge(other_coords)\n-\n-        if isinstance(other, Dataset):\n-            new_vars = apply_over_both(\n-                self.data_vars, other.data_vars, self.variables, other.variables\n-            )\n-        else:\n-            other_variable = getattr(other, \"variable\", other)\n-            new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}\n-        ds._variables.update(new_vars)\n-        ds._dims = calculate_dimensions(ds._variables)\n-        return ds\n-\n-    def _copy_attrs_from(self, other):\n-        self.attrs = other.attrs\n-        for v in other.variables:\n-            if v in self.variables:\n-                self.variables[v].attrs = other.variables[v].attrs\n-\n-    def diff(self, dim, n=1, label=\"upper\"):\n-        \"\"\"Calculate the n-th order discrete difference along given axis.\n-\n-        Parameters\n-        ----------\n-        dim : str, optional\n-            Dimension over which to calculate the finite difference.\n-        n : int, optional\n-            The number of times values are differenced.\n-        label : str, optional\n-            The new coordinate in dimension ``dim`` will have the\n-            values of either the minuend's or subtrahend's coordinate\n-            for values 'upper' and 'lower', respectively.  Other\n-            values are not supported.\n-\n-        Returns\n-        -------\n-        difference : same type as caller\n-            The n-th order finite difference of this object.\n-\n-        Examples\n-        --------\n-        >>> ds = xr.Dataset({'foo': ('x', [5, 5, 6, 6])})\n-        >>> ds.diff('x')\n-        <xarray.Dataset>\n-        Dimensions:  (x: 3)\n-        Coordinates:\n-          * x        (x) int64 1 2 3\n-        Data variables:\n-            foo      (x) int64 0 1 0\n-        >>> ds.diff('x', 2)\n-        <xarray.Dataset>\n-        Dimensions:  (x: 2)\n-        Coordinates:\n-        * x        (x) int64 2 3\n-        Data variables:\n-        foo      (x) int64 1 -1\n-\n-        See Also\n-        --------\n-        Dataset.differentiate\n-        \"\"\"\n-        if n == 0:\n-            return self\n-        if n < 0:\n-            raise ValueError(f\"order `n` must be non-negative but got {n}\")\n-\n-        # prepare slices\n-        kwargs_start = {dim: slice(None, -1)}\n-        kwargs_end = {dim: slice(1, None)}\n-\n-        # prepare new coordinate\n-        if label == \"upper\":\n-            kwargs_new = kwargs_end\n-        elif label == \"lower\":\n-            kwargs_new = kwargs_start\n-        else:\n-            raise ValueError(\n-                \"The 'label' argument has to be either \" \"'upper' or 'lower'\"\n-            )\n-\n-        variables = {}\n-\n-        for name, var in self.variables.items():\n-            if dim in var.dims:\n-                if name in self.data_vars:\n-                    variables[name] = var.isel(**kwargs_end) - var.isel(**kwargs_start)\n-                else:\n-                    variables[name] = var.isel(**kwargs_new)\n-            else:\n-                variables[name] = var\n-\n-        indexes = dict(self.indexes)\n-        if dim in indexes:\n-            indexes[dim] = indexes[dim][kwargs_new[dim]]\n-\n-        difference = self._replace_with_new_dims(variables, indexes=indexes)\n-\n-        if n > 1:\n-            return difference.diff(dim, n - 1)\n-        else:\n-            return difference\n-\n-    def shift(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs):\n-        \"\"\"Shift this dataset by an offset along one or more dimensions.\n-\n-        Only data variables are moved; coordinates stay in place. This is\n-        consistent with the behavior of ``shift`` in pandas.\n-\n-        Parameters\n-        ----------\n-        shifts : Mapping with the form of {dim: offset}\n-            Integer offset to shift along each of the given dimensions.\n-            Positive offsets shift to the right; negative offsets shift to the\n-            left.\n-        fill_value: scalar, optional\n-            Value to use for newly missing values\n-        **shifts_kwargs:\n-            The keyword arguments form of ``shifts``.\n-            One of shifts or shifts_kwargs must be provided.\n-\n-        Returns\n-        -------\n-        shifted : Dataset\n-            Dataset with the same coordinates and attributes but shifted data\n-            variables.\n-\n-        See also\n-        --------\n-        roll\n-\n-        Examples\n-        --------\n-\n-        >>> ds = xr.Dataset({'foo': ('x', list('abcde'))})\n-        >>> ds.shift(x=2)\n-        <xarray.Dataset>\n-        Dimensions:  (x: 5)\n-        Coordinates:\n-          * x        (x) int64 0 1 2 3 4\n-        Data variables:\n-            foo      (x) object nan nan 'a' 'b' 'c'\n-        \"\"\"\n-        shifts = either_dict_or_kwargs(shifts, shifts_kwargs, \"shift\")\n-        invalid = [k for k in shifts if k not in self.dims]\n-        if invalid:\n-            raise ValueError(\"dimensions %r do not exist\" % invalid)\n-\n-        variables = {}\n-        for name, var in self.variables.items():\n-            if name in self.data_vars:\n-                var_shifts = {k: v for k, v in shifts.items() if k in var.dims}\n-                variables[name] = var.shift(fill_value=fill_value, shifts=var_shifts)\n-            else:\n-                variables[name] = var\n-\n-        return self._replace(variables)\n-\n-    def roll(self, shifts=None, roll_coords=None, **shifts_kwargs):\n-        \"\"\"Roll this dataset by an offset along one or more dimensions.\n-\n-        Unlike shift, roll may rotate all variables, including coordinates\n-        if specified. The direction of rotation is consistent with\n-        :py:func:`numpy.roll`.\n-\n-        Parameters\n-        ----------\n-\n-        shifts : dict, optional\n-            A dict with keys matching dimensions and values given\n-            by integers to rotate each of the given dimensions. Positive\n-            offsets roll to the right; negative offsets roll to the left.\n-        roll_coords : bool\n-            Indicates whether to  roll the coordinates by the offset\n-            The current default of roll_coords (None, equivalent to True) is\n-            deprecated and will change to False in a future version.\n-            Explicitly pass roll_coords to silence the warning.\n-        **shifts_kwargs : {dim: offset, ...}, optional\n-            The keyword arguments form of ``shifts``.\n-            One of shifts or shifts_kwargs must be provided.\n-        Returns\n-        -------\n-        rolled : Dataset\n-            Dataset with the same coordinates and attributes but rolled\n-            variables.\n-\n-        See also\n-        --------\n-        shift\n-\n-        Examples\n-        --------\n-\n-        >>> ds = xr.Dataset({'foo': ('x', list('abcde'))})\n-        >>> ds.roll(x=2)\n-        <xarray.Dataset>\n-        Dimensions:  (x: 5)\n-        Coordinates:\n-          * x        (x) int64 3 4 0 1 2\n-        Data variables:\n-            foo      (x) object 'd' 'e' 'a' 'b' 'c'\n-        \"\"\"\n-        shifts = either_dict_or_kwargs(shifts, shifts_kwargs, \"roll\")\n-        invalid = [k for k in shifts if k not in self.dims]\n-        if invalid:\n-            raise ValueError(\"dimensions %r do not exist\" % invalid)\n-\n-        if roll_coords is None:\n-            warnings.warn(\n-                \"roll_coords will be set to False in the future.\"\n-                \" Explicitly set roll_coords to silence warning.\",\n-                FutureWarning,\n-                stacklevel=2,\n-            )\n-            roll_coords = True\n-\n-        unrolled_vars = () if roll_coords else self.coords\n-\n-        variables = {}\n-        for k, v in self.variables.items():\n-            if k not in unrolled_vars:\n-                variables[k] = v.roll(\n-                    **{k: s for k, s in shifts.items() if k in v.dims}\n-                )\n-            else:\n-                variables[k] = v\n-\n-        if roll_coords:\n-            indexes = {}\n-            for k, v in self.indexes.items():\n-                (dim,) = self.variables[k].dims\n-                if dim in shifts:\n-                    indexes[k] = roll_index(v, shifts[dim])\n-                else:\n-                    indexes[k] = v\n-        else:\n-            indexes = dict(self.indexes)\n-\n-        return self._replace(variables, indexes=indexes)\n-\n-    def sortby(self, variables, ascending=True):\n-        \"\"\"\n-        Sort object by labels or values (along an axis).\n-\n-        Sorts the dataset, either along specified dimensions,\n-        or according to values of 1-D dataarrays that share dimension\n-        with calling object.\n-\n-        If the input variables are dataarrays, then the dataarrays are aligned\n-        (via left-join) to the calling object prior to sorting by cell values.\n-        NaNs are sorted to the end, following Numpy convention.\n-\n-        If multiple sorts along the same dimension is\n-        given, numpy's lexsort is performed along that dimension:\n-        https://docs.scipy.org/doc/numpy/reference/generated/numpy.lexsort.html\n-        and the FIRST key in the sequence is used as the primary sort key,\n-        followed by the 2nd key, etc.\n-\n-        Parameters\n-        ----------\n-        variables: str, DataArray, or list of either\n-            1D DataArray objects or name(s) of 1D variable(s) in\n-            coords/data_vars whose values are used to sort the dataset.\n-        ascending: boolean, optional\n-            Whether to sort by ascending or descending order.\n-\n-        Returns\n-        -------\n-        sorted: Dataset\n-            A new dataset where all the specified dims are sorted by dim\n-            labels.\n-        \"\"\"\n-        from .dataarray import DataArray\n-\n-        if not isinstance(variables, list):\n-            variables = [variables]\n-        else:\n-            variables = variables\n-        variables = [v if isinstance(v, DataArray) else self[v] for v in variables]\n-        aligned_vars = align(self, *variables, join=\"left\")\n-        aligned_self = aligned_vars[0]\n-        aligned_other_vars = aligned_vars[1:]\n-        vars_by_dim = defaultdict(list)\n-        for data_array in aligned_other_vars:\n-            if data_array.ndim != 1:\n-                raise ValueError(\"Input DataArray is not 1-D.\")\n-            (key,) = data_array.dims\n-            vars_by_dim[key].append(data_array)\n-\n-        indices = {}\n-        for key, arrays in vars_by_dim.items():\n-            order = np.lexsort(tuple(reversed(arrays)))\n-            indices[key] = order if ascending else order[::-1]\n-        return aligned_self.isel(**indices)\n-\n-    def quantile(\n-        self, q, dim=None, interpolation=\"linear\", numeric_only=False, keep_attrs=None\n-    ):\n-        \"\"\"Compute the qth quantile of the data along the specified dimension.\n-\n-        Returns the qth quantiles(s) of the array elements for each variable\n-        in the Dataset.\n-\n-        Parameters\n-        ----------\n-        q : float in range of [0,1] or array-like of floats\n-            Quantile to compute, which must be between 0 and 1 inclusive.\n-        dim : str or sequence of str, optional\n-            Dimension(s) over which to apply quantile.\n-        interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}\n-            This optional parameter specifies the interpolation method to\n-            use when the desired quantile lies between two data points\n-            ``i < j``:\n-\n-                * linear: ``i + (j - i) * fraction``, where ``fraction`` is\n-                  the fractional part of the index surrounded by ``i`` and\n-                  ``j``.\n-                * lower: ``i``.\n-                * higher: ``j``.\n-                * nearest: ``i`` or ``j``, whichever is nearest.\n-                * midpoint: ``(i + j) / 2``.\n-        keep_attrs : bool, optional\n-            If True, the dataset's attributes (`attrs`) will be copied from\n-            the original object to the new one.  If False (default), the new\n-            object will be returned without attributes.\n-        numeric_only : bool, optional\n-            If True, only apply ``func`` to variables with a numeric dtype.\n-\n-        Returns\n-        -------\n-        quantiles : Dataset\n-            If `q` is a single quantile, then the result is a scalar for each\n-            variable in data_vars. If multiple percentiles are given, first\n-            axis of the result corresponds to the quantile and a quantile\n-            dimension is added to the return Dataset. The other dimensions are\n-            the dimensions that remain after the reduction of the array.\n-\n-        See Also\n-        --------\n-        numpy.nanpercentile, pandas.Series.quantile, DataArray.quantile\n-\n-        Examples\n-        --------\n-\n-        >>> ds = xr.Dataset(\n-        ...     {\"a\": ((\"x\", \"y\"), [[0.7, 4.2, 9.4, 1.5], [6.5, 7.3, 2.6, 1.9]])},\n-        ...     coords={\"x\": [7, 9], \"y\": [1, 1.5, 2, 2.5]},\n-        ... )\n-        >>> ds.quantile(0)  # or ds.quantile(0, dim=...)\n-        <xarray.Dataset>\n-        Dimensions:   ()\n-        Coordinates:\n-            quantile  float64 0.0\n-        Data variables:\n-            a         float64 0.7\n-        >>> ds.quantile(0, dim=\"x\")\n-        <xarray.Dataset>\n-        Dimensions:   (y: 4)\n-        Coordinates:\n-          * y         (y) float64 1.0 1.5 2.0 2.5\n-            quantile  float64 0.0\n-        Data variables:\n-            a         (y) float64 0.7 4.2 2.6 1.5\n-        >>> ds.quantile([0, 0.5, 1])\n-        <xarray.Dataset>\n-        Dimensions:   (quantile: 3)\n-        Coordinates:\n-          * quantile  (quantile) float64 0.0 0.5 1.0\n-        Data variables:\n-            a         (quantile) float64 0.7 3.4 9.4\n-        >>> ds.quantile([0, 0.5, 1], dim=\"x\")\n-        <xarray.Dataset>\n-        Dimensions:   (quantile: 3, y: 4)\n-        Coordinates:\n-          * y         (y) float64 1.0 1.5 2.0 2.5\n-          * quantile  (quantile) float64 0.0 0.5 1.0\n-        Data variables:\n-            a         (quantile, y) float64 0.7 4.2 2.6 1.5 3.6 ... 1.7 6.5 7.3 9.4 1.9\n-        \"\"\"\n-\n-        if isinstance(dim, str):\n-            dims = {dim}\n-        elif dim in [None, ...]:\n-            dims = set(self.dims)\n-        else:\n-            dims = set(dim)\n-\n-        _assert_empty(\n-            [d for d in dims if d not in self.dims],\n-            \"Dataset does not contain the dimensions: %s\",\n-        )\n-\n-        q = np.asarray(q, dtype=np.float64)\n-\n-        variables = {}\n-        for name, var in self.variables.items():\n-            reduce_dims = [d for d in var.dims if d in dims]\n-            if reduce_dims or not var.dims:\n-                if name not in self.coords:\n-                    if (\n-                        not numeric_only\n-                        or np.issubdtype(var.dtype, np.number)\n-                        or var.dtype == np.bool_\n-                    ):\n-                        if len(reduce_dims) == var.ndim:\n-                            # prefer to aggregate over axis=None rather than\n-                            # axis=(0, 1) if they will be equivalent, because\n-                            # the former is often more efficient\n-                            reduce_dims = None\n-                        variables[name] = var.quantile(\n-                            q,\n-                            dim=reduce_dims,\n-                            interpolation=interpolation,\n-                            keep_attrs=keep_attrs,\n-                        )\n-\n-            else:\n-                variables[name] = var\n-\n-        # construct the new dataset\n-        coord_names = {k for k in self.coords if k in variables}\n-        indexes = {k: v for k, v in self.indexes.items() if k in variables}\n-        if keep_attrs is None:\n-            keep_attrs = _get_keep_attrs(default=False)\n-        attrs = self.attrs if keep_attrs else None\n-        new = self._replace_with_new_dims(\n-            variables, coord_names=coord_names, attrs=attrs, indexes=indexes\n-        )\n-        return new.assign_coords(quantile=q)\n-\n-    def rank(self, dim, pct=False, keep_attrs=None):\n-        \"\"\"Ranks the data.\n-\n-        Equal values are assigned a rank that is the average of the ranks that\n-        would have been otherwise assigned to all of the values within\n-        that set.\n-        Ranks begin at 1, not 0. If pct is True, computes percentage ranks.\n-\n-        NaNs in the input array are returned as NaNs.\n-\n-        The `bottleneck` library is required.\n-\n-        Parameters\n-        ----------\n-        dim : str\n-            Dimension over which to compute rank.\n-        pct : bool, optional\n-            If True, compute percentage ranks, otherwise compute integer ranks.\n-        keep_attrs : bool, optional\n-            If True, the dataset's attributes (`attrs`) will be copied from\n-            the original object to the new one.  If False (default), the new\n-            object will be returned without attributes.\n-\n-        Returns\n-        -------\n-        ranked : Dataset\n-            Variables that do not depend on `dim` are dropped.\n-        \"\"\"\n-        if dim not in self.dims:\n-            raise ValueError(\"Dataset does not contain the dimension: %s\" % dim)\n-\n-        variables = {}\n-        for name, var in self.variables.items():\n-            if name in self.data_vars:\n-                if dim in var.dims:\n-                    variables[name] = var.rank(dim, pct=pct)\n-            else:\n-                variables[name] = var\n-\n-        coord_names = set(self.coords)\n-        if keep_attrs is None:\n-            keep_attrs = _get_keep_attrs(default=False)\n-        attrs = self.attrs if keep_attrs else None\n-        return self._replace(variables, coord_names, attrs=attrs)\n-\n-    def differentiate(self, coord, edge_order=1, datetime_unit=None):\n-        \"\"\" Differentiate with the second order accurate central\n-        differences.\n-\n-        .. note::\n-            This feature is limited to simple cartesian geometry, i.e. coord\n-            must be one dimensional.\n-\n-        Parameters\n-        ----------\n-        coord: str\n-            The coordinate to be used to compute the gradient.\n-        edge_order: 1 or 2. Default 1\n-            N-th order accurate differences at the boundaries.\n-        datetime_unit: None or any of {'Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms',\n-            'us', 'ns', 'ps', 'fs', 'as'}\n-            Unit to compute gradient. Only valid for datetime coordinate.\n-\n-        Returns\n-        -------\n-        differentiated: Dataset\n-\n-        See also\n-        --------\n-        numpy.gradient: corresponding numpy function\n-        \"\"\"\n-        from .variable import Variable\n-\n-        if coord not in self.variables and coord not in self.dims:\n-            raise ValueError(f\"Coordinate {coord} does not exist.\")\n-\n-        coord_var = self[coord].variable\n-        if coord_var.ndim != 1:\n-            raise ValueError(\n-                \"Coordinate {} must be 1 dimensional but is {}\"\n-                \" dimensional\".format(coord, coord_var.ndim)\n-            )\n-\n-        dim = coord_var.dims[0]\n-        if _contains_datetime_like_objects(coord_var):\n-            if coord_var.dtype.kind in \"mM\" and datetime_unit is None:\n-                datetime_unit, _ = np.datetime_data(coord_var.dtype)\n-            elif datetime_unit is None:\n-                datetime_unit = \"s\"  # Default to seconds for cftime objects\n-            coord_var = coord_var._to_numeric(datetime_unit=datetime_unit)\n-\n-        variables = {}\n-        for k, v in self.variables.items():\n-            if k in self.data_vars and dim in v.dims and k not in self.coords:\n-                if _contains_datetime_like_objects(v):\n-                    v = v._to_numeric(datetime_unit=datetime_unit)\n-                grad = duck_array_ops.gradient(\n-                    v.data, coord_var, edge_order=edge_order, axis=v.get_axis_num(dim)\n-                )\n-                variables[k] = Variable(v.dims, grad)\n-            else:\n-                variables[k] = v\n-        return self._replace(variables)\n-\n-    def integrate(self, coord, datetime_unit=None):\n-        \"\"\" integrate the array with the trapezoidal rule.\n-\n-        .. note::\n-            This feature is limited to simple cartesian geometry, i.e. coord\n-            must be one dimensional.\n-\n-        Parameters\n-        ----------\n-        coord: str, or a sequence of str\n-            Coordinate(s) used for the integration.\n-        datetime_unit\n-            Can be specify the unit if datetime coordinate is used. One of\n-            {'Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns', 'ps', 'fs',\n-            'as'}\n-\n-        Returns\n-        -------\n-        integrated: Dataset\n-\n-        See also\n-        --------\n-        DataArray.integrate\n-        numpy.trapz: corresponding numpy function\n-\n-        Examples\n-        --------\n-        >>> ds = xr.Dataset(\n-        ...     data_vars={\"a\": (\"x\", [5, 5, 6, 6]), \"b\": (\"x\", [1, 2, 1, 0])},\n-        ...     coords={\"x\": [0, 1, 2, 3], \"y\": (\"x\", [1, 7, 3, 5])},\n-        ... )\n-        >>> ds\n-        <xarray.Dataset>\n-        Dimensions:  (x: 4)\n-        Coordinates:\n-          * x        (x) int64 0 1 2 3\n-            y        (x) int64 1 7 3 5\n-        Data variables:\n-            a        (x) int64 5 5 6 6\n-            b        (x) int64 1 2 1 0\n-        >>> ds.integrate(\"x\")\n-        <xarray.Dataset>\n-        Dimensions:  ()\n-        Data variables:\n-            a        float64 16.5\n-            b        float64 3.5\n-        >>> ds.integrate(\"y\")\n-        <xarray.Dataset>\n-        Dimensions:  ()\n-        Data variables:\n-            a        float64 20.0\n-            b        float64 4.0\n-        \"\"\"\n-        if not isinstance(coord, (list, tuple)):\n-            coord = (coord,)\n-        result = self\n-        for c in coord:\n-            result = result._integrate_one(c, datetime_unit=datetime_unit)\n-        return result\n-\n-    def _integrate_one(self, coord, datetime_unit=None):\n-        from .variable import Variable\n-\n-        if coord not in self.variables and coord not in self.dims:\n-            raise ValueError(f\"Coordinate {coord} does not exist.\")\n-\n-        coord_var = self[coord].variable\n-        if coord_var.ndim != 1:\n-            raise ValueError(\n-                \"Coordinate {} must be 1 dimensional but is {}\"\n-                \" dimensional\".format(coord, coord_var.ndim)\n-            )\n-\n-        dim = coord_var.dims[0]\n-        if _contains_datetime_like_objects(coord_var):\n-            if coord_var.dtype.kind in \"mM\" and datetime_unit is None:\n-                datetime_unit, _ = np.datetime_data(coord_var.dtype)\n-            elif datetime_unit is None:\n-                datetime_unit = \"s\"  # Default to seconds for cftime objects\n-            coord_var = coord_var._replace(\n-                data=datetime_to_numeric(coord_var.data, datetime_unit=datetime_unit)\n-            )\n-\n-        variables = {}\n-        coord_names = set()\n-        for k, v in self.variables.items():\n-            if k in self.coords:\n-                if dim not in v.dims:\n-                    variables[k] = v\n-                    coord_names.add(k)\n-            else:\n-                if k in self.data_vars and dim in v.dims:\n-                    if _contains_datetime_like_objects(v):\n-                        v = datetime_to_numeric(v, datetime_unit=datetime_unit)\n-                    integ = duck_array_ops.trapz(\n-                        v.data, coord_var.data, axis=v.get_axis_num(dim)\n-                    )\n-                    v_dims = list(v.dims)\n-                    v_dims.remove(dim)\n-                    variables[k] = Variable(v_dims, integ)\n-                else:\n-                    variables[k] = v\n-        indexes = {k: v for k, v in self.indexes.items() if k in variables}\n-        return self._replace_with_new_dims(\n-            variables, coord_names=coord_names, indexes=indexes\n-        )\n-\n-    @property\n-    def real(self):\n-        return self._unary_op(lambda x: x.real, keep_attrs=True)(self)\n-\n-    @property\n-    def imag(self):\n-        return self._unary_op(lambda x: x.imag, keep_attrs=True)(self)\n-\n-    @property\n-    def plot(self):\n-        \"\"\"\n-        Access plotting functions for Datasets.\n-        Use it as a namespace to use xarray.plot functions as Dataset methods\n-\n-        >>> ds.plot.scatter(...)  # equivalent to xarray.plot.scatter(ds,...)\n-\n-        \"\"\"\n-        return _Dataset_PlotMethods(self)\n-\n-    def filter_by_attrs(self, **kwargs):\n-        \"\"\"Returns a ``Dataset`` with variables that match specific conditions.\n-\n-        Can pass in ``key=value`` or ``key=callable``.  A Dataset is returned\n-        containing only the variables for which all the filter tests pass.\n-        These tests are either ``key=value`` for which the attribute ``key``\n-        has the exact value ``value`` or the callable passed into\n-        ``key=callable`` returns True. The callable will be passed a single\n-        value, either the value of the attribute ``key`` or ``None`` if the\n-        DataArray does not have an attribute with the name ``key``.\n-\n-        Parameters\n-        ----------\n-        **kwargs : key=value\n-            key : str\n-                Attribute name.\n-            value : callable or obj\n-                If value is a callable, it should return a boolean in the form\n-                of bool = func(attr) where attr is da.attrs[key].\n-                Otherwise, value will be compared to the each\n-                DataArray's attrs[key].\n-\n-        Returns\n-        -------\n-        new : Dataset\n-            New dataset with variables filtered by attribute.\n-\n-        Examples\n-        --------\n-        >>> # Create an example dataset:\n-        >>> import numpy as np\n-        >>> import pandas as pd\n-        >>> import xarray as xr\n-        >>> temp = 15 + 8 * np.random.randn(2, 2, 3)\n-        >>> precip = 10 * np.random.rand(2, 2, 3)\n-        >>> lon = [[-99.83, -99.32], [-99.79, -99.23]]\n-        >>> lat = [[42.25, 42.21], [42.63, 42.59]]\n-        >>> dims = ['x', 'y', 'time']\n-        >>> temp_attr = dict(standard_name='air_potential_temperature')\n-        >>> precip_attr = dict(standard_name='convective_precipitation_flux')\n-        >>> ds = xr.Dataset({\n-        ...         'temperature': (dims,  temp, temp_attr),\n-        ...         'precipitation': (dims, precip, precip_attr)},\n-        ...                 coords={\n-        ...         'lon': (['x', 'y'], lon),\n-        ...         'lat': (['x', 'y'], lat),\n-        ...         'time': pd.date_range('2014-09-06', periods=3),\n-        ...         'reference_time': pd.Timestamp('2014-09-05')})\n-        >>> # Get variables matching a specific standard_name.\n-        >>> ds.filter_by_attrs(standard_name='convective_precipitation_flux')\n-        <xarray.Dataset>\n-        Dimensions:         (time: 3, x: 2, y: 2)\n-        Coordinates:\n-          * x               (x) int64 0 1\n-          * time            (time) datetime64[ns] 2014-09-06 2014-09-07 2014-09-08\n-            lat             (x, y) float64 42.25 42.21 42.63 42.59\n-          * y               (y) int64 0 1\n-            reference_time  datetime64[ns] 2014-09-05\n-            lon             (x, y) float64 -99.83 -99.32 -99.79 -99.23\n-        Data variables:\n-            precipitation   (x, y, time) float64 4.178 2.307 6.041 6.046 0.06648 ...\n-        >>> # Get all variables that have a standard_name attribute.\n-        >>> standard_name = lambda v: v is not None\n-        >>> ds.filter_by_attrs(standard_name=standard_name)\n-        <xarray.Dataset>\n-        Dimensions:         (time: 3, x: 2, y: 2)\n-        Coordinates:\n-            lon             (x, y) float64 -99.83 -99.32 -99.79 -99.23\n-            lat             (x, y) float64 42.25 42.21 42.63 42.59\n-          * x               (x) int64 0 1\n-          * y               (y) int64 0 1\n-          * time            (time) datetime64[ns] 2014-09-06 2014-09-07 2014-09-08\n-            reference_time  datetime64[ns] 2014-09-05\n-        Data variables:\n-            temperature     (x, y, time) float64 25.86 20.82 6.954 23.13 10.25 11.68 ...\n-            precipitation   (x, y, time) float64 5.702 0.9422 2.075 1.178 3.284 ...\n-\n-        \"\"\"\n-        selection = []\n-        for var_name, variable in self.variables.items():\n-            has_value_flag = False\n-            for attr_name, pattern in kwargs.items():\n-                attr_value = variable.attrs.get(attr_name)\n-                if (callable(pattern) and pattern(attr_value)) or attr_value == pattern:\n-                    has_value_flag = True\n-                else:\n-                    has_value_flag = False\n-                    break\n-            if has_value_flag is True:\n-                selection.append(var_name)\n-        return self[selection]\n-\n-    def unify_chunks(self) -> \"Dataset\":\n-        \"\"\" Unify chunk size along all chunked dimensions of this Dataset.\n-\n-        Returns\n-        -------\n-\n-        Dataset with consistent chunk sizes for all dask-array variables\n-\n-        See Also\n-        --------\n-\n-        dask.array.core.unify_chunks\n-        \"\"\"\n-\n-        try:\n-            self.chunks\n-        except ValueError:  # \"inconsistent chunks\"\n-            pass\n-        else:\n-            # No variables with dask backend, or all chunks are already aligned\n-            return self.copy()\n-\n-        # import dask is placed after the quick exit test above to allow\n-        # running this method if dask isn't installed and there are no chunks\n-        import dask.array\n-\n-        ds = self.copy()\n-\n-        dims_pos_map = {dim: index for index, dim in enumerate(ds.dims)}\n-\n-        dask_array_names = []\n-        dask_unify_args = []\n-        for name, variable in ds.variables.items():\n-            if isinstance(variable.data, dask.array.Array):\n-                dims_tuple = [dims_pos_map[dim] for dim in variable.dims]\n-                dask_array_names.append(name)\n-                dask_unify_args.append(variable.data)\n-                dask_unify_args.append(dims_tuple)\n-\n-        _, rechunked_arrays = dask.array.core.unify_chunks(*dask_unify_args)\n-\n-        for name, new_array in zip(dask_array_names, rechunked_arrays):\n-            ds.variables[name]._data = new_array\n-\n-        return ds\n-\n-    def map_blocks(\n-        self,\n-        func: \"Callable[..., T_DSorDA]\",\n-        args: Sequence[Any] = (),\n-        kwargs: Mapping[str, Any] = None,\n-    ) -> \"T_DSorDA\":\n-        \"\"\"\n-        Apply a function to each chunk of this Dataset. This method is experimental and\n-        its signature may change.\n-\n-        Parameters\n-        ----------\n-        func: callable\n-            User-provided function that accepts a Dataset as its first parameter. The\n-            function will receive a subset of this Dataset, corresponding to one chunk\n-            along each chunked dimension. ``func`` will be executed as\n-            ``func(obj_subset, *args, **kwargs)``.\n-\n-            The function will be first run on mocked-up data, that looks like this\n-            Dataset but has sizes 0, to determine properties of the returned object such\n-            as dtype, variable names, new dimensions and new indexes (if any).\n-\n-            This function must return either a single DataArray or a single Dataset.\n-\n-            This function cannot change size of existing dimensions, or add new chunked\n-            dimensions.\n-        args: Sequence\n-            Passed verbatim to func after unpacking, after the sliced DataArray. xarray\n-            objects, if any, will not be split by chunks. Passing dask collections is\n-            not allowed.\n-        kwargs: Mapping\n-            Passed verbatim to func after unpacking. xarray objects, if any, will not be\n-            split by chunks. Passing dask collections is not allowed.\n-\n-        Returns\n-        -------\n-        A single DataArray or Dataset with dask backend, reassembled from the outputs of\n-        the function.\n-\n-        Notes\n-        -----\n-        This method is designed for when one needs to manipulate a whole xarray object\n-        within each chunk. In the more common case where one can work on numpy arrays,\n-        it is recommended to use apply_ufunc.\n-\n-        If none of the variables in this Dataset is backed by dask, calling this method\n-        is equivalent to calling ``func(self, *args, **kwargs)``.\n-\n-        See Also\n-        --------\n-        dask.array.map_blocks, xarray.apply_ufunc, xarray.map_blocks,\n-        xarray.DataArray.map_blocks\n-        \"\"\"\n-        from .parallel import map_blocks\n-\n-        return map_blocks(func, self, args, kwargs)\n-\n-\n-ops.inject_all_ops_and_reduce_methods(Dataset, array_only=False)\n+def merge(self, other, join='outer', fill_value=NaN, priority_arg=None):\n+    if isinstance(other, DataArray):\n+        other = Dataset({other.name: other})\n+    return merge([self, other], join=join, fill_value=fill_value, priority_arg=priority_arg)\n\\ No newline at end of file\n"}
{"instance_id": "pydata__xarray-3993", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py\nindex 2fef3edb..091c4636 100644\n--- a/xarray/core/dataarray.py\n+++ b/xarray/core/dataarray.py\n@@ -3481,17 +3481,21 @@ class DataArray(AbstractArray, DataWithCoords):\n         return self._from_temp_dataset(ds)\n \n     def integrate(\n-        self, dim: Union[Hashable, Sequence[Hashable]], datetime_unit: str = None\n+        self,\n+        coord: Union[Hashable, Sequence[Hashable]] = None,\n+        datetime_unit: str = None,\n+        *,\n+        dim: Union[Hashable, Sequence[Hashable]] = None,\n     ) -> \"DataArray\":\n         \"\"\" integrate the array with the trapezoidal rule.\n \n         .. note::\n-            This feature is limited to simple cartesian geometry, i.e. dim\n+            This feature is limited to simple cartesian geometry, i.e. coord\n             must be one dimensional.\n \n         Parameters\n         ----------\n-        dim : hashable, or sequence of hashable\n+        coord : hashable, or sequence of hashable\n             Coordinate(s) used for the integration.\n         datetime_unit : {\"Y\", \"M\", \"W\", \"D\", \"h\", \"m\", \"s\", \"ms\", \"us\", \"ns\", \\\n                          \"ps\", \"fs\", \"as\"}, optional\n@@ -3528,7 +3532,19 @@ class DataArray(AbstractArray, DataWithCoords):\n         array([5.4, 6.6, 7.8])\n         Dimensions without coordinates: y\n         \"\"\"\n-        ds = self._to_temp_dataset().integrate(dim, datetime_unit)\n+        if dim is not None:\n+            if coord is not None:\n+                raise TypeError(\"Cannot pass both 'dim' and 'coord'.\")\n+            warnings.warn(\n+                \"The `dim` argument to DataArray.integrate has been \"\n+                \"deprecated; please use `coord` instead.\",\n+                FutureWarning,\n+                stacklevel=2,\n+            )\n+            coord = dim\n+        if coord is None:\n+            raise TypeError(\"integrate() missing required argument: 'coord'\")\n+        ds = self._to_temp_dataset().integrate(coord, datetime_unit)\n         return self._from_temp_dataset(ds)\n \n     def unify_chunks(self) -> \"DataArray\":\n", "model": "claude-sonnet-5-5", "steps": 8, "finished": true, "patch_lines": 50, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 50, "steps": 8}], "ms": 43175}
{"instance_id": "pydata__xarray-4075", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/weighted.py b/xarray/core/weighted.py\nindex 996d2e4c..f419ca42 100644\n--- a/xarray/core/weighted.py\n+++ b/xarray/core/weighted.py\n@@ -129,6 +129,10 @@ class Weighted:\n         if skipna or (skipna is None and da.dtype.kind in \"cfO\"):\n             da = da.fillna(0.0)\n \n+        # boolean weights would make `dot` compute a logical (not a numeric) sum\n+        if weights.dtype == bool:\n+            weights = weights * 1\n+\n         # `dot` does not broadcast arrays, so this avoids creating a large\n         # DataArray (if `weights` has additional dimensions)\n         # maybe add fasttrack (`(da * weights).sum(dims=dim, skipna=skipna)`)\n", "model": "claude-haiku-5-5", "steps": 5, "finished": true, "patch_lines": 15, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 15, "steps": 5}], "ms": 15296}
{"instance_id": "pydata__xarray-4094", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py\nindex b0df8749..3be9bb79 100644\n--- a/xarray/core/dataarray.py\n+++ b/xarray/core/dataarray.py\n@@ -1961,7 +1961,7 @@ class DataArray(AbstractArray, DataWithCoords):\n         # pull variables out of datarray\n         data_dict = {}\n         for k in variables:\n-            data_dict[k] = self.sel({variable_dim: k}).squeeze(drop=True)\n+            data_dict[k] = self.sel({variable_dim: k}, drop=True).squeeze(drop=True)\n \n         # unstacked dataset\n         return Dataset(data_dict)\n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 13, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 13, "steps": 6}], "ms": 21372}
{"instance_id": "pydata__xarray-4629", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/merge.py b/xarray/core/merge.py\nindex ca4e29b6..dff00804 100644\n--- a/xarray/core/merge.py\n+++ b/xarray/core/merge.py\n@@ -501,7 +501,7 @@ def merge_attrs(variable_attrs, combine_attrs):\n     if combine_attrs == \"drop\":\n         return {}\n     elif combine_attrs == \"override\":\n-        return variable_attrs[0]\n+        return dict(variable_attrs[0])\n     elif combine_attrs == \"no_conflicts\":\n         result = dict(variable_attrs[0])\n         for attrs in variable_attrs[1:]:\n", "model": "claude-haiku-5-5", "steps": 9, "finished": true, "patch_lines": 13, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 13, "steps": 9}], "ms": 9627}
{"instance_id": "pydata__xarray-4687", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/computation.py b/xarray/core/computation.py\nindex 9fe93c88..0066f196 100644\n--- a/xarray/core/computation.py\n+++ b/xarray/core/computation.py\n@@ -1817,6 +1817,7 @@ def where(cond, x, y):\n         join=\"exact\",\n         dataset_join=\"exact\",\n         dask=\"allowed\",\n+        keep_attrs=True,\n     )\n \n \n", "model": "claude-haiku-5-5", "steps": 11, "finished": true, "patch_lines": 12, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 12, "steps": 11}], "ms": 18117}
