(dtype)
| 931 | |
| 932 | |
| 933 | def test_extractall_single_multi_case(dtype) -> None: |
| 934 | pat_str = r"(\w+)_Xy_\d*" |
| 935 | pat_re: str | bytes = ( |
| 936 | pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8") |
| 937 | ) |
| 938 | pat_compiled = re.compile(pat_re) |
| 939 | |
| 940 | value = xr.DataArray( |
| 941 | [ |
| 942 | ["a_Xy_0", "ab_xY_10-bab_Xy_110-baab_Xy_1100", "abc_Xy_01-cbc_Xy_2210"], |
| 943 | [ |
| 944 | "abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210", |
| 945 | "", |
| 946 | "abcdef_Xy_101-fef_Xy_5543210", |
| 947 | ], |
| 948 | ], |
| 949 | dims=["X", "Y"], |
| 950 | ).astype(dtype) |
| 951 | |
| 952 | expected = xr.DataArray( |
| 953 | [ |
| 954 | [[["a"], [""], [""]], [["bab"], ["baab"], [""]], [["abc"], ["cbc"], [""]]], |
| 955 | [ |
| 956 | [["abcd"], ["dcd"], ["dccd"]], |
| 957 | [[""], [""], [""]], |
| 958 | [["abcdef"], ["fef"], [""]], |
| 959 | ], |
| 960 | ], |
| 961 | dims=["X", "Y", "XX", "YY"], |
| 962 | ).astype(dtype) |
| 963 | |
| 964 | res_str = value.str.extractall(pat=pat_str, group_dim="XX", match_dim="YY") |
| 965 | res_re = value.str.extractall(pat=pat_compiled, group_dim="XX", match_dim="YY") |
| 966 | res_str_case = value.str.extractall( |
| 967 | pat=pat_str, group_dim="XX", match_dim="YY", case=True |
| 968 | ) |
| 969 | |
| 970 | assert res_str.dtype == expected.dtype |
| 971 | assert res_re.dtype == expected.dtype |
| 972 | assert res_str_case.dtype == expected.dtype |
| 973 | |
| 974 | assert_equal(res_str, expected) |
| 975 | assert_equal(res_re, expected) |
| 976 | assert_equal(res_str_case, expected) |
| 977 | |
| 978 | |
| 979 | def test_extractall_single_multi_nocase(dtype) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…