(dtype)
| 1141 | |
| 1142 | |
| 1143 | def test_extractall_multi_multi_nocase(dtype) -> None: |
| 1144 | pat_str = r"(\w+)_Xy_(\d*)" |
| 1145 | pat_re: str | bytes = ( |
| 1146 | pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8") |
| 1147 | ) |
| 1148 | pat_compiled = re.compile(pat_re, flags=re.IGNORECASE) |
| 1149 | |
| 1150 | value = xr.DataArray( |
| 1151 | [ |
| 1152 | ["a_Xy_0", "ab_xY_10-bab_Xy_110-baab_Xy_1100", "abc_Xy_01-cbc_Xy_2210"], |
| 1153 | [ |
| 1154 | "abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210", |
| 1155 | "", |
| 1156 | "abcdef_Xy_101-fef_Xy_5543210", |
| 1157 | ], |
| 1158 | ], |
| 1159 | dims=["X", "Y"], |
| 1160 | ).astype(dtype) |
| 1161 | |
| 1162 | expected = xr.DataArray( |
| 1163 | [ |
| 1164 | [ |
| 1165 | [["a", "0"], ["", ""], ["", ""]], |
| 1166 | [["ab", "10"], ["bab", "110"], ["baab", "1100"]], |
| 1167 | [["abc", "01"], ["cbc", "2210"], ["", ""]], |
| 1168 | ], |
| 1169 | [ |
| 1170 | [["abcd", ""], ["dcd", "33210"], ["dccd", "332210"]], |
| 1171 | [["", ""], ["", ""], ["", ""]], |
| 1172 | [["abcdef", "101"], ["fef", "5543210"], ["", ""]], |
| 1173 | ], |
| 1174 | ], |
| 1175 | dims=["X", "Y", "XX", "YY"], |
| 1176 | ).astype(dtype) |
| 1177 | |
| 1178 | res_str = value.str.extractall( |
| 1179 | pat=pat_str, group_dim="XX", match_dim="YY", case=False |
| 1180 | ) |
| 1181 | res_re = value.str.extractall(pat=pat_compiled, group_dim="XX", match_dim="YY") |
| 1182 | |
| 1183 | assert res_str.dtype == expected.dtype |
| 1184 | assert res_re.dtype == expected.dtype |
| 1185 | |
| 1186 | assert_equal(res_str, expected) |
| 1187 | assert_equal(res_re, expected) |
| 1188 | |
| 1189 | |
| 1190 | def test_extractall_broadcast(dtype) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…