(dtype)
| 1354 | |
| 1355 | |
| 1356 | def test_findall_multi_single_case(dtype) -> None: |
| 1357 | pat_str = r"(\w+)_Xy_(\d*)" |
| 1358 | pat_re = re.compile(dtype(pat_str)) |
| 1359 | |
| 1360 | value = xr.DataArray( |
| 1361 | [["a_Xy_0", "ab_xY_10", "abc_Xy_01"], ["abcd_Xy_", "", "abcdef_Xy_101"]], |
| 1362 | dims=["X", "Y"], |
| 1363 | ).astype(dtype) |
| 1364 | |
| 1365 | expected_list: list[list[list[list]]] = [ |
| 1366 | [[["a", "0"]], [], [["abc", "01"]]], |
| 1367 | [[["abcd", ""]], [], [["abcdef", "101"]]], |
| 1368 | ] |
| 1369 | expected_dtype = [ |
| 1370 | [[tuple(dtype(x) for x in y) for y in z] for z in w] for w in expected_list |
| 1371 | ] |
| 1372 | expected_np = np.array(expected_dtype, dtype=np.object_) |
| 1373 | expected = xr.DataArray(expected_np, dims=["X", "Y"]) |
| 1374 | |
| 1375 | res_str = value.str.findall(pat=pat_str) |
| 1376 | res_re = value.str.findall(pat=pat_re) |
| 1377 | res_str_case = value.str.findall(pat=pat_str, case=True) |
| 1378 | |
| 1379 | assert res_str.dtype == expected.dtype |
| 1380 | assert res_re.dtype == expected.dtype |
| 1381 | assert res_str_case.dtype == expected.dtype |
| 1382 | |
| 1383 | assert_equal(res_str, expected) |
| 1384 | assert_equal(res_re, expected) |
| 1385 | assert_equal(res_str_case, expected) |
| 1386 | |
| 1387 | |
| 1388 | def test_findall_multi_single_nocase(dtype) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…