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

Function test_extractall_multi_single_nocase

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

Source from the content-addressed store, hash-verified

1059
1060
1061def test_extractall_multi_single_nocase(dtype) -> None:
1062 pat_str = r"(\w+)_Xy_(\d*)"
1063 pat_re: str | bytes = (
1064 pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8")
1065 )
1066 pat_compiled = re.compile(pat_re, flags=re.IGNORECASE)
1067
1068 value = xr.DataArray(
1069 [["a_Xy_0", "ab_xY_10", "abc_Xy_01"], ["abcd_Xy_", "", "abcdef_Xy_101"]],
1070 dims=["X", "Y"],
1071 ).astype(dtype)
1072
1073 expected = xr.DataArray(
1074 [
1075 [[["a", "0"]], [["ab", "10"]], [["abc", "01"]]],
1076 [[["abcd", ""]], [["", ""]], [["abcdef", "101"]]],
1077 ],
1078 dims=["X", "Y", "XX", "YY"],
1079 ).astype(dtype)
1080
1081 res_str = value.str.extractall(
1082 pat=pat_str, group_dim="XX", match_dim="YY", case=False
1083 )
1084 res_re = value.str.extractall(pat=pat_compiled, group_dim="XX", match_dim="YY")
1085
1086 assert res_str.dtype == expected.dtype
1087 assert res_re.dtype == expected.dtype
1088
1089 assert_equal(res_str, expected)
1090 assert_equal(res_re, expected)
1091
1092
1093def test_extractall_multi_multi_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…