numpy  2.0.0
src/multiarray/common.h
Go to the documentation of this file.
00001 #ifndef _NPY_PRIVATE_COMMON_H_
00002 #define _NPY_PRIVATE_COMMON_H_
00003 
00004 #define error_converting(x)  (((x) == -1) && PyErr_Occurred())
00005 
00006 /*
00007  * Recursively examines the object to determine an appropriate dtype
00008  * to use for converting to an ndarray.
00009  *
00010  * 'obj' is the object to be converted to an ndarray.
00011  *
00012  * 'maxdims' is the maximum recursion depth.
00013  *
00014  * 'out_dtype' should be either NULL or a minimal starting dtype when
00015  * the function is called. It is updated with the results of type
00016  * promotion. This dtype does not get updated when processing NA objects.
00017  *
00018  * Returns 0 on success, -1 on failure.
00019  */
00020 NPY_NO_EXPORT int
00021 PyArray_DTypeFromObject(PyObject *obj, int maxdims,
00022                         PyArray_Descr **out_dtype);
00023 
00024 NPY_NO_EXPORT int
00025 PyArray_DTypeFromObjectHelper(PyObject *obj, int maxdims,
00026                               PyArray_Descr **out_dtype, int string_status);
00027 
00028 /*
00029  * Returns NULL without setting an exception if no scalar is matched, a
00030  * new dtype reference otherwise.
00031  */
00032 NPY_NO_EXPORT PyArray_Descr *
00033 _array_find_python_scalar_type(PyObject *op);
00034 
00035 NPY_NO_EXPORT PyArray_Descr *
00036 _array_typedescr_fromstr(char *str);
00037 
00038 /* 
00039  * Returns -1 and sets an exception if *index is an invalid index for
00040  * an array of size max_item, otherwise adjusts it in place to be
00041  * 0 <= *index < max_item, and returns 0.
00042  * 'axis' should be the array axis that is being indexed over, if known. If
00043  * unknown, use -1.
00044  */
00045 NPY_NO_EXPORT int
00046 check_and_adjust_index(npy_intp *index, npy_intp max_item, int axis);
00047 
00048 NPY_NO_EXPORT char *
00049 index2ptr(PyArrayObject *mp, npy_intp i);
00050 
00051 NPY_NO_EXPORT int
00052 _zerofill(PyArrayObject *ret);
00053 
00054 NPY_NO_EXPORT int
00055 _IsAligned(PyArrayObject *ap);
00056 
00057 NPY_NO_EXPORT npy_bool
00058 _IsWriteable(PyArrayObject *ap);
00059 
00060 #include "ucsnarrow.h"
00061 
00062 #endif