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

Function test_argmin_max

xarray/tests/test_duck_array_ops.py:685–712  ·  view source on GitHub ↗
(dim_num, dtype, contains_nan, dask, func, skipna, aggdim)

Source from the content-addressed store, hash-verified

683@pytest.mark.parametrize("skipna", [False, True])
684@pytest.mark.parametrize("aggdim", ["x", "y"])
685def test_argmin_max(dim_num, dtype, contains_nan, dask, func, skipna, aggdim):
686 # pandas-dev/pandas#16830, we do not check consistency with pandas but
687 # just make sure da[da.argmin()] == da.min()
688
689 if aggdim == "y" and dim_num < 2:
690 pytest.skip("dim not in this test")
691
692 if dask and not has_dask:
693 pytest.skip("requires dask")
694
695 if contains_nan:
696 if not skipna:
697 pytest.skip("numpy's argmin (not nanargmin) does not handle object-dtype")
698 if skipna and np.dtype(dtype).kind in "iufc":
699 pytest.skip("numpy's nanargmin raises ValueError for all nan axis")
700 da = construct_dataarray(dim_num, dtype, contains_nan=contains_nan, dask=dask)
701
702 with warnings.catch_warnings():
703 warnings.filterwarnings("ignore", "All-NaN slice")
704
705 actual = da.isel(
706 **{aggdim: getattr(da, "arg" + func)(dim=aggdim, skipna=skipna).compute()}
707 )
708 expected = getattr(da, func)(dim=aggdim, skipna=skipna)
709 assert_allclose(
710 actual.drop_vars(list(actual.coords)),
711 expected.drop_vars(list(expected.coords)),
712 )
713
714
715def test_argmin_max_error():

Callers

nothing calls this directly

Calls 6

assert_allcloseFunction · 0.90
construct_dataarrayFunction · 0.85
dtypeMethod · 0.45
iselMethod · 0.45
computeMethod · 0.45
drop_varsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…