(dtype)
| 1271 | |
| 1272 | |
| 1273 | def test_findall_single_multi_case(dtype) -> None: |
| 1274 | pat_str = r"(\w+)_Xy_\d*" |
| 1275 | pat_re = re.compile(dtype(pat_str)) |
| 1276 | |
| 1277 | value = xr.DataArray( |
| 1278 | [ |
| 1279 | ["a_Xy_0", "ab_xY_10-bab_Xy_110-baab_Xy_1100", "abc_Xy_01-cbc_Xy_2210"], |
| 1280 | [ |
| 1281 | "abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210", |
| 1282 | "", |
| 1283 | "abcdef_Xy_101-fef_Xy_5543210", |
| 1284 | ], |
| 1285 | ], |
| 1286 | dims=["X", "Y"], |
| 1287 | ).astype(dtype) |
| 1288 | |
| 1289 | expected_list: list[list[list]] = [ |
| 1290 | [["a"], ["bab", "baab"], ["abc", "cbc"]], |
| 1291 | [ |
| 1292 | ["abcd", "dcd", "dccd"], |
| 1293 | [], |
| 1294 | ["abcdef", "fef"], |
| 1295 | ], |
| 1296 | ] |
| 1297 | expected_dtype = [[[dtype(x) for x in y] for y in z] for z in expected_list] |
| 1298 | expected_np = np.array(expected_dtype, dtype=np.object_) |
| 1299 | expected = xr.DataArray(expected_np, dims=["X", "Y"]) |
| 1300 | |
| 1301 | res_str = value.str.findall(pat=pat_str) |
| 1302 | res_re = value.str.findall(pat=pat_re) |
| 1303 | res_str_case = value.str.findall(pat=pat_str, case=True) |
| 1304 | |
| 1305 | assert res_str.dtype == expected.dtype |
| 1306 | assert res_re.dtype == expected.dtype |
| 1307 | assert res_str_case.dtype == expected.dtype |
| 1308 | |
| 1309 | assert_equal(res_str, expected) |
| 1310 | assert_equal(res_re, expected) |
| 1311 | assert_equal(res_str_case, expected) |
| 1312 | |
| 1313 | |
| 1314 | def test_findall_single_multi_nocase(dtype) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…