Skip to content

Commit a258333

Browse files
shoyermax-sixty
authored andcommitted
Finish deprecation cycle for DataArray.__contains__ checking array values (#2520)
Fixes GH1267
1 parent c2a6902 commit a258333

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

doc/whats-new.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ v0.11.0 (unreleased)
3333
Breaking changes
3434
~~~~~~~~~~~~~~~~
3535

36-
- ``Dataset.T`` has been removed as a shortcut for :py:meth:`Dataset.transpose`.
37-
Call :py:meth:`Dataset.transpose` directly instead.
38-
- Iterating over a ``Dataset`` now includes only data variables, not coordinates.
39-
Similarily, calling ``len`` and ``bool`` on a ``Dataset`` now
40-
includes only data variables
36+
- Finished deprecation cycles:
37+
- ``Dataset.T`` has been removed as a shortcut for :py:meth:`Dataset.transpose`.
38+
Call :py:meth:`Dataset.transpose` directly instead.
39+
- Iterating over a ``Dataset`` now includes only data variables, not coordinates.
40+
Similarily, calling ``len`` and ``bool`` on a ``Dataset`` now
41+
includes only data variables.
42+
- ``DataArray.__contains__`` (used by Python's ``in`` operator) now checks
43+
array data, not coordinates.
4144
- Xarray's storage backends now automatically open and close files when
4245
necessary, rather than requiring opening a file with ``autoclose=True``. A
4346
global least-recently-used cache is used to store open files; the default

xarray/core/dataarray.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,7 @@ def _item_sources(self):
503503
LevelCoordinatesSource(self)]
504504

505505
def __contains__(self, key):
506-
warnings.warn(
507-
'xarray.DataArray.__contains__ currently checks membership in '
508-
'DataArray.coords, but in xarray v0.11 will change to check '
509-
'membership in array values.', FutureWarning, stacklevel=2)
510-
return key in self._coords
506+
return key in self.data
511507

512508
@property
513509
def loc(self):

xarray/tests/test_dataarray.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ def get_data():
618618
da[dict(x=ind)] = value # should not raise
619619

620620
def test_contains(self):
621-
data_array = DataArray(1, coords={'x': 2})
622-
with pytest.warns(FutureWarning):
623-
assert 'x' in data_array
621+
data_array = DataArray([1, 2])
622+
assert 1 in data_array
623+
assert 3 not in data_array
624624

625625
def test_attr_sources_multiindex(self):
626626
# make sure attr-style access for multi-index levels
@@ -2533,6 +2533,7 @@ def test_upsample_interpolate_regression_1605(self):
25332533
assert_allclose(actual, expected, rtol=1e-16)
25342534

25352535
@requires_dask
2536+
@requires_scipy
25362537
def test_upsample_interpolate_dask(self):
25372538
import dask.array as da
25382539

0 commit comments

Comments
 (0)