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

Function PyArray_AxisConverter

numpy/core/src/multiarray/conversion_utils.c:323–346  ·  view source on GitHub ↗

NUMPY_API * Get axis from an object (possibly None) -- a converter function, * * See also PyArray_ConvertMultiAxis, which also handles a tuple of axes. */

Source from the content-addressed store, hash-verified

321 * See also PyArray_ConvertMultiAxis, which also handles a tuple of axes.
322 */
323NPY_NO_EXPORT int
324PyArray_AxisConverter(PyObject *obj, int *axis)
325{
326 if (obj == Py_None) {
327 *axis = NPY_MAXDIMS;
328 }
329 else {
330 *axis = PyArray_PyIntAsInt_ErrMsg(obj,
331 "an integer is required for the axis");
332 if (error_converting(*axis)) {
333 return NPY_FAIL;
334 }
335 if (*axis == NPY_MAXDIMS){
336 /* NumPy 1.23, 2022-05-19 */
337 if (DEPRECATE("Using `axis=32` (MAXDIMS) is deprecated. "
338 "32/MAXDIMS had the same meaning as `axis=None` which "
339 "should be used instead. "
340 "(Deprecated NumPy 1.23)") < 0) {
341 return NPY_FAIL;
342 }
343 }
344 }
345 return NPY_SUCCEED;
346}
347
348/*
349 * Converts an axis parameter into an ndim-length C-array of

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected