(dtype)
| 804 | |
| 805 | |
| 806 | def test_extract_multi_nocase(dtype) -> None: |
| 807 | pat_str = r"(\w+)_Xy_(\d*)" |
| 808 | pat_re: str | bytes = ( |
| 809 | pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8") |
| 810 | ) |
| 811 | pat_compiled = re.compile(pat_re, flags=re.IGNORECASE) |
| 812 | |
| 813 | value = xr.DataArray( |
| 814 | [ |
| 815 | ["a_Xy_0", "ab_xY_10-bab_Xy_110-baab_Xy_1100", "abc_Xy_01-cbc_Xy_2210"], |
| 816 | [ |
| 817 | "abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210", |
| 818 | "", |
| 819 | "abcdef_Xy_101-fef_Xy_5543210", |
| 820 | ], |
| 821 | ], |
| 822 | dims=["X", "Y"], |
| 823 | ).astype(dtype) |
| 824 | |
| 825 | expected = xr.DataArray( |
| 826 | [ |
| 827 | [["a", "0"], ["ab", "10"], ["abc", "01"]], |
| 828 | [["abcd", ""], ["", ""], ["abcdef", "101"]], |
| 829 | ], |
| 830 | dims=["X", "Y", "XX"], |
| 831 | ).astype(dtype) |
| 832 | |
| 833 | res_str = value.str.extract(pat=pat_str, dim="XX", case=False) |
| 834 | res_re = value.str.extract(pat=pat_compiled, dim="XX") |
| 835 | |
| 836 | assert res_str.dtype == expected.dtype |
| 837 | assert res_re.dtype == expected.dtype |
| 838 | |
| 839 | assert_equal(res_str, expected) |
| 840 | assert_equal(res_re, expected) |
| 841 | |
| 842 | |
| 843 | def test_extract_broadcast(dtype) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…