MCPcopy
hub / github.com/pydata/xarray / test_extractall_single_multi_nocase

Function test_extractall_single_multi_nocase

xarray/tests/test_accessor_str.py:979–1023  ·  view source on GitHub ↗
(dtype)

Source from the content-addressed store, hash-verified

977
978
979def test_extractall_single_multi_nocase(dtype) -> None:
980 pat_str = r"(\w+)_Xy_\d*"
981 pat_re: str | bytes = (
982 pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8")
983 )
984 pat_compiled = re.compile(pat_re, flags=re.IGNORECASE)
985
986 value = xr.DataArray(
987 [
988 ["a_Xy_0", "ab_xY_10-bab_Xy_110-baab_Xy_1100", "abc_Xy_01-cbc_Xy_2210"],
989 [
990 "abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210",
991 "",
992 "abcdef_Xy_101-fef_Xy_5543210",
993 ],
994 ],
995 dims=["X", "Y"],
996 ).astype(dtype)
997
998 expected = xr.DataArray(
999 [
1000 [
1001 [["a"], [""], [""]],
1002 [["ab"], ["bab"], ["baab"]],
1003 [["abc"], ["cbc"], [""]],
1004 ],
1005 [
1006 [["abcd"], ["dcd"], ["dccd"]],
1007 [[""], [""], [""]],
1008 [["abcdef"], ["fef"], [""]],
1009 ],
1010 ],
1011 dims=["X", "Y", "XX", "YY"],
1012 ).astype(dtype)
1013
1014 res_str = value.str.extractall(
1015 pat=pat_str, group_dim="XX", match_dim="YY", case=False
1016 )
1017 res_re = value.str.extractall(pat=pat_compiled, group_dim="XX", match_dim="YY")
1018
1019 assert res_str.dtype == expected.dtype
1020 assert res_re.dtype == expected.dtype
1021
1022 assert_equal(res_str, expected)
1023 assert_equal(res_re, expected)
1024
1025
1026def test_extractall_multi_single_case(dtype) -> None:

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
extractallMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…