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

Function test_format_scalar

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

Source from the content-addressed store, hash-verified

3554
3555
3556def test_format_scalar() -> None:
3557 values = xr.DataArray(
3558 ["{}.{Y}.{ZZ}", "{},{},{X},{X}", "{X}-{Y}-{ZZ}"],
3559 dims=["X"],
3560 ).astype(np.str_)
3561
3562 pos0 = 1
3563 pos1 = 1.2
3564 pos2 = "2.3"
3565 X = "'test'"
3566 Y = "X"
3567 ZZ = None
3568 W = "NO!"
3569
3570 expected = xr.DataArray(
3571 ["1.X.None", "1,1.2,'test','test'", "'test'-X-None"],
3572 dims=["X"],
3573 ).astype(np.str_)
3574
3575 res = values.str.format(pos0, pos1, pos2, X=X, Y=Y, ZZ=ZZ, W=W)
3576
3577 assert res.dtype == expected.dtype
3578 assert_equal(res, expected)
3579
3580
3581def test_format_broadcast() -> 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…