MCPcopy
hub / github.com/pydata/xarray / test_align_exclude

Method test_align_exclude

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

Source from the content-addressed store, hash-verified

2638 xr.align(left.isel(x=0).expand_dims("x"), right, join="override")
2639
2640 def test_align_exclude(self) -> None:
2641 x = Dataset(
2642 {
2643 "foo": DataArray(
2644 [[1, 2], [3, 4]], dims=["x", "y"], coords={"x": [1, 2], "y": [3, 4]}
2645 )
2646 }
2647 )
2648 y = Dataset(
2649 {
2650 "bar": DataArray(
2651 [[1, 2], [3, 4]], dims=["x", "y"], coords={"x": [1, 3], "y": [5, 6]}
2652 )
2653 }
2654 )
2655 x2, y2 = align(x, y, exclude=["y"], join="outer")
2656
2657 expected_x2 = Dataset(
2658 {
2659 "foo": DataArray(
2660 [[1, 2], [3, 4], [np.nan, np.nan]],
2661 dims=["x", "y"],
2662 coords={"x": [1, 2, 3], "y": [3, 4]},
2663 )
2664 }
2665 )
2666 expected_y2 = Dataset(
2667 {
2668 "bar": DataArray(
2669 [[1, 2], [np.nan, np.nan], [3, 4]],
2670 dims=["x", "y"],
2671 coords={"x": [1, 2, 3], "y": [5, 6]},
2672 )
2673 }
2674 )
2675 assert_identical(expected_x2, x2)
2676 assert_identical(expected_y2, y2)
2677
2678 def test_align_nocopy(self) -> None:
2679 x = Dataset({"foo": DataArray([1, 2, 3], coords=[("x", [1, 2, 3])])})

Callers

nothing calls this directly

Calls 4

DatasetClass · 0.90
DataArrayClass · 0.90
alignFunction · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected