Skip to content

Commit 5940100

Browse files
dcherianmax-sixty
authored andcommitted
Remove .T as shortcut for transpose() (#2509)
* Remove .T as shortcut for transpose() * fix whats-new * remove Dataset.__dir__ * Update whats-new.rst * Update whats-new.rst
1 parent 2a46913 commit 5940100

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ v0.11.0 (unreleased)
3333
Breaking changes
3434
~~~~~~~~~~~~~~~~
3535

36+
- ``Dataset.T`` has been removed as a shortcut for :py:meth:`Dataset.transpose`.
37+
Call :py:meth:`Dataset.transpose` directly instead.
3638
- Iterating over a ``Dataset`` now includes only data variables, not coordinates.
3739
Similarily, calling ``len`` and ``bool`` on a ``Dataset`` now
3840
includes only data variables

xarray/core/dataset.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,6 @@ def _item_sources(self):
916916
return [self.data_vars, self.coords, {d: self[d] for d in self.dims},
917917
LevelCoordinatesSource(self)]
918918

919-
def __dir__(self):
920-
# In order to suppress a deprecation warning in Ipython autocompletion
921-
# .T is explicitly removed from __dir__. GH: issue 1675
922-
d = super(Dataset, self).__dir__()
923-
d.remove('T')
924-
return d
925-
926919
def __contains__(self, key):
927920
"""The 'in' operator will return true or false depending on whether
928921
'key' is an array in the dataset or not.
@@ -2647,13 +2640,6 @@ def transpose(self, *dims):
26472640
ds._variables[name] = var.transpose(*var_dims)
26482641
return ds
26492642

2650-
@property
2651-
def T(self):
2652-
warnings.warn('xarray.Dataset.T has been deprecated as an alias for '
2653-
'`.transpose()`. It will be removed in xarray v0.11.',
2654-
FutureWarning, stacklevel=2)
2655-
return self.transpose()
2656-
26572643
def dropna(self, dim, how='any', thresh=None, subset=None):
26582644
"""Returns a new dataset with dropped labels for missing values along
26592645
the provided dimension.

xarray/tests/test_dataset.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,10 +3801,6 @@ def test_dataset_transpose(self):
38013801
expected = ds.apply(lambda x: x.transpose())
38023802
assert_identical(expected, actual)
38033803

3804-
with pytest.warns(FutureWarning):
3805-
actual = ds.T
3806-
assert_identical(expected, actual)
3807-
38083804
actual = ds.transpose('x', 'y')
38093805
expected = ds.apply(lambda x: x.transpose('x', 'y'))
38103806
assert_identical(expected, actual)

0 commit comments

Comments
 (0)