MCPcopy
hub / github.com/pydata/xarray / test_argmax_dim

Method test_argmax_dim

xarray/tests/test_dataarray.py:6741–6978  ·  view source on GitHub ↗
(
        self,
        x: np.ndarray,
        minindices_x: dict[str, np.ndarray],
        minindices_y: dict[str, np.ndarray],
        minindices_z: dict[str, np.ndarray],
        minindices_xy: dict[str, np.ndarray],
        minindices_xz: dict[str, np.ndarray],
        minindices_yz: dict[str, np.ndarray],
        minindices_xyz: dict[str, np.ndarray],
        maxindices_x: dict[str, np.ndarray],
        maxindices_y: dict[str, np.ndarray],
        maxindices_z: dict[str, np.ndarray],
        maxindices_xy: dict[str, np.ndarray],
        maxindices_xz: dict[str, np.ndarray],
        maxindices_yz: dict[str, np.ndarray],
        maxindices_xyz: dict[str, np.ndarray],
        nanindices_x: dict[str, np.ndarray],
        nanindices_y: dict[str, np.ndarray],
        nanindices_z: dict[str, np.ndarray],
        nanindices_xy: dict[str, np.ndarray],
        nanindices_xz: dict[str, np.ndarray],
        nanindices_yz: dict[str, np.ndarray],
        nanindices_xyz: dict[str, np.ndarray],
    )

Source from the content-addressed store, hash-verified

6739 assert_identical(result13[key], expected13[key])
6740
6741 def test_argmax_dim(
6742 self,
6743 x: np.ndarray,
6744 minindices_x: dict[str, np.ndarray],
6745 minindices_y: dict[str, np.ndarray],
6746 minindices_z: dict[str, np.ndarray],
6747 minindices_xy: dict[str, np.ndarray],
6748 minindices_xz: dict[str, np.ndarray],
6749 minindices_yz: dict[str, np.ndarray],
6750 minindices_xyz: dict[str, np.ndarray],
6751 maxindices_x: dict[str, np.ndarray],
6752 maxindices_y: dict[str, np.ndarray],
6753 maxindices_z: dict[str, np.ndarray],
6754 maxindices_xy: dict[str, np.ndarray],
6755 maxindices_xz: dict[str, np.ndarray],
6756 maxindices_yz: dict[str, np.ndarray],
6757 maxindices_xyz: dict[str, np.ndarray],
6758 nanindices_x: dict[str, np.ndarray],
6759 nanindices_y: dict[str, np.ndarray],
6760 nanindices_z: dict[str, np.ndarray],
6761 nanindices_xy: dict[str, np.ndarray],
6762 nanindices_xz: dict[str, np.ndarray],
6763 nanindices_yz: dict[str, np.ndarray],
6764 nanindices_xyz: dict[str, np.ndarray],
6765 ) -> None:
6766 ar = xr.DataArray(
6767 x,
6768 dims=["x", "y", "z"],
6769 coords={
6770 "x": np.arange(x.shape[0]) * 4,
6771 "y": 1 - np.arange(x.shape[1]),
6772 "z": 2 + 3 * np.arange(x.shape[2]),
6773 },
6774 attrs=self.attrs,
6775 )
6776
6777 for inds in [
6778 maxindices_x,
6779 maxindices_y,
6780 maxindices_z,
6781 maxindices_xy,
6782 maxindices_xz,
6783 maxindices_yz,
6784 maxindices_xyz,
6785 ]:
6786 if np.array([np.isnan(i) for i in inds.values()]).any():
6787 with pytest.raises(ValueError):
6788 ar.argmax(dim=list(inds))
6789 return
6790
6791 result0 = ar.argmax(dim=["x"])
6792 assert isinstance(result0, dict)
6793 expected0 = {
6794 key: xr.DataArray(value, dims=("y", "z"), attrs=self.attrs)
6795 for key, value in maxindices_x.items()
6796 }
6797 for key in expected0:
6798 assert_identical(result0[key].drop_vars(["y", "z"]), expected0[key])

Callers

nothing calls this directly

Calls 8

argmaxMethod · 0.95
assert_identicalFunction · 0.90
arangeMethod · 0.80
itemsMethod · 0.80
anyMethod · 0.45
valuesMethod · 0.45
drop_varsMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected