Repository: pydata/xarray

Issue:
Ipython autocomplete raises a deprecation warning introduced in #1643.
#### Code Sample, a copy-pastable example if possible

```python
# Your code here
import xarray as xr
ds = xr.Dataset({'a': ('x', [0, 1, 2])})
ds. -> press 'Tab'
```
#### Problem description

IPython autocomplete raises a deprecation warning, introducing in #1643.
```ipython
/home/keisukefujii/anaconda3/envs/tensorflow/lib/python3.5/site-packages/jedi/e.
  getattr(obj, name)
/home/keisukefujii/anaconda3/envs/tensorflow/lib/python3.5/site-packages/jedi/e.
  obj = getattr(obj, name)
In [3]: ds.
```
#### Expected Output
None

#### Output of ``xr.show_versions()``

<details>
# Paste the output here xr.show_versions() here

INSTALLED VERSIONS
------------------
commit: 2ef63bf0b199bacc310f448bf0d070a57b7fc043
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-97-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

xarray: 0.9.6-32-g5122ee4
pandas: 0.20.3
numpy: 1.13.1
scipy: 0.19.0
netCDF4: None
h5netcdf: None
Nio: None
bottleneck: None
cyordereddict: None
dask: 0.15.4
matplotlib: 2.0.2
cartopy: None
seaborn: 0.7.1
setuptools: 36.2.7
pip: 9.0.1
conda: None
pytest: 3.0.7
IPython: 6.1.0
sphinx: 1.5.2

</details>


Discussion:

Patch:
diff --git a/doc/whats-new.rst b/doc/whats-new.rst
index d4048ab4..05ebb3e9 100644
--- a/doc/whats-new.rst
+++ b/doc/whats-new.rst
@@ -15,6 +15,17 @@ What's New
 
 .. _whats-new.0.10.0:
 
+Changes since v0.10.0 rc1 (Unreleased)
+--------------------------------------
+
+Bug fixes
+~~~~~~~~~
+
+- Suppress warning in Ipython autocompletion, related to the deprecation
+  of ``.T`` attributes. (:issue:`1675`).
+  By `Keisuke Fujii <https://github.com/fujiisoup>`_
+
+
 v0.10.0 rc1 (30 October 2017)
 -----------------------------
 
diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py
index 422e9fe3..abe32055 100644
--- a/xarray/core/dataset.py
+++ b/xarray/core/dataset.py
@@ -731,6 +731,13 @@ class Dataset(Mapping, ImplementsDatasetReduce, BaseDataObject,
         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.


Test patch:
diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py
index 8a4aa503..4b79fa3a 100644
--- a/xarray/tests/test_dataset.py
+++ b/xarray/tests/test_dataset.py
@@ -3606,6 +3606,8 @@ class TestDataset(TestCase):
         with raises_regex(ValueError, 'arguments to transpose'):
             ds.transpose('dim1', 'dim2', 'dim3', 'time', 'extra_dim')
 
+        assert 'T' not in dir(ds)
+
     def test_dataset_retains_period_index_on_transpose(self):
 
         ds = create_test_data()