MCPcopy Create free account
hub / github.com/numpy/numpy / _check_keepdims_support

Function _check_keepdims_support

numpy/core/src/umath/ufunc_object.c:1779–1800  ·  view source on GitHub ↗

* Check whether the gufunc can be used with keepdims, i.e., that all its * input arguments have the same number of core dimension, and all output * arguments have no core dimensions. Returns 0 if all is fine, and sets * an error and returns -1 if not. */

Source from the content-addressed store, hash-verified

1777 * an error and returns -1 if not.
1778 */
1779static int
1780_check_keepdims_support(PyUFuncObject *ufunc) {
1781 int i;
1782 int nin = ufunc->nin, nout = ufunc->nout;
1783 int input_core_dims = ufunc->core_num_dims[0];
1784 for (i = 1; i < nin + nout; i++) {
1785 if (ufunc->core_num_dims[i] != (i < nin ? input_core_dims : 0)) {
1786 PyErr_Format(PyExc_TypeError,
1787 "%s does not support keepdims: its signature %s requires "
1788 "%s %d to have %d core dimensions, but keepdims can only "
1789 "be used when all inputs have the same number of core "
1790 "dimensions and all outputs have no core dimensions.",
1791 ufunc_get_name_cstr(ufunc),
1792 ufunc->core_signature,
1793 i < nin ? "input" : "output",
1794 i < nin ? i : i - nin,
1795 ufunc->core_num_dims[i]);
1796 return -1;
1797 }
1798 }
1799 return 0;
1800}
1801
1802/*
1803 * Interpret a possible axes keyword argument, using it to fill the remap_axis

Callers 1

Calls 1

ufunc_get_name_cstrFunction · 0.85

Tested by

no test coverage detected