MCPcopy Index your code
hub / github.com/pydata/xarray / test_dataset_array_math

Method test_dataset_array_math

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

Source from the content-addressed store, hash-verified

6651 _ = ds.searchsorted
6652
6653 def test_dataset_array_math(self) -> None:
6654 ds = self.make_example_math_dataset()
6655
6656 expected = ds.map(lambda x: x - ds["foo"])
6657 assert_identical(expected, ds - ds["foo"])
6658 assert_identical(expected, -ds["foo"] + ds)
6659 assert_identical(expected, ds - ds["foo"].variable)
6660 assert_identical(expected, -ds["foo"].variable + ds)
6661 actual = ds.copy(deep=True)
6662 actual -= ds["foo"]
6663 assert_identical(expected, actual)
6664
6665 expected = ds.map(lambda x: x + ds["bar"])
6666 assert_identical(expected, ds + ds["bar"])
6667 actual = ds.copy(deep=True)
6668 actual += ds["bar"]
6669 assert_identical(expected, actual)
6670
6671 expected = Dataset({"bar": ds["bar"] + np.arange(3)})
6672 assert_identical(expected, ds[["bar"]] + np.arange(3))
6673 assert_identical(expected, np.arange(3) + ds[["bar"]])
6674
6675 def test_dataset_dataset_math(self) -> None:
6676 ds = self.make_example_math_dataset()

Callers

nothing calls this directly

Calls 6

assert_identicalFunction · 0.90
DatasetClass · 0.90
arangeMethod · 0.80
mapMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected