Skip to content

Commit 88690fd

Browse files
sjvrijnmax-sixty
authored andcommitted
removed mention that 'dims' are inferred from 'coords'-dict when omit… (pydata#3821)
* removed mention that 'dims' are inferred from 'coords'-dict when omitted in DataArray (fixes pydata#3820) * added summary of PR pydata#3821 to whats-new
1 parent 1c5e1cd commit 88690fd

File tree

4 files changed

+7
-29
lines changed

4 files changed

+7
-29
lines changed

doc/whats-new.rst

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Bug fixes
7171

7272
Documentation
7373
~~~~~~~~~~~~~
74+
- Fix documentation of :py:class:`DataArray` removing the deprecated mention
75+
that when omitted, `dims` are inferred from a `coords`-dict. (:pull:`3821`)
76+
By `Sander van Rijn <https://github.com/sjvrijn>`_.
7477

7578
Internal Changes
7679
~~~~~~~~~~~~~~~~

xarray/core/dataarray.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import datetime
22
import functools
3-
import warnings
43
from numbers import Number
54
from typing import (
65
TYPE_CHECKING,
@@ -304,8 +303,7 @@ def __init__(
304303
Name(s) of the data dimension(s). Must be either a hashable (only
305304
for 1D data) or a sequence of hashables with length equal to the
306305
number of dimensions. If this argument is omitted, dimension names
307-
are taken from ``coords`` (if possible) and otherwise default to
308-
``['dim_0', ... 'dim_n']``.
306+
default to ``['dim_0', ... 'dim_n']``.
309307
name : str or None, optional
310308
Name of this array.
311309
attrs : dict_like or None, optional
@@ -1860,15 +1858,15 @@ def to_unstacked_dataset(self, dim, level=0):
18601858
# unstacked dataset
18611859
return Dataset(data_dict)
18621860

1863-
def transpose(self, *dims: Hashable, transpose_coords: bool = None) -> "DataArray":
1861+
def transpose(self, *dims: Hashable, transpose_coords: bool = True) -> "DataArray":
18641862
"""Return a new DataArray object with transposed dimensions.
18651863
18661864
Parameters
18671865
----------
18681866
*dims : hashable, optional
18691867
By default, reverse the dimensions. Otherwise, reorder the
18701868
dimensions to this order.
1871-
transpose_coords : boolean, optional
1869+
transpose_coords : boolean, default True
18721870
If True, also transpose the coordinates of this DataArray.
18731871
18741872
Returns
@@ -1897,15 +1895,6 @@ def transpose(self, *dims: Hashable, transpose_coords: bool = None) -> "DataArra
18971895
coords[name] = coord.variable.transpose(*coord_dims)
18981896
return self._replace(variable, coords)
18991897
else:
1900-
if transpose_coords is None and any(self[c].ndim > 1 for c in self.coords):
1901-
warnings.warn(
1902-
"This DataArray contains multi-dimensional "
1903-
"coordinates. In the future, these coordinates "
1904-
"will be transposed as well unless you specify "
1905-
"transpose_coords=False.",
1906-
FutureWarning,
1907-
stacklevel=2,
1908-
)
19091898
return self._replace(variable)
19101899

19111900
@property

xarray/core/groupby.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def __init__(
292292
bins : array-like, optional
293293
If `bins` is specified, the groups will be discretized into the
294294
specified bins by `pandas.cut`.
295-
restore_coord_dims : bool, optional
295+
restore_coord_dims : bool, default True
296296
If True, also restore the dimension order of multi-dimensional
297297
coordinates.
298298
cut_kwargs : dict, optional
@@ -390,14 +390,6 @@ def __init__(
390390
and restore_coord_dims is None
391391
and any(obj[c].ndim > 1 for c in obj.coords)
392392
):
393-
warnings.warn(
394-
"This DataArray contains multi-dimensional "
395-
"coordinates. In the future, the dimension order "
396-
"of these coordinates will be restored as well "
397-
"unless you specify restore_coord_dims=False.",
398-
FutureWarning,
399-
stacklevel=2,
400-
)
401393
restore_coord_dims = False
402394

403395
# specification for the groupby operation

xarray/tests/test_dataarray.py

-6
Original file line numberDiff line numberDiff line change
@@ -2119,9 +2119,6 @@ def test_transpose(self):
21192119
with pytest.raises(ValueError):
21202120
da.transpose("x", "y")
21212121

2122-
with pytest.warns(FutureWarning):
2123-
da.transpose()
2124-
21252122
def test_squeeze(self):
21262123
assert_equal(self.dv.variable.squeeze(), self.dv.squeeze().variable)
21272124

@@ -2703,9 +2700,6 @@ def test_groupby_restore_coord_dims(self):
27032700
)["c"]
27042701
assert result.dims == expected_dims
27052702

2706-
with pytest.warns(FutureWarning):
2707-
array.groupby("x").map(lambda x: x.squeeze())
2708-
27092703
def test_groupby_first_and_last(self):
27102704
array = DataArray([1, 2, 3, 4, 5], dims="x")
27112705
by = DataArray(["a"] * 2 + ["b"] * 3, dims="x", name="ab")

0 commit comments

Comments
 (0)