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

Method test_combine_first

xarray/tests/test_dataarray.py:4494–4517  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4492 assert_equal(actual, expected)
4493
4494 def test_combine_first(self) -> None:
4495 ar0 = DataArray([[0, 0], [0, 0]], [("x", ["a", "b"]), ("y", [-1, 0])])
4496 ar1 = DataArray([[1, 1], [1, 1]], [("x", ["b", "c"]), ("y", [0, 1])])
4497 ar2 = DataArray([2], [("x", ["d"])])
4498
4499 actual = ar0.combine_first(ar1)
4500 expected = DataArray(
4501 [[0, 0, np.nan], [0, 0, 1], [np.nan, 1, 1]],
4502 [("x", ["a", "b", "c"]), ("y", [-1, 0, 1])],
4503 )
4504 assert_equal(actual, expected)
4505
4506 actual = ar1.combine_first(ar0)
4507 expected = DataArray(
4508 [[0, 0, np.nan], [0, 1, 1], [np.nan, 1, 1]],
4509 [("x", ["a", "b", "c"]), ("y", [-1, 0, 1])],
4510 )
4511 assert_equal(actual, expected)
4512
4513 actual = ar0.combine_first(ar2)
4514 expected = DataArray(
4515 [[0, 0], [0, 0], [2, 2]], [("x", ["a", "b", "d"]), ("y", [-1, 0])]
4516 )
4517 assert_equal(actual, expected)
4518
4519 def test_sortby(self) -> None:
4520 da = DataArray(

Callers

nothing calls this directly

Calls 3

combine_firstMethod · 0.95
DataArrayClass · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected