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

Method test_dataset_math_auto_align

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

Source from the content-addressed store, hash-verified

6698 assert_identical(expected, ds + subsampled)
6699
6700 def test_dataset_math_auto_align(self) -> None:
6701 ds = self.make_example_math_dataset()
6702 subset = ds.isel(y=[1, 3])
6703 expected = 2 * subset
6704 actual = ds + subset
6705 assert_identical(expected, actual)
6706
6707 actual = ds.isel(y=slice(1)) + ds.isel(y=slice(1, None))
6708 expected = 2 * ds.drop_sel(y=ds.y)
6709 assert_equal(actual, expected)
6710
6711 actual = ds + ds[["bar"]]
6712 expected = (2 * ds[["bar"]]).merge(ds.coords, compat="override")
6713 assert_identical(expected, actual)
6714
6715 assert_identical(ds + Dataset(), ds.coords.to_dataset())
6716 assert_identical(Dataset() + Dataset(), Dataset())
6717
6718 ds2 = Dataset(coords={"bar": 42})
6719 assert_identical(ds + ds2, ds.coords.merge(ds2))
6720
6721 # maybe unary arithmetic with empty datasets should raise instead?
6722 assert_identical(Dataset() + 1, Dataset())
6723
6724 actual = ds.copy(deep=True)
6725 other = ds.isel(y=slice(2))
6726 actual += other
6727 expected = ds + other.reindex_like(ds)
6728 assert_identical(expected, actual)
6729
6730 def test_dataset_math_errors(self) -> None:
6731 ds = self.make_example_math_dataset()

Callers

nothing calls this directly

Calls 10

assert_identicalFunction · 0.90
assert_equalFunction · 0.90
DatasetClass · 0.90
iselMethod · 0.45
drop_selMethod · 0.45
mergeMethod · 0.45
to_datasetMethod · 0.45
copyMethod · 0.45
reindex_likeMethod · 0.45

Tested by

no test coverage detected