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

Method test_broadcast_exclude

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

Source from the content-addressed store, hash-verified

2865 assert source_ndarray(actual_x["foo"].data) is source_ndarray(x["foo"].data)
2866
2867 def test_broadcast_exclude(self) -> None:
2868 x = Dataset(
2869 {
2870 "foo": DataArray(
2871 [[1, 2], [3, 4]], dims=["x", "y"], coords={"x": [1, 2], "y": [3, 4]}
2872 ),
2873 "bar": DataArray(5),
2874 }
2875 )
2876 y = Dataset(
2877 {
2878 "foo": DataArray(
2879 [[1, 2]], dims=["z", "y"], coords={"z": [1], "y": [5, 6]}
2880 )
2881 }
2882 )
2883 x2, y2 = broadcast(x, y, exclude=["y"])
2884
2885 expected_x2 = Dataset(
2886 {
2887 "foo": DataArray(
2888 [[[1, 2]], [[3, 4]]],
2889 dims=["x", "z", "y"],
2890 coords={"z": [1], "x": [1, 2], "y": [3, 4]},
2891 ),
2892 "bar": DataArray(
2893 [[5], [5]], dims=["x", "z"], coords={"x": [1, 2], "z": [1]}
2894 ),
2895 }
2896 )
2897 expected_y2 = Dataset(
2898 {
2899 "foo": DataArray(
2900 [[[1, 2]], [[1, 2]]],
2901 dims=["x", "z", "y"],
2902 coords={"z": [1], "x": [1, 2], "y": [5, 6]},
2903 )
2904 }
2905 )
2906 assert_identical(expected_x2, x2)
2907 assert_identical(expected_y2, y2)
2908
2909 def test_broadcast_misaligned(self) -> None:
2910 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
broadcastFunction · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected