Skip to content

Commit 51d4d5f

Browse files
authored
Revert "Deprecate bool(ds) (#6126)" (#6141)
1 parent e05edea commit 51d4d5f

File tree

3 files changed

+1
-16
lines changed

3 files changed

+1
-16
lines changed

doc/whats-new.rst

-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ Deprecations
4040
By `Tom Nicholas <https://github.com/TomNicholas>`_.
4141

4242

43-
- Coercing a dataset to bool, e.g. ``bool(ds)``, is being deprecated and will raise an
44-
error in a future version (not yet planned). For now, invoking ``Dataset.__bool__``
45-
issues a ``PendingDeprecationWarning`` (:issue:`6124`, :pull:`6126`).
46-
By `Michael Delgado <https://github.com/delgadom>`_.
47-
4843
Bug fixes
4944
~~~~~~~~~
5045
- Properly support :py:meth:`DataArray.ffill`, :py:meth:`DataArray.bfill`, :py:meth:`Dataset.ffill` and :py:meth:`Dataset.bfill` along chunked dimensions (:issue:`6112`).

xarray/core/dataset.py

-8
Original file line numberDiff line numberDiff line change
@@ -1456,14 +1456,6 @@ def __len__(self) -> int:
14561456
return len(self.data_vars)
14571457

14581458
def __bool__(self) -> bool:
1459-
warnings.warn(
1460-
"coercing a Dataset to a bool will be deprecated. "
1461-
"Using bool(ds.data_vars) to check for at least one "
1462-
"data variable or using Dataset.to_array to test "
1463-
"whether array values are true is encouraged.",
1464-
PendingDeprecationWarning,
1465-
stacklevel=2,
1466-
)
14671459
return bool(self.data_vars)
14681460

14691461
def __iter__(self) -> Iterator[Hashable]:

xarray/tests/test_dataset.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,7 @@ def test_properties(self):
544544
assert "aasldfjalskdfj" not in ds.variables
545545
assert "dim1" in repr(ds.variables)
546546
assert len(ds) == 3
547-
548-
with pytest.warns(PendingDeprecationWarning):
549-
assert bool(ds)
547+
assert bool(ds)
550548

551549
assert list(ds.data_vars) == ["var1", "var2", "var3"]
552550
assert list(ds.data_vars.keys()) == ["var1", "var2", "var3"]

0 commit comments

Comments
 (0)