* 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. */
| 1777 | * an error and returns -1 if not. |
| 1778 | */ |
| 1779 | static 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 |
no test coverage detected