From 5bf989d46dfd88609d338242c56199e1a1472a59 Mon Sep 17 00:00:00 2001 From: dcherian Date: Wed, 24 Oct 2018 18:56:26 -0700 Subject: [PATCH 1/5] Remove .T as shortcut for transpose() --- doc/whats-new.rst | 3 +++ xarray/core/dataset.py | 10 ---------- xarray/tests/test_dataset.py | 4 ---- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 6512d48d7d8..f3ec61d352f 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -33,6 +33,9 @@ v0.11.0 (unreleased) Breaking changes ~~~~~~~~~~~~~~~~ +- ``.T`` has been removed as a shortcut for :py:meth:`transpose()`. + Call :py:meth:`Dataset.transpose()` or :py:meth:`DataArray.transpose()` instead. + - Xarray's storage backends now automatically open and close files when necessary, rather than requiring opening a file with ``autoclose=True``. A global least-recently-used cache is used to store open files; the default diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 756cd795540..2f530b88397 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -917,10 +917,7 @@ def _item_sources(self): 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): @@ -2666,13 +2663,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. diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 89704653e92..a7eb33b85f1 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -3805,10 +3805,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) From 87474774cfe8be29beef7a5d8a81dd592926e26e Mon Sep 17 00:00:00 2001 From: dcherian Date: Wed, 24 Oct 2018 22:08:24 -0700 Subject: [PATCH 2/5] fix whats-new --- doc/whats-new.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index f3ec61d352f..75d34b2afc1 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -33,8 +33,8 @@ v0.11.0 (unreleased) Breaking changes ~~~~~~~~~~~~~~~~ -- ``.T`` has been removed as a shortcut for :py:meth:`transpose()`. - Call :py:meth:`Dataset.transpose()` or :py:meth:`DataArray.transpose()` instead. +- ``Dataset.T`` has been removed as a shortcut for :py:meth:`transpose()`. + Call :py:meth:`Dataset.transpose()` instead. - Xarray's storage backends now automatically open and close files when necessary, rather than requiring opening a file with ``autoclose=True``. A From 2726253ca11daae8ac74802306cc3b7e9b75dfc2 Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 25 Oct 2018 06:24:42 -0700 Subject: [PATCH 3/5] remove Dataset.__dir__ --- xarray/core/dataset.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 2f530b88397..c3700dc34f8 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -916,10 +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): - d = super(Dataset, self).__dir__() - 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. From bb8882b328d3278b62fad6a55e2c4fe182590594 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Thu, 25 Oct 2018 16:07:58 -0700 Subject: [PATCH 4/5] Update whats-new.rst --- doc/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 9c1b4f1ef9b..7adc17b1d98 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -33,7 +33,7 @@ v0.11.0 (unreleased) Breaking changes ~~~~~~~~~~~~~~~~ -- ``Dataset.T`` has been removed as a shortcut for :py:meth:`transpose()`. +- ``Dataset.T`` has been removed as a shortcut for :py:meth:`Dataset.transpose`. Call :py:meth:`Dataset.transpose()` instead. - Iterating over a ``Dataset`` now includes only data variables, not coordinates. Similarily, calling ``len`` and ``bool`` on a ``Dataset`` now From 770e7eab7c7f59875b5875ea8f9e2f7d2abe8875 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Thu, 25 Oct 2018 17:05:14 -0700 Subject: [PATCH 5/5] Update whats-new.rst --- doc/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 7adc17b1d98..75101ba2273 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -34,7 +34,7 @@ Breaking changes ~~~~~~~~~~~~~~~~ - ``Dataset.T`` has been removed as a shortcut for :py:meth:`Dataset.transpose`. - Call :py:meth:`Dataset.transpose()` instead. + 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