(dtype)
| 1415 | |
| 1416 | |
| 1417 | def test_findall_multi_multi_case(dtype) -> None: |
| 1418 | pat_str = r"(\w+)_Xy_(\d*)" |
| 1419 | pat_re = re.compile(dtype(pat_str)) |
| 1420 | |
| 1421 | value = xr.DataArray( |
| 1422 | [ |
| 1423 | ["a_Xy_0", "ab_xY_10-bab_Xy_110-baab_Xy_1100", "abc_Xy_01-cbc_Xy_2210"], |
| 1424 | [ |
| 1425 | "abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210", |
| 1426 | "", |
| 1427 | "abcdef_Xy_101-fef_Xy_5543210", |
| 1428 | ], |
| 1429 | ], |
| 1430 | dims=["X", "Y"], |
| 1431 | ).astype(dtype) |
| 1432 | |
| 1433 | expected_list: list[list[list[list]]] = [ |
| 1434 | [ |
| 1435 | [["a", "0"]], |
| 1436 | [["bab", "110"], ["baab", "1100"]], |
| 1437 | [["abc", "01"], ["cbc", "2210"]], |
| 1438 | ], |
| 1439 | [ |
| 1440 | [["abcd", ""], ["dcd", "33210"], ["dccd", "332210"]], |
| 1441 | [], |
| 1442 | [["abcdef", "101"], ["fef", "5543210"]], |
| 1443 | ], |
| 1444 | ] |
| 1445 | expected_dtype = [ |
| 1446 | [[tuple(dtype(x) for x in y) for y in z] for z in w] for w in expected_list |
| 1447 | ] |
| 1448 | expected_np = np.array(expected_dtype, dtype=np.object_) |
| 1449 | expected = xr.DataArray(expected_np, dims=["X", "Y"]) |
| 1450 | |
| 1451 | res_str = value.str.findall(pat=pat_str) |
| 1452 | res_re = value.str.findall(pat=pat_re) |
| 1453 | res_str_case = value.str.findall(pat=pat_str, case=True) |
| 1454 | |
| 1455 | assert res_str.dtype == expected.dtype |
| 1456 | assert res_re.dtype == expected.dtype |
| 1457 | assert res_str_case.dtype == expected.dtype |
| 1458 | |
| 1459 | assert_equal(res_str, expected) |
| 1460 | assert_equal(res_re, expected) |
| 1461 | assert_equal(res_str_case, expected) |
| 1462 | |
| 1463 | |
| 1464 | def test_findall_multi_multi_nocase(dtype) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…