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

Method test_align_override

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

Source from the content-addressed store, hash-verified

3366 assert source_ndarray(x2.data) is not source_ndarray(x.data)
3367
3368 def test_align_override(self) -> None:
3369 left = DataArray([1, 2, 3], dims="x", coords={"x": [0, 1, 2]})
3370 right = DataArray(
3371 np.arange(9).reshape((3, 3)),
3372 dims=["x", "y"],
3373 coords={"x": [0.1, 1.1, 2.1], "y": [1, 2, 3]},
3374 )
3375
3376 expected_right = DataArray(
3377 np.arange(9).reshape(3, 3),
3378 dims=["x", "y"],
3379 coords={"x": [0, 1, 2], "y": [1, 2, 3]},
3380 )
3381
3382 new_left, new_right = align(left, right, join="override")
3383 assert_identical(left, new_left)
3384 assert_identical(new_right, expected_right)
3385
3386 new_left, new_right = align(left, right, exclude="x", join="override")
3387 assert_identical(left, new_left)
3388 assert_identical(right, new_right)
3389
3390 new_left, new_right = xr.align(
3391 left.isel(x=0, drop=True), right, exclude="x", join="override"
3392 )
3393 assert_identical(left.isel(x=0, drop=True), new_left)
3394 assert_identical(right, new_right)
3395
3396 with pytest.raises(
3397 ValueError, match=r"cannot align.*join.*override.*same size"
3398 ):
3399 align(left.isel(x=0).expand_dims("x"), right, join="override")
3400
3401 @pytest.mark.parametrize(
3402 "darrays",

Callers

nothing calls this directly

Calls 7

iselMethod · 0.95
DataArrayClass · 0.90
alignFunction · 0.90
assert_identicalFunction · 0.90
arangeMethod · 0.80
alignMethod · 0.80
expand_dimsMethod · 0.45

Tested by

no test coverage detected