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

Function test_repeat_broadcast

xarray/tests/test_accessor_str.py:1550–1566  ·  view source on GitHub ↗
(dtype)

Source from the content-addressed store, hash-verified

1548
1549
1550def test_repeat_broadcast(dtype) -> None:
1551 values = xr.DataArray(["a", "b", "c", "d"], dims=["X"]).astype(dtype)
1552 reps = xr.DataArray([3, 4], dims=["Y"])
1553
1554 result = values.str.repeat(reps)
1555 result_mul = values.str * reps
1556
1557 expected = xr.DataArray(
1558 [["aaa", "aaaa"], ["bbb", "bbbb"], ["ccc", "cccc"], ["ddd", "dddd"]],
1559 dims=["X", "Y"],
1560 ).astype(dtype)
1561
1562 assert result.dtype == expected.dtype
1563 assert result_mul.dtype == expected.dtype
1564
1565 assert_equal(result_mul, expected)
1566 assert_equal(result, expected)
1567
1568
1569def test_match(dtype) -> None:

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
repeatMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…