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

Function test_cat_broadcast_right

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

Source from the content-addressed store, hash-verified

3222
3223
3224def test_cat_broadcast_right(dtype) -> None:
3225 values_1 = xr.DataArray(
3226 [["a", "bb", "cccc"], ["ddddd", "eeee", "fff"]],
3227 dims=["X", "Y"],
3228 ).astype(dtype)
3229 values_2 = xr.DataArray(
3230 ["11111", "222", "33"],
3231 dims=["Y"],
3232 )
3233
3234 targ_blank = xr.DataArray(
3235 [["a11111", "bb222", "cccc33"], ["ddddd11111", "eeee222", "fff33"]],
3236 dims=["X", "Y"],
3237 ).astype(dtype)
3238
3239 targ_space = xr.DataArray(
3240 [["a 11111", "bb 222", "cccc 33"], ["ddddd 11111", "eeee 222", "fff 33"]],
3241 dims=["X", "Y"],
3242 ).astype(dtype)
3243
3244 targ_bars = xr.DataArray(
3245 [["a||11111", "bb||222", "cccc||33"], ["ddddd||11111", "eeee||222", "fff||33"]],
3246 dims=["X", "Y"],
3247 ).astype(dtype)
3248
3249 targ_comma = xr.DataArray(
3250 [["a, 11111", "bb, 222", "cccc, 33"], ["ddddd, 11111", "eeee, 222", "fff, 33"]],
3251 dims=["X", "Y"],
3252 ).astype(dtype)
3253
3254 res_blank = values_1.str.cat(values_2)
3255 res_add = values_1.str + values_2
3256 res_space = values_1.str.cat(values_2, sep=" ")
3257 res_bars = values_1.str.cat(values_2, sep="||")
3258 res_comma = values_1.str.cat(values_2, sep=", ")
3259
3260 assert res_blank.dtype == targ_blank.dtype
3261 assert res_add.dtype == targ_blank.dtype
3262 assert res_space.dtype == targ_space.dtype
3263 assert res_bars.dtype == targ_bars.dtype
3264 assert res_comma.dtype == targ_comma.dtype
3265
3266 assert_equal(res_blank, targ_blank)
3267 assert_equal(res_add, targ_blank)
3268 assert_equal(res_space, targ_space)
3269 assert_equal(res_bars, targ_bars)
3270 assert_equal(res_comma, targ_comma)
3271
3272
3273def test_cat_broadcast_left(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…