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

Method test_dataset_math_errors

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

Source from the content-addressed store, hash-verified

6728 assert_identical(expected, actual)
6729
6730 def test_dataset_math_errors(self) -> None:
6731 ds = self.make_example_math_dataset()
6732
6733 with pytest.raises(TypeError):
6734 ds["foo"] += ds
6735 with pytest.raises(TypeError):
6736 ds["foo"].variable += ds
6737 with pytest.raises(ValueError, match=r"must have the same"):
6738 ds += ds[["bar"]]
6739
6740 # verify we can rollback in-place operations if something goes wrong
6741 # nb. inplace datetime64 math actually will work with an integer array
6742 # but not floats thanks to numpy's inconsistent handling
6743 other = DataArray(np.datetime64("2000-01-01"), coords={"c": 2})
6744 actual = ds.copy(deep=True)
6745 with pytest.raises(TypeError):
6746 actual += other
6747 assert_identical(actual, ds)
6748
6749 def test_dataset_transpose(self) -> None:
6750 ds = Dataset(

Callers

nothing calls this directly

Calls 4

DataArrayClass · 0.90
assert_identicalFunction · 0.90
copyMethod · 0.45

Tested by

no test coverage detected