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

Function test_partition_comma

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

Source from the content-addressed store, hash-verified

2508
2509
2510def test_partition_comma(dtype) -> None:
2511 values = xr.DataArray(
2512 [
2513 ["abc, def", "spam, eggs, swallow", "red_blue"],
2514 ["test0, test1, test2, test3", "", "abra, ka, da, bra"],
2515 ],
2516 dims=["X", "Y"],
2517 ).astype(dtype)
2518
2519 exp_part_dim_list = [
2520 [
2521 ["abc", ", ", "def"],
2522 ["spam", ", ", "eggs, swallow"],
2523 ["red_blue", "", ""],
2524 ],
2525 [
2526 ["test0", ", ", "test1, test2, test3"],
2527 ["", "", ""],
2528 ["abra", ", ", "ka, da, bra"],
2529 ],
2530 ]
2531
2532 exp_rpart_dim_list = [
2533 [
2534 ["abc", ", ", "def"],
2535 ["spam, eggs", ", ", "swallow"],
2536 ["", "", "red_blue"],
2537 ],
2538 [
2539 ["test0, test1, test2", ", ", "test3"],
2540 ["", "", ""],
2541 ["abra, ka, da", ", ", "bra"],
2542 ],
2543 ]
2544
2545 exp_part_dim = xr.DataArray(exp_part_dim_list, dims=["X", "Y", "ZZ"]).astype(dtype)
2546 exp_rpart_dim = xr.DataArray(exp_rpart_dim_list, dims=["X", "Y", "ZZ"]).astype(
2547 dtype
2548 )
2549
2550 res_part_dim = values.str.partition(sep=", ", dim="ZZ")
2551 res_rpart_dim = values.str.rpartition(sep=", ", dim="ZZ")
2552
2553 assert res_part_dim.dtype == exp_part_dim.dtype
2554 assert res_rpart_dim.dtype == exp_rpart_dim.dtype
2555
2556 assert_equal(res_part_dim, exp_part_dim)
2557 assert_equal(res_rpart_dim, exp_rpart_dim)
2558
2559
2560def test_partition_empty(dtype) -> None:

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
partitionMethod · 0.80
rpartitionMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…