MCPcopy Index your code
hub / github.com/pydata/xarray / test_extractall_broadcast

Function test_extractall_broadcast

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

Source from the content-addressed store, hash-verified

1188
1189
1190def test_extractall_broadcast(dtype) -> None:
1191 value = xr.DataArray(
1192 ["a_Xy_0", "ab_xY_10", "abc_Xy_01"],
1193 dims=["X"],
1194 ).astype(dtype)
1195
1196 pat_str = xr.DataArray(
1197 [r"(\w+)_Xy_(\d*)", r"(\w+)_xY_(\d*)"],
1198 dims=["Y"],
1199 ).astype(dtype)
1200 pat_re = value.str._re_compile(pat=pat_str)
1201
1202 expected_list = [
1203 [[["a", "0"]], [["", ""]]],
1204 [[["", ""]], [["ab", "10"]]],
1205 [[["abc", "01"]], [["", ""]]],
1206 ]
1207 expected = xr.DataArray(expected_list, dims=["X", "Y", "ZX", "ZY"]).astype(dtype)
1208
1209 res_str = value.str.extractall(pat=pat_str, group_dim="ZX", match_dim="ZY")
1210 res_re = value.str.extractall(pat=pat_re, group_dim="ZX", match_dim="ZY")
1211
1212 assert res_str.dtype == expected.dtype
1213 assert res_re.dtype == expected.dtype
1214
1215 assert_equal(res_str, expected)
1216 assert_equal(res_re, expected)
1217
1218
1219def test_findall_single_single_case(dtype) -> None:

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
_re_compileMethod · 0.80
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…