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_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, npy_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 npy_intp PyArray_PyIntAsIntp (PyObject *o)
NPY_NO_EXPORT npy_intp PyArray_IntpFromIndexSequence (PyObject *seq, npy_intp *vals, npy_intp maxvals)
NPY_NO_EXPORT int PyArray_IntpFromSequence (PyObject *seq, npy_intp *vals, int maxvals)
NPY_NO_EXPORT int PyArray_TypestrConvert (int itemsize, int gentype)
NPY_NO_EXPORT PyObject * PyArray_IntTupleFromIntp (int len, npy_intp *vals)
NPY_NO_EXPORT int PyArray_SelectkindConverter (PyObject *obj, NPY_SELECTKIND *selectkind)
NPY_NO_EXPORT int PyArray_ConvertMultiAxis (PyObject *axis_in, int ndim, npy_bool *out_axis_flags)

Variables

NPY_NO_EXPORT int evil_global_disable_warn_O4O8_flag

Function Documentation

NPY_NO_EXPORT int PyArray_BoolConverter ( PyObject *  object,
npy_bool val 
)
Convert an object to true / false
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

References NPY_FAIL.

NPY_NO_EXPORT int PyArray_ByteorderConverter ( PyObject *  obj,
char *  endian 
)
Convert object to endian
NPY_NO_EXPORT int PyArray_ConvertMultiAxis ( PyObject *  axis_in,
int  ndim,
npy_bool out_axis_flags 
)
Converts an axis parameter into an ndim-length C-array of boolean flags, True for each axis specified.
If obj is None, everything is set to True. If obj is a tuple, each axis within the tuple is set to True. If obj is an integer, just that axis is set to True.
Converts an axis parameter into an ndim-length C-array of boolean flags, True for each axis specified.
If obj is None or NULL, everything is set to True. If obj is a tuple, each axis within the tuple is set to True. If obj is an integer, just that axis is set to True.
None means all of the axes
A tuple of which axes
Try to interpret axis as an integer
Special case letting axis={-1,0} slip through for scalars, for backwards compatibility reasons.
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 an integer number
After the deprecation the PyNumber_Check could be replaced by PyIndex_Check. FIXME 1.9 ?
NPY_NO_EXPORT npy_intp PyArray_IntpFromIndexSequence ( PyObject *  seq,
npy_intp vals,
npy_intp  maxvals 
)
PyArray_IntpFromIndexSequence Returns the number of dimensions or -1 if an error occurred. vals must be large enough to hold maxvals. Opposed to PyArray_IntpFromSequence it uses and returns npy_intp for the number of values.
Check to see if sequence is a single integer first. or, can be made into one

References NPY_BOOL, NPY_FLOAT16, NPY_FLOATINGLTR, NPY_GENBOOLLTR, NPY_SIGNEDLTR, and NPY_UNSIGNEDLTR.

NPY_NO_EXPORT int PyArray_IntpFromSequence ( PyObject *  seq,
npy_intp vals,
int  maxvals 
)
PyArray_IntpFromSequence
Returns the number of integers converted or -1 if an error occurred. vals must be large enough to hold maxvals
NPY_NO_EXPORT PyObject* PyArray_IntTupleFromIntp ( int  len,
npy_intp vals 
)
Lifted from numarray
TODO: not documented
PyArray_IntTupleFromIntp
NPY_NO_EXPORT int PyArray_PyIntAsInt ( PyObject *  o)
NPY_NO_EXPORT int PyArray_SearchsideConverter ( PyObject *  obj,
void *  addr 
)
Convert object to searchsorted side

References NPY_SUCCEED.

NPY_NO_EXPORT int PyArray_SelectkindConverter ( PyObject *  obj,
NPY_SELECTKIND selectkind 
)
Convert object to select kind

References NPY_FAIL, NPY_SEARCHLEFT, NPY_SEARCHRIGHT, NPY_SUCCEED, PyBytes_AsString, and side().

NPY_NO_EXPORT int PyArray_SortkindConverter ( PyObject *  obj,
NPY_SORTKIND sortkind 
)
Convert object to sort kind
NPY_NO_EXPORT int PyArray_TypestrConvert ( int  itemsize,
int  gentype 
)
Typestr converter
For 'O4' and 'O8', let it pass, but raise a deprecation warning. For all other cases, raise an exception by leaving newtype unset.
2012-02-04, 1.7, not sure when this can be removed

Variable Documentation

WARNING: This flag is a bad idea, but was the only way to both
  1. Support unpickling legacy pickles with object types.
  2. Deprecate (and later disable) usage of O4 and O8
The key problem is that the pickled representation unpickles by directly calling the dtype constructor, which has no way of knowing that it is in an unpickle context instead of a normal context without evil global state like we create here.