From 62bd2a4cde65c732fbaefc82df00a0a3a9d2c06c Mon Sep 17 00:00:00 2001 From: dcherian Date: Wed, 5 Jan 2022 08:57:38 -0700 Subject: [PATCH] Revert "Deprecate bool(ds) (#6126)" This reverts commit d6ee8caa84b27d4635ec3384b1a06ef4ddf2d998. --- doc/whats-new.rst | 5 ----- xarray/core/dataset.py | 8 -------- xarray/tests/test_dataset.py | 4 +--- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index c63470535b1..f8fe939b849 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -40,11 +40,6 @@ Deprecations By `Tom Nicholas `_. -- Coercing a dataset to bool, e.g. ``bool(ds)``, is being deprecated and will raise an - error in a future version (not yet planned). For now, invoking ``Dataset.__bool__`` - issues a ``PendingDeprecationWarning`` (:issue:`6124`, :pull:`6126`). - By `Michael Delgado `_. - Bug fixes ~~~~~~~~~ - Properly support :py:meth:`DataArray.ffill`, :py:meth:`DataArray.bfill`, :py:meth:`Dataset.ffill` and :py:meth:`Dataset.bfill` along chunked dimensions (:issue:`6112`). diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 6996266e1e6..22f4e32e83e 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -1456,14 +1456,6 @@ def __len__(self) -> int: return len(self.data_vars) def __bool__(self) -> bool: - warnings.warn( - "coercing a Dataset to a bool will be deprecated. " - "Using bool(ds.data_vars) to check for at least one " - "data variable or using Dataset.to_array to test " - "whether array values are true is encouraged.", - PendingDeprecationWarning, - stacklevel=2, - ) return bool(self.data_vars) def __iter__(self) -> Iterator[Hashable]: diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 40b9b31c7fa..c8770601c30 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -544,9 +544,7 @@ def test_properties(self): assert "aasldfjalskdfj" not in ds.variables assert "dim1" in repr(ds.variables) assert len(ds) == 3 - - with pytest.warns(PendingDeprecationWarning): - assert bool(ds) + assert bool(ds) assert list(ds.data_vars) == ["var1", "var2", "var3"] assert list(ds.data_vars.keys()) == ["var1", "var2", "var3"]