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

Function test_cat_uniform

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

Source from the content-addressed store, hash-verified

3173
3174
3175def test_cat_uniform(dtype) -> None:
3176 values_1 = xr.DataArray(
3177 [["a", "bb", "cccc"], ["ddddd", "eeee", "fff"]],
3178 dims=["X", "Y"],
3179 ).astype(dtype)
3180 values_2 = xr.DataArray(
3181 [["11111", "222", "33"], ["4", "5555", "66"]],
3182 dims=["X", "Y"],
3183 )
3184
3185 targ_blank = xr.DataArray(
3186 [["a11111", "bb222", "cccc33"], ["ddddd4", "eeee5555", "fff66"]],
3187 dims=["X", "Y"],
3188 ).astype(dtype)
3189
3190 targ_space = xr.DataArray(
3191 [["a 11111", "bb 222", "cccc 33"], ["ddddd 4", "eeee 5555", "fff 66"]],
3192 dims=["X", "Y"],
3193 ).astype(dtype)
3194
3195 targ_bars = xr.DataArray(
3196 [["a||11111", "bb||222", "cccc||33"], ["ddddd||4", "eeee||5555", "fff||66"]],
3197 dims=["X", "Y"],
3198 ).astype(dtype)
3199
3200 targ_comma = xr.DataArray(
3201 [["a, 11111", "bb, 222", "cccc, 33"], ["ddddd, 4", "eeee, 5555", "fff, 66"]],
3202 dims=["X", "Y"],
3203 ).astype(dtype)
3204
3205 res_blank = values_1.str.cat(values_2)
3206 res_add = values_1.str + values_2
3207 res_space = values_1.str.cat(values_2, sep=" ")
3208 res_bars = values_1.str.cat(values_2, sep="||")
3209 res_comma = values_1.str.cat(values_2, sep=", ")
3210
3211 assert res_blank.dtype == targ_blank.dtype
3212 assert res_add.dtype == targ_blank.dtype
3213 assert res_space.dtype == targ_space.dtype
3214 assert res_bars.dtype == targ_bars.dtype
3215 assert res_comma.dtype == targ_comma.dtype
3216
3217 assert_equal(res_blank, targ_blank)
3218 assert_equal(res_add, targ_blank)
3219 assert_equal(res_space, targ_space)
3220 assert_equal(res_bars, targ_bars)
3221 assert_equal(res_comma, targ_comma)
3222
3223
3224def test_cat_broadcast_right(dtype) -> None:

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
catMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…