(dtype)
| 1091 | |
| 1092 | |
| 1093 | def test_extractall_multi_multi_case(dtype) -> None: |
| 1094 | pat_str = r"(\w+)_Xy_(\d*)" |
| 1095 | pat_re: str | bytes = ( |
| 1096 | pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8") |
| 1097 | ) |
| 1098 | pat_compiled = re.compile(pat_re) |
| 1099 | |
| 1100 | value = xr.DataArray( |
| 1101 | [ |
| 1102 | ["a_Xy_0", "ab_xY_10-bab_Xy_110-baab_Xy_1100", "abc_Xy_01-cbc_Xy_2210"], |
| 1103 | [ |
| 1104 | "abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210", |
| 1105 | "", |
| 1106 | "abcdef_Xy_101-fef_Xy_5543210", |
| 1107 | ], |
| 1108 | ], |
| 1109 | dims=["X", "Y"], |
| 1110 | ).astype(dtype) |
| 1111 | |
| 1112 | expected = xr.DataArray( |
| 1113 | [ |
| 1114 | [ |
| 1115 | [["a", "0"], ["", ""], ["", ""]], |
| 1116 | [["bab", "110"], ["baab", "1100"], ["", ""]], |
| 1117 | [["abc", "01"], ["cbc", "2210"], ["", ""]], |
| 1118 | ], |
| 1119 | [ |
| 1120 | [["abcd", ""], ["dcd", "33210"], ["dccd", "332210"]], |
| 1121 | [["", ""], ["", ""], ["", ""]], |
| 1122 | [["abcdef", "101"], ["fef", "5543210"], ["", ""]], |
| 1123 | ], |
| 1124 | ], |
| 1125 | dims=["X", "Y", "XX", "YY"], |
| 1126 | ).astype(dtype) |
| 1127 | |
| 1128 | res_str = value.str.extractall(pat=pat_str, group_dim="XX", match_dim="YY") |
| 1129 | res_re = value.str.extractall(pat=pat_compiled, group_dim="XX", match_dim="YY") |
| 1130 | res_str_case = value.str.extractall( |
| 1131 | pat=pat_str, group_dim="XX", match_dim="YY", case=True |
| 1132 | ) |
| 1133 | |
| 1134 | assert res_str.dtype == expected.dtype |
| 1135 | assert res_re.dtype == expected.dtype |
| 1136 | assert res_str_case.dtype == expected.dtype |
| 1137 | |
| 1138 | assert_equal(res_str, expected) |
| 1139 | assert_equal(res_re, expected) |
| 1140 | assert_equal(res_str_case, expected) |
| 1141 | |
| 1142 | |
| 1143 | def test_extractall_multi_multi_nocase(dtype) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…