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

Function test_get_dummies_broadcast

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

Source from the content-addressed store, hash-verified

3014
3015
3016def test_get_dummies_broadcast(dtype) -> None:
3017 values = xr.DataArray(
3018 ["x~x|x~x", "x", "x|x~x", "x~x"],
3019 dims=["X"],
3020 ).astype(dtype)
3021
3022 sep = xr.DataArray(
3023 ["|", "~"],
3024 dims=["Y"],
3025 ).astype(dtype)
3026
3027 expected_list = [
3028 [[False, False, True], [True, True, False]],
3029 [[True, False, False], [True, False, False]],
3030 [[True, False, True], [True, True, False]],
3031 [[False, False, True], [True, False, False]],
3032 ]
3033 expected_np = np.array(expected_list)
3034 expected = xr.DataArray(expected_np, dims=["X", "Y", "ZZ"])
3035 expected.coords["ZZ"] = np.array(["x", "x|x", "x~x"]).astype(dtype)
3036
3037 res = values.str.get_dummies(dim="ZZ", sep=sep)
3038
3039 assert res.dtype == expected.dtype
3040
3041 assert_equal(res, expected)
3042
3043
3044def test_get_dummies_empty(dtype) -> None:

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
get_dummiesMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…