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

Function test_format_broadcast

xarray/tests/test_accessor_str.py:3581–3612  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3579
3580
3581def test_format_broadcast() -> None:
3582 values = xr.DataArray(
3583 ["{}.{Y}.{ZZ}", "{},{},{X},{X}", "{X}-{Y}-{ZZ}"],
3584 dims=["X"],
3585 ).astype(np.str_)
3586
3587 pos0 = 1
3588 pos1 = 1.2
3589
3590 pos2 = xr.DataArray(
3591 ["2.3", "3.44444"],
3592 dims=["YY"],
3593 )
3594
3595 X = "'test'"
3596 Y = "X"
3597 ZZ = None
3598 W = "NO!"
3599
3600 expected = xr.DataArray(
3601 [
3602 ["1.X.None", "1.X.None"],
3603 ["1,1.2,'test','test'", "1,1.2,'test','test'"],
3604 ["'test'-X-None", "'test'-X-None"],
3605 ],
3606 dims=["X", "YY"],
3607 ).astype(np.str_)
3608
3609 res = values.str.format(pos0, pos1, pos2, X=X, Y=Y, ZZ=ZZ, W=W)
3610
3611 assert res.dtype == expected.dtype
3612 assert_equal(res, expected)
3613
3614
3615def test_mod_scalar() -> None:

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
astypeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…