Skip to content

Remove .T as shortcut for transpose() #2509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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