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

Function test_cat_broadcast_left

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

Source from the content-addressed store, hash-verified

3271
3272
3273def test_cat_broadcast_left(dtype) -> None:
3274 values_1 = xr.DataArray(
3275 ["a", "bb", "cccc"],
3276 dims=["Y"],
3277 ).astype(dtype)
3278 values_2 = xr.DataArray(
3279 [["11111", "222", "33"], ["4", "5555", "66"]],
3280 dims=["X", "Y"],
3281 )
3282
3283 targ_blank = (
3284 xr.DataArray(
3285 [["a11111", "bb222", "cccc33"], ["a4", "bb5555", "cccc66"]],
3286 dims=["X", "Y"],
3287 )
3288 .astype(dtype)
3289 .T
3290 )
3291
3292 targ_space = (
3293 xr.DataArray(
3294 [["a 11111", "bb 222", "cccc 33"], ["a 4", "bb 5555", "cccc 66"]],
3295 dims=["X", "Y"],
3296 )
3297 .astype(dtype)
3298 .T
3299 )
3300
3301 targ_bars = (
3302 xr.DataArray(
3303 [["a||11111", "bb||222", "cccc||33"], ["a||4", "bb||5555", "cccc||66"]],
3304 dims=["X", "Y"],
3305 )
3306 .astype(dtype)
3307 .T
3308 )
3309
3310 targ_comma = (
3311 xr.DataArray(
3312 [["a, 11111", "bb, 222", "cccc, 33"], ["a, 4", "bb, 5555", "cccc, 66"]],
3313 dims=["X", "Y"],
3314 )
3315 .astype(dtype)
3316 .T
3317 )
3318
3319 res_blank = values_1.str.cat(values_2)
3320 res_add = values_1.str + values_2
3321 res_space = values_1.str.cat(values_2, sep=" ")
3322 res_bars = values_1.str.cat(values_2, sep="||")
3323 res_comma = values_1.str.cat(values_2, sep=", ")
3324
3325 assert res_blank.dtype == targ_blank.dtype
3326 assert res_add.dtype == targ_blank.dtype
3327 assert res_space.dtype == targ_space.dtype
3328 assert res_bars.dtype == targ_bars.dtype
3329 assert res_comma.dtype == targ_comma.dtype
3330

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…