Repository: pydata/xarray

Issue:
test_infer_cftime_datetime_units failing on Windows
I don't know why, but this test is now failing on Python 2.7 / Windows: https://ci.appveyor.com/project/shoyer/xray/builds/19850608
```
================================== FAILURES ===================================
______________________ test_infer_cftime_datetime_units _______________________
    @pytest.mark.skipif(not has_cftime_or_netCDF4, reason='cftime not installed')
    def test_infer_cftime_datetime_units():
        date_types = _all_cftime_date_types()
        for date_type in date_types.values():
            for dates, expected in [
                    ([date_type(1900, 1, 1),
                      date_type(1900, 1, 2)],
                     'days since 1900-01-01 00:00:00.000000'),
                    ([date_type(1900, 1, 1, 12),
                      date_type(1900, 1, 1, 13)],
                     'seconds since 1900-01-01 12:00:00.000000'),
                    ([date_type(1900, 1, 1),
                      date_type(1900, 1, 2),
                      date_type(1900, 1, 2, 0, 0, 1)],
                     'seconds since 1900-01-01 00:00:00.000000'),
                    ([date_type(1900, 1, 1),
                      date_type(1900, 1, 2, 0, 0, 0, 5)],
                     'days since 1900-01-01 00:00:00.000000'),
                    ([date_type(1900, 1, 1), date_type(1900, 1, 8),
                      date_type(1900, 1, 16)],
                     'days since 1900-01-01 00:00:00.000000')]:
>               assert expected == coding.times.infer_datetime_units(dates)
E               AssertionError: assert 'seconds sinc...:00:00.000000' == 'hours since 1...:00:00.000000'
E                 - seconds since 1900-01-01 12:00:00.000000
E                 ?  ------
E                 + hours since 1900-01-01 12:00:00.000000
E                 ? ++++
```

@spencerkclark please take a look (or we can xfail this if necessary)

Discussion:

Patch:
diff --git a/doc/whats-new.rst b/doc/whats-new.rst
index 918106a4..3a644ddf 100644
--- a/doc/whats-new.rst
+++ b/doc/whats-new.rst
@@ -33,11 +33,14 @@ 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
+- Finished deprecation cycles:
+  - ``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.
+  - ``DataArray.__contains__`` (used by Python's ``in`` operator) now checks
+    array data, not coordinates. 
 - 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/dataarray.py b/xarray/core/dataarray.py
index f131b003..7dc867c9 100644
--- a/xarray/core/dataarray.py
+++ b/xarray/core/dataarray.py
@@ -503,11 +503,7 @@ class DataArray(AbstractArray, DataWithCoords):
                 LevelCoordinatesSource(self)]
 
     def __contains__(self, key):
-        warnings.warn(
-            'xarray.DataArray.__contains__ currently checks membership in '
-            'DataArray.coords, but in xarray v0.11 will change to check '
-            'membership in array values.', FutureWarning, stacklevel=2)
-        return key in self._coords
+        return key in self.data
 
     @property
     def loc(self):


Test patch:
diff --git a/xarray/tests/test_coding_times.py b/xarray/tests/test_coding_times.py
index 8e47bd37..f76b8c3c 100644
--- a/xarray/tests/test_coding_times.py
+++ b/xarray/tests/test_coding_times.py
@@ -576,28 +576,24 @@ def test_infer_datetime_units(dates, expected):
     assert expected == coding.times.infer_datetime_units(dates)
 
 
+_CFTIME_DATETIME_UNITS_TESTS = [
+    ([(1900, 1, 1), (1900, 1, 1)], 'days since 1900-01-01 00:00:00.000000'),
+    ([(1900, 1, 1), (1900, 1, 2), (1900, 1, 2, 0, 0, 1)],
+     'seconds since 1900-01-01 00:00:00.000000'),
+    ([(1900, 1, 1), (1900, 1, 8), (1900, 1, 16)],
+     'days since 1900-01-01 00:00:00.000000')
+]
+
+
 @pytest.mark.skipif(not has_cftime_or_netCDF4, reason='cftime not installed')
-def test_infer_cftime_datetime_units():
-    date_types = _all_cftime_date_types()
-    for date_type in date_types.values():
-        for dates, expected in [
-                ([date_type(1900, 1, 1),
-                  date_type(1900, 1, 2)],
-                 'days since 1900-01-01 00:00:00.000000'),
-                ([date_type(1900, 1, 1, 12),
-                  date_type(1900, 1, 1, 13)],
-                 'seconds since 1900-01-01 12:00:00.000000'),
-                ([date_type(1900, 1, 1),
-                  date_type(1900, 1, 2),
-                  date_type(1900, 1, 2, 0, 0, 1)],
-                 'seconds since 1900-01-01 00:00:00.000000'),
-                ([date_type(1900, 1, 1),
-                  date_type(1900, 1, 2, 0, 0, 0, 5)],
-                 'days since 1900-01-01 00:00:00.000000'),
-                ([date_type(1900, 1, 1), date_type(1900, 1, 8),
-                  date_type(1900, 1, 16)],
-                 'days since 1900-01-01 00:00:00.000000')]:
-            assert expected == coding.times.infer_datetime_units(dates)
+@pytest.mark.parametrize(
+    'calendar', _NON_STANDARD_CALENDARS + ['gregorian', 'proleptic_gregorian'])
+@pytest.mark.parametrize(('date_args', 'expected'),
+                         _CFTIME_DATETIME_UNITS_TESTS)
+def test_infer_cftime_datetime_units(calendar, date_args, expected):
+    date_type = _all_cftime_date_types()[calendar]
+    dates = [date_type(*args) for args in date_args]
+    assert expected == coding.times.infer_datetime_units(dates)
 
 
 @pytest.mark.parametrize(
diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py
index e49b6cdf..433a669e 100644
--- a/xarray/tests/test_dataarray.py
+++ b/xarray/tests/test_dataarray.py
@@ -618,9 +618,9 @@ class TestDataArray(object):
         da[dict(x=ind)] = value  # should not raise
 
     def test_contains(self):
-        data_array = DataArray(1, coords={'x': 2})
-        with pytest.warns(FutureWarning):
-            assert 'x' in data_array
+        data_array = DataArray([1, 2])
+        assert 1 in data_array
+        assert 3 not in data_array
 
     def test_attr_sources_multiindex(self):
         # make sure attr-style access for multi-index levels
@@ -2533,6 +2533,7 @@ class TestDataArray(object):
         assert_allclose(actual, expected, rtol=1e-16)
 
     @requires_dask
+    @requires_scipy
     def test_upsample_interpolate_dask(self):
         import dask.array as da