numpy 2.0.0
src/multiarray/conversion_utils.h File Reference

Go to the source code of this file.

Functions

NPY_NO_EXPORT int PyArray_Converter (PyObject *object, PyObject **address)
NPY_NO_EXPORT int PyArray_OutputConverter (PyObject *object, PyArrayObject **address)
NPY_NO_EXPORT int PyArray_IntpConverter (PyObject *obj, PyArray_Dims *seq)
NPY_NO_EXPORT int PyArray_BufferConverter (PyObject *obj, PyArray_Chunk *buf)
NPY_NO_EXPORT int PyArray_BoolConverter (PyObject *object, Bool *val)
NPY_NO_EXPORT int PyArray_ByteorderConverter (PyObject *obj, char *endian)
NPY_NO_EXPORT int PyArray_SortkindConverter (PyObject *obj, NPY_SORTKIND *sortkind)
NPY_NO_EXPORT int PyArray_SearchsideConverter (PyObject *obj, void *addr)
NPY_NO_EXPORT int PyArray_PyIntAsInt (PyObject *o)
NPY_NO_EXPORT intp PyArray_PyIntAsIntp (PyObject *o)
NPY_NO_EXPORT int PyArray_IntpFromSequence (PyObject *seq, intp *vals, int maxvals)
NPY_NO_EXPORT int PyArray_TypestrConvert (int itemsize, int gentype)
NPY_NO_EXPORT PyObject * PyArray_IntTupleFromIntp (int len, intp *vals)

Function Documentation

NPY_NO_EXPORT int PyArray_BoolConverter ( PyObject *  object,
Bool *  val 
)
Convert an object to true / false

Referenced by gentype_size_get().

NPY_NO_EXPORT int PyArray_BufferConverter ( PyObject *  obj,
PyArray_Chunk buf 
)
Get buffer chunk from object <blockquote>
this function takes a Python object which exposes the (single-segment) buffer interface and returns a pointer to the data segment
You should increment the reference count by one of buf->base if you will hang on to a reference
You only get a borrowed reference to the object. Do not free the memory... </blockquote>

Point to the base of the buffer object if present

NPY_NO_EXPORT int PyArray_ByteorderConverter ( PyObject *  obj,
char *  endian 
)
Convert object to endian

References PY_FAIL, PyArray_BIG, PyArray_IGNORE, PyArray_LITTLE, PyArray_NATIVE, and PyArray_SWAP.

NPY_NO_EXPORT int PyArray_Converter ( PyObject *  object,
PyObject **  address 
)

Useful function for conversion when used with PyArg_ParseTuple

System Message: WARNING/2 (<string>, line 1)
Title overline too short.

 Useful function for conversion when used with PyArg_ParseTuple
 
Useful to pass as converter function for O& processing in PyArgs_ParseTuple. <blockquote>
This conversion function can be used with the "O&" argument for PyArg_ParseTuple. It will immediately return an object of array type or will convert to a CARRAY any other object.
If you use PyArray_Converter, you must DECREF the array when finished as you get a new reference to it. </blockquote>
NPY_NO_EXPORT int PyArray_IntpConverter ( PyObject *  obj,
PyArray_Dims seq 
)
Get intp chunk from sequence <blockquote>
This function takes a Python sequence object and allocates and fills in an intp array with the converted values.
Remember to free the pointer seq.ptr when done using PyDimMem_FREE(seq.ptr)** </blockquote>

Check to see if it is a number

Referenced by _strided_to_strided_subarray_broadcast_withrefs(), and array_empty().

NPY_NO_EXPORT int PyArray_IntpFromSequence ( PyObject *  seq,
npy_intp vals,
int  maxvals 
)
PyArray_IntpFromSequence
Returns the number of dimensions or -1 if an error occurred. vals must be large enough to hold maxvals

Check to see if sequence is a single integer first. or, can be made into one
Check wether there was an error - if the error was an overflow, raise a ValueError instead to be more helpful
Check wether there was an error - if the error was an overflow, raise a ValueError instead to be more helpful

NPY_NO_EXPORT PyObject* PyArray_IntTupleFromIntp ( int  len,
npy_intp vals 
)
Lifted from numarray
TODO: not documented
PyArray_IntTupleFromIntp
NPY_NO_EXPORT int PyArray_OutputConverter ( PyObject *  object,
PyArrayObject **  address 
)
Useful to pass as converter function for O& processing in
PyArgs_ParseTuple for output arrays

Referenced by array_sum().

NPY_NO_EXPORT int PyArray_PyIntAsInt ( PyObject *  o)

Other conversion functions

Referenced by _convert_from_tuple().

NPY_NO_EXPORT intp PyArray_PyIntAsIntp ( PyObject *  o)
NPY_NO_EXPORT int PyArray_SearchsideConverter ( PyObject *  obj,
void *  addr 
)
Convert object to searchsorted side

Referenced by array_argsort().

NPY_NO_EXPORT int PyArray_SortkindConverter ( PyObject *  obj,
NPY_SORTKIND sortkind 
)
Convert object to sort kind

References PyArray_HEAPSORT.

NPY_NO_EXPORT int PyArray_TypestrConvert ( int  itemsize,
int  gentype 
)
Typestr converter