(dim_num, dtype, contains_nan, dask, func, skipna, aggdim)
| 683 | @pytest.mark.parametrize("skipna", [False, True]) |
| 684 | @pytest.mark.parametrize("aggdim", ["x", "y"]) |
| 685 | def 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 | |
| 715 | def test_argmin_max_error(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…