MCPcopy
hub / github.com/pydata/xarray / test_unary_ops

Method test_unary_ops

xarray/tests/test_dataset.py:6632–6651  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6630 # casting nan warns
6631 @pytest.mark.filterwarnings("ignore:invalid value encountered in cast")
6632 def test_unary_ops(self) -> None:
6633 ds = self.make_example_math_dataset()
6634
6635 assert_identical(ds.map(abs), abs(ds))
6636 assert_identical(ds.map(lambda x: x + 4), ds + 4)
6637
6638 for func in [
6639 lambda x: x.isnull(),
6640 lambda x: x.round(),
6641 lambda x: x.astype(int),
6642 ]:
6643 assert_identical(ds.map(func), func(ds))
6644
6645 assert_identical(ds.isnull(), ~ds.notnull())
6646
6647 # don't actually patch these methods in
6648 with pytest.raises(AttributeError):
6649 _ = ds.item
6650 with pytest.raises(AttributeError):
6651 _ = ds.searchsorted
6652
6653 def test_dataset_array_math(self) -> None:
6654 ds = self.make_example_math_dataset()

Callers

nothing calls this directly

Calls 8

assert_identicalFunction · 0.90
funcFunction · 0.70
mapMethod · 0.45
isnullMethod · 0.45
roundMethod · 0.45
astypeMethod · 0.45
notnullMethod · 0.45

Tested by

no test coverage detected