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

Function test_cat_multi

xarray/tests/test_accessor_str.py:3403–3444  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3401
3402
3403def test_cat_multi() -> None:
3404 values_1 = xr.DataArray(
3405 ["11111", "4"],
3406 dims=["X"],
3407 )
3408
3409 values_2 = xr.DataArray(
3410 ["a", "bb", "cccc"],
3411 dims=["Y"],
3412 ).astype(np.bytes_)
3413
3414 values_3 = np.array(3.4)
3415
3416 values_4 = ""
3417
3418 values_5 = np.array("", dtype=np.str_)
3419
3420 sep = xr.DataArray(
3421 [" ", ", "],
3422 dims=["ZZ"],
3423 ).astype(np.str_)
3424
3425 expected = xr.DataArray(
3426 [
3427 [
3428 ["11111 a 3.4 ", "11111, a, 3.4, , "],
3429 ["11111 bb 3.4 ", "11111, bb, 3.4, , "],
3430 ["11111 cccc 3.4 ", "11111, cccc, 3.4, , "],
3431 ],
3432 [
3433 ["4 a 3.4 ", "4, a, 3.4, , "],
3434 ["4 bb 3.4 ", "4, bb, 3.4, , "],
3435 ["4 cccc 3.4 ", "4, cccc, 3.4, , "],
3436 ],
3437 ],
3438 dims=["X", "Y", "ZZ"],
3439 ).astype(np.str_)
3440
3441 res = values_1.str.cat(values_2, values_3, values_4, values_5, sep=sep)
3442
3443 assert res.dtype == expected.dtype
3444 assert_equal(res, expected)
3445
3446
3447def test_join_scalar(dtype) -> None:

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
catMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…