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

Method test_combine_first

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

Source from the content-addressed store, hash-verified

7203 assert_identical(expected, actual)
7204
7205 def test_combine_first(self) -> None:
7206 dsx0 = DataArray([0, 0], [("x", ["a", "b"])]).to_dataset(name="dsx0")
7207 dsx1 = DataArray([1, 1], [("x", ["b", "c"])]).to_dataset(name="dsx1")
7208
7209 actual = dsx0.combine_first(dsx1)
7210 expected = Dataset(
7211 {"dsx0": ("x", [0, 0, np.nan]), "dsx1": ("x", [np.nan, 1, 1])},
7212 coords={"x": ["a", "b", "c"]},
7213 )
7214 assert_equal(actual, expected)
7215 assert_equal(actual, xr.merge([dsx0, dsx1], join="outer"))
7216
7217 # works just like xr.merge([self, other])
7218 dsy2 = DataArray([2, 2, 2], [("x", ["b", "c", "d"])]).to_dataset(name="dsy2")
7219 actual = dsx0.combine_first(dsy2)
7220 expected = xr.merge([dsy2, dsx0], join="outer")
7221 assert_equal(actual, expected)
7222
7223 def test_sortby(self) -> None:
7224 ds = Dataset(

Callers

nothing calls this directly

Calls 6

DataArrayClass · 0.90
DatasetClass · 0.90
assert_equalFunction · 0.90
to_datasetMethod · 0.45
combine_firstMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected