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

Method test_quantile

xarray/tests/test_dataarray.py:3199–3212  ·  view source on GitHub ↗
(self, q, axis, dim, skipna, compute_backend)

Source from the content-addressed store, hash-verified

3197 zip([None, 0, [0], [0, 1]], [None, "x", ["x"], ["x", "y"]], strict=True),
3198 )
3199 def test_quantile(self, q, axis, dim, skipna, compute_backend) -> None:
3200 va = self.va.copy(deep=True)
3201 va[0, 0] = np.nan
3202
3203 actual = DataArray(va).quantile(q, dim=dim, keep_attrs=True, skipna=skipna)
3204 _percentile_func = np.nanpercentile if skipna in (True, None) else np.percentile
3205 expected = _percentile_func(va.values, np.array(q) * 100, axis=axis)
3206 np.testing.assert_allclose(actual.values, expected)
3207 if is_scalar(q):
3208 assert "quantile" not in actual.dims
3209 else:
3210 assert "quantile" in actual.dims
3211
3212 assert actual.attrs == self.attrs
3213
3214 @pytest.mark.parametrize("method", ["midpoint", "lower"])
3215 def test_quantile_method(self, method) -> None:

Callers

nothing calls this directly

Calls 4

DataArrayClass · 0.90
is_scalarFunction · 0.90
copyMethod · 0.45
quantileMethod · 0.45

Tested by

no test coverage detected