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

Method test_align_copy

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

Source from the content-addressed store, hash-verified

3339 assert c.dtype == np.float32
3340
3341 def test_align_copy(self) -> None:
3342 x = DataArray([1, 2, 3], coords=[("a", [1, 2, 3])])
3343 y = DataArray([1, 2], coords=[("a", [3, 1])])
3344
3345 expected_x2 = x
3346 expected_y2 = DataArray([2, np.nan, 1], coords=[("a", [1, 2, 3])])
3347
3348 x2, y2 = align(x, y, join="outer", copy=False)
3349 assert_identical(expected_x2, x2)
3350 assert_identical(expected_y2, y2)
3351 assert source_ndarray(x2.data) is source_ndarray(x.data)
3352
3353 x2, y2 = align(x, y, join="outer", copy=True)
3354 assert_identical(expected_x2, x2)
3355 assert_identical(expected_y2, y2)
3356 assert source_ndarray(x2.data) is not source_ndarray(x.data)
3357
3358 # Trivial align - 1 element
3359 x = DataArray([1, 2, 3], coords=[("a", [1, 2, 3])])
3360 (x2,) = align(x, copy=False)
3361 assert_identical(x, x2)
3362 assert source_ndarray(x2.data) is source_ndarray(x.data)
3363
3364 (x2,) = align(x, copy=True)
3365 assert_identical(x, x2)
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]})

Callers

nothing calls this directly

Calls 4

DataArrayClass · 0.90
alignFunction · 0.90
assert_identicalFunction · 0.90
source_ndarrayFunction · 0.90

Tested by

no test coverage detected