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

Function test_clip

xarray/tests/test_variable.py:3060–3081  ·  view source on GitHub ↗
(var)

Source from the content-addressed store, hash-verified

3058
3059
3060def test_clip(var):
3061 # Copied from test_dataarray (would there be a way to combine the tests?)
3062 result = var.clip(min=0.5)
3063 assert result.min(...) >= 0.5
3064
3065 result = var.clip(max=0.5)
3066 assert result.max(...) <= 0.5
3067
3068 result = var.clip(min=0.25, max=0.75)
3069 assert result.min(...) >= 0.25
3070 assert result.max(...) <= 0.75
3071
3072 result = var.clip(min=var.mean("x"), max=var.mean("z"))
3073 assert result.dims == var.dims
3074 assert_array_equal(
3075 result.data,
3076 np.clip(
3077 var.data,
3078 var.mean("x").data[np.newaxis, :, :],
3079 var.mean("z").data[:, :, np.newaxis],
3080 ),
3081 )
3082
3083
3084@pytest.mark.parametrize("Var", [Variable, IndexVariable])

Callers

nothing calls this directly

Calls 4

clipMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…