Skip to content

Commit

Permalink
Remove .T as shortcut for transpose() (#2509)
Browse files Browse the repository at this point in the history
* Remove .T as shortcut for transpose()

* fix whats-new

* remove Dataset.__dir__

* Update whats-new.rst

* Update whats-new.rst
  • Loading branch information
dcherian authored and max-sixty committed Oct 26, 2018
1 parent 2a46913 commit 5940100
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ v0.11.0 (unreleased)
Breaking changes
~~~~~~~~~~~~~~~~

- ``Dataset.T`` has been removed as a shortcut for :py:meth:`Dataset.transpose`.
Call :py:meth:`Dataset.transpose` directly instead.
- Iterating over a ``Dataset`` now includes only data variables, not coordinates.
Similarily, calling ``len`` and ``bool`` on a ``Dataset`` now
includes only data variables
Expand Down
14 changes: 0 additions & 14 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,13 +916,6 @@ def _item_sources(self):
return [self.data_vars, self.coords, {d: self[d] for d in self.dims},
LevelCoordinatesSource(self)]

def __dir__(self):
# In order to suppress a deprecation warning in Ipython autocompletion
# .T is explicitly removed from __dir__. GH: issue 1675
d = super(Dataset, self).__dir__()
d.remove('T')
return d

def __contains__(self, key):
"""The 'in' operator will return true or false depending on whether
'key' is an array in the dataset or not.
Expand Down Expand Up @@ -2647,13 +2640,6 @@ def transpose(self, *dims):
ds._variables[name] = var.transpose(*var_dims)
return ds

@property
def T(self):
warnings.warn('xarray.Dataset.T has been deprecated as an alias for '
'`.transpose()`. It will be removed in xarray v0.11.',
FutureWarning, stacklevel=2)
return self.transpose()

def dropna(self, dim, how='any', thresh=None, subset=None):
"""Returns a new dataset with dropped labels for missing values along
the provided dimension.
Expand Down
4 changes: 0 additions & 4 deletions xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3801,10 +3801,6 @@ def test_dataset_transpose(self):
expected = ds.apply(lambda x: x.transpose())
assert_identical(expected, actual)

with pytest.warns(FutureWarning):
actual = ds.T
assert_identical(expected, actual)

actual = ds.transpose('x', 'y')
expected = ds.apply(lambda x: x.transpose('x', 'y'))
assert_identical(expected, actual)
Expand Down

0 comments on commit 5940100

Please sign in to comment.