Multiarray API
Multiarray API
Multiarray API
NumPy C-API
===========
::
unsigned int
PyArray_GetNDArrayCVersion(void )
Included at the very first so not auto-grabbed and thus not labeled.
::
int
PyArray_SetNumericOps(PyObject *dict)
Set internal structure with number functions that all arrays will use
::
PyObject *
PyArray_GetNumericOps(void )
Get dictionary showing number functions that all arrays will use
::
int
PyArray_INCREF(PyArrayObject *mp)
::
int
PyArray_XDECREF(PyArrayObject *mp)
::
void
PyArray_SetStringFunction(PyObject *op, int repr)
::
PyArray_Descr *
PyArray_DescrFromType(int type)
::
PyObject *
PyArray_TypeObjectFromType(int type)
Get a typeobject from a type-number -- can return NULL.
New reference
::
char *
PyArray_Zero(PyArrayObject *arr)
::
char *
PyArray_One(PyArrayObject *arr)
::
PyObject *
PyArray_CastToType(PyArrayObject *arr, PyArray_Descr *dtype, int
is_f_order)
::
int
PyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)
::
int
PyArray_CastAnyTo(PyArrayObject *out, PyArrayObject *mp)
::
int
PyArray_CanCastSafely(int fromtype, int totype)
::
npy_bool
PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)
leaves reference count alone --- cannot be NULL
::
int
PyArray_ObjectType(PyObject *op, int minimum_type)
Returns the type number the result should have, or NPY_NOTYPE on error.
::
PyArray_Descr *
PyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)
::
PyArrayObject **
PyArray_ConvertToCommonType(PyObject *op, int *retn)
This function is only used in one place within NumPy and should
generally be avoided. It is provided mainly for backward compatibility.
::
PyArray_Descr *
PyArray_DescrFromScalar(PyObject *sc)
New reference
::
PyArray_Descr *
PyArray_DescrFromTypeObject(PyObject *type)
::
npy_intp
PyArray_Size(PyObject *op)
::
PyObject *
PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
Get scalar-equivalent to a region of memory described by a descriptor.
::
PyObject *
PyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode)
::
void
PyArray_ScalarAsCtype(PyObject *scalar, void *ctypeptr)
Convert to c-type
::
int
PyArray_CastScalarToCtype(PyObject *scalar, void
*ctypeptr, PyArray_Descr *outcode)
This may not work right on narrow builds for NumPy unicode scalars.
::
int
PyArray_CastScalarDirect(PyObject *scalar, PyArray_Descr
*indescr, void *ctypeptr, int outtype)
::
PyObject *
PyArray_ScalarFromObject(PyObject *object)
Returns NULL if unsuccessful but error is only set if another error occurred.
Currently only Numeric-like object supported.
::
PyArray_VectorUnaryFunc *
PyArray_GetCastFunc(PyArray_Descr *descr, int type_num)
::
PyObject *
PyArray_FromDims(int NPY_UNUSED(nd) , int *NPY_UNUSED(d) , int
NPY_UNUSED(type) )
::
PyObject *
PyArray_FromDimsAndDataAndDescr(int NPY_UNUSED(nd) , int
*NPY_UNUSED(d) , PyArray_Descr
*descr, char *NPY_UNUSED(data) )
::
PyObject *
PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int
min_depth, int max_depth, int flags, PyObject
*context)
::
PyObject *
PyArray_EnsureArray(PyObject *op)
::
PyObject *
PyArray_EnsureAnyArray(PyObject *op)
::
PyObject *
PyArray_FromFile(FILE *fp, PyArray_Descr *dtype, npy_intp num, char
*sep)
For memory-mapped files, use the buffer interface. No more data than
necessary is read by this routine.
::
PyObject *
PyArray_FromString(char *data, npy_intp slen, PyArray_Descr
*dtype, npy_intp num, char *sep)
If ``slen`` is < 0, then the end of string is used for text data.
It is an error for ``slen`` to be < 0 for binary data (since embedded NULLs
would be the norm).
::
PyObject *
PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, npy_intp
count, npy_intp offset)
::
PyObject *
PyArray_FromIter(PyObject *obj, PyArray_Descr *dtype, npy_intp count)
steals a reference to dtype (which cannot be NULL)
::
PyObject *
PyArray_Return(PyArrayObject *mp)
::
PyObject *
PyArray_GetField(PyArrayObject *self, PyArray_Descr *typed, int
offset)
::
int
PyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype, int
offset, PyObject *val)
::
PyObject *
PyArray_Byteswap(PyArrayObject *self, npy_bool inplace)
::
PyObject *
PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int
refcheck, NPY_ORDER NPY_UNUSED(order) )
::
int
PyArray_MoveInto(PyArrayObject *dst, PyArrayObject *src)
Move the memory of one array into another, allowing for overlapping data.
::
int
PyArray_CopyInto(PyArrayObject *dst, PyArrayObject *src)
::
int
PyArray_CopyAnyInto(PyArrayObject *dst, PyArrayObject *src)
TODO: For NumPy 2.0, this could accept an order parameter which
only allows NPY_CORDER and NPY_FORDER. Could also rename
this to CopyAsFlat to make the name more intuitive.
::
int
PyArray_CopyObject(PyArrayObject *dest, PyObject *src_object)
::
PyObject *
PyArray_NewCopy(PyArrayObject *obj, NPY_ORDER order)
Copy an array.
::
PyObject *
PyArray_ToList(PyArrayObject *self)
To List
::
PyObject *
PyArray_ToString(PyArrayObject *self, NPY_ORDER order)
::
int
PyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format)
To File
::
int
PyArray_Dump(PyObject *self, PyObject *file, int protocol)
::
PyObject *
PyArray_Dumps(PyObject *self, int protocol)
::
int
PyArray_ValidType(int type)
::
void
PyArray_UpdateFlags(PyArrayObject *ret, int flagmask)
::
PyObject *
PyArray_New(PyTypeObject *subtype, int nd, npy_intp const *dims, int
type_num, npy_intp const *strides, void *data, int
itemsize, int flags, PyObject *obj)
::
PyObject *
PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int
nd, npy_intp const *dims, npy_intp const
*strides, void *data, int flags, PyObject *obj)
::
PyArray_Descr *
PyArray_DescrNew(PyArray_Descr *base)
::
PyArray_Descr *
PyArray_DescrNewFromType(int type_num)
::
double
PyArray_GetPriority(PyObject *obj, double default_)
::
PyObject *
PyArray_IterNew(PyObject *obj)
Get Iterator.
::
PyObject*
PyArray_MultiIterNew(int n, ... )
Get MultiIterator,
::
int
PyArray_PyIntAsInt(PyObject *o)
::
npy_intp
PyArray_PyIntAsIntp(PyObject *o)
::
int
PyArray_Broadcast(PyArrayMultiIterObject *mit)
::
void
PyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)
Assumes contiguous
::
int
PyArray_FillWithScalar(PyArrayObject *arr, PyObject *obj)
::
npy_bool
PyArray_CheckStrides(int elsize, int nd, npy_intp numbytes, npy_intp
offset, npy_intp const *dims, npy_intp const
*newstrides)
::
PyArray_Descr *
PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)
::
PyObject *
PyArray_IterAllButAxis(PyObject *obj, int *inaxis)
Get Iterator that iterates over all but one axis (don't use this with
PyArray_ITER_GOTO1D). The axis will be over-written if negative
with the axis having the smallest stride.
::
PyObject *
PyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int
min_depth, int max_depth, int requires, PyObject
*context)
::
PyObject *
PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int
flags)
::
PyObject *
PyArray_FromInterface(PyObject *origin)
::
PyObject *
PyArray_FromStructInterface(PyObject *input)
::
PyObject *
PyArray_FromArrayAttr(PyObject *op, PyArray_Descr *typecode, PyObject
*context)
::
NPY_SCALARKIND
PyArray_ScalarKind(int typenum, PyArrayObject **arr)
ScalarKind
::
int
PyArray_CanCoerceScalar(int thistype, int neededtype, NPY_SCALARKIND
scalar)
::
PyObject *
PyArray_NewFlagsObject(PyObject *obj)
::
npy_bool
PyArray_CanCastScalar(PyTypeObject *from, PyTypeObject *to)
::
int
PyArray_CompareUCS4(npy_ucs4 const *s1, npy_ucs4 const *s2, size_t
len)
::
int
PyArray_RemoveSmallest(PyArrayMultiIterObject *multi)
Adjusts previously broadcasted iterators so that the axis with
the smallest sum of iterator strides is not iterated over.
Returns dimension which is smallest in the range [0,multi->nd).
A -1 is returned if multi->nd == 0.
::
int
PyArray_ElementStrides(PyObject *obj)
::
void
PyArray_Item_INCREF(char *data, PyArray_Descr *descr)
::
void
PyArray_Item_XDECREF(char *data, PyArray_Descr *descr)
::
PyObject *
PyArray_FieldNames(PyObject *fields)
::
PyObject *
PyArray_Transpose(PyArrayObject *ap, PyArray_Dims *permute)
Return Transpose.
::
PyObject *
PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int
axis, PyArrayObject *out, NPY_CLIPMODE clipmode)
Take
::
PyObject *
PyArray_PutTo(PyArrayObject *self, PyObject*values0, PyObject
*indices0, NPY_CLIPMODE clipmode)
::
PyObject *
PyArray_PutMask(PyArrayObject *self, PyObject*values0, PyObject*mask0)
::
PyObject *
PyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis)
::
PyObject *
PyArray_Choose(PyArrayObject *ip, PyObject *op, PyArrayObject
*out, NPY_CLIPMODE clipmode)
::
int
PyArray_Sort(PyArrayObject *op, int axis, NPY_SORTKIND which)
::
PyObject *
PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)
ArgSort an array
::
PyObject *
PyArray_SearchSorted(PyArrayObject *op1, PyObject *op2, NPY_SEARCHSIDE
side, PyObject *perm)
Search the sorted array op1 for the location of the items in op2. The
result is an array of indexes, one for each element in op2, such that if
the item were to be inserted in op1 just before that index the array
would still be in sorted order.
Parameters
----------
op1 : PyArrayObject *
Array to be searched, must be 1-D.
op2 : PyObject *
Array of items whose insertion indexes in op1 are wanted
side : {NPY_SEARCHLEFT, NPY_SEARCHRIGHT}
If NPY_SEARCHLEFT, return first valid insertion indexes
If NPY_SEARCHRIGHT, return last valid insertion indexes
perm : PyObject *
Permutation array that sorts op1 (optional)
Returns
-------
ret : PyObject *
New reference to npy_intp array containing indexes where items in op2
could be validly inserted into op1. NULL on error.
Notes
-----
Binary search is used to find the indexes.
::
PyObject *
PyArray_ArgMax(PyArrayObject *op, int axis, PyArrayObject *out)
ArgMax
::
PyObject *
PyArray_ArgMin(PyArrayObject *op, int axis, PyArrayObject *out)
ArgMin
::
PyObject *
PyArray_Reshape(PyArrayObject *self, PyObject *shape)
Reshape
::
PyObject *
PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims, NPY_ORDER
order)
::
PyObject *
PyArray_Squeeze(PyArrayObject *self)
return a new view of the array object with all of its unit-length
dimensions squeezed out if needed, otherwise
return the same array.
::
PyObject *
PyArray_View(PyArrayObject *self, PyArray_Descr *type, PyTypeObject
*pytype)
View
steals a reference to type -- accepts NULL
::
PyObject *
PyArray_SwapAxes(PyArrayObject *ap, int a1, int a2)
SwapAxes
::
PyObject *
PyArray_Max(PyArrayObject *ap, int axis, PyArrayObject *out)
Max
::
PyObject *
PyArray_Min(PyArrayObject *ap, int axis, PyArrayObject *out)
Min
::
PyObject *
PyArray_Ptp(PyArrayObject *ap, int axis, PyArrayObject *out)
Ptp
::
PyObject *
PyArray_Mean(PyArrayObject *self, int axis, int rtype, PyArrayObject
*out)
Mean
::
PyObject *
PyArray_Trace(PyArrayObject *self, int offset, int axis1, int
axis2, int rtype, PyArrayObject *out)
Trace
::
PyObject *
PyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int
axis2)
Diagonal
::
PyObject *
PyArray_Clip(PyArrayObject *self, PyObject *min, PyObject
*max, PyArrayObject *out)
Clip
::
PyObject *
PyArray_Conjugate(PyArrayObject *self, PyArrayObject *out)
Conjugate
::
PyObject *
PyArray_Nonzero(PyArrayObject *self)
Nonzero
::
PyObject *
PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject
*out, int variance)
::
PyObject *
PyArray_Sum(PyArrayObject *self, int axis, int rtype, PyArrayObject
*out)
Sum
::
PyObject *
PyArray_CumSum(PyArrayObject *self, int axis, int rtype, PyArrayObject
*out)
CumSum
::
PyObject *
PyArray_Prod(PyArrayObject *self, int axis, int rtype, PyArrayObject
*out)
Prod
::
PyObject *
PyArray_CumProd(PyArrayObject *self, int axis, int
rtype, PyArrayObject *out)
CumProd
::
PyObject *
PyArray_All(PyArrayObject *self, int axis, PyArrayObject *out)
All
::
PyObject *
PyArray_Any(PyArrayObject *self, int axis, PyArrayObject *out)
Any
::
PyObject *
PyArray_Compress(PyArrayObject *self, PyObject *condition, int
axis, PyArrayObject *out)
Compress
::
PyObject *
PyArray_Flatten(PyArrayObject *a, NPY_ORDER order)
Flatten
::
PyObject *
PyArray_Ravel(PyArrayObject *arr, NPY_ORDER order)
Ravel
Returns a contiguous array
::
npy_intp
PyArray_MultiplyList(npy_intp const *l1, int n)
Multiply a List
::
int
PyArray_MultiplyIntList(int const *l1, int n)
Multiply a List of ints
::
void *
PyArray_GetPtr(PyArrayObject *obj, npy_intp const*ind)
::
int
PyArray_CompareLists(npy_intp const *l1, npy_intp const *l2, int n)
Compare Lists
::
int
PyArray_AsCArray(PyObject **op, void *ptr, npy_intp *dims, int
nd, PyArray_Descr*typedescr)
Simulate a C-array
steals a reference to typedescr -- can be NULL
::
int
PyArray_As1D(PyObject **NPY_UNUSED(op) , char **NPY_UNUSED(ptr) , int
*NPY_UNUSED(d1) , int NPY_UNUSED(typecode) )
Convert to a 1D C-array
::
int
PyArray_As2D(PyObject **NPY_UNUSED(op) , char ***NPY_UNUSED(ptr) , int
*NPY_UNUSED(d1) , int *NPY_UNUSED(d2) , int
NPY_UNUSED(typecode) )
Convert to a 2D C-array
::
int
PyArray_Free(PyObject *op, void *ptr)
::
int
PyArray_Converter(PyObject *object, PyObject **address)
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 NPY_ARRAY_CARRAY any other object.
If you use PyArray_Converter, you must DECREF the array when finished
as you get a new reference to it.
::
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
::
PyObject *
PyArray_Concatenate(PyObject *op, int axis)
Concatenate
::
PyObject *
PyArray_InnerProduct(PyObject *op1, PyObject *op2)
Numeric.innerproduct(a,v)
::
PyObject *
PyArray_MatrixProduct(PyObject *op1, PyObject *op2)
Numeric.matrixproduct(a,v)
just like inner product but does the swapaxes stuff on the fly
::
PyObject *
PyArray_CopyAndTranspose(PyObject *op)
::
PyObject *
PyArray_Correlate(PyObject *op1, PyObject *op2, int mode)
Numeric.correlate(a1,a2,mode)
::
int
PyArray_TypestrConvert(int itemsize, int gentype)
Typestr converter
::
int
PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
::
int
PyArray_DescrConverter2(PyObject *obj, PyArray_Descr **at)
::
int
PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)
::
int
PyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)
::
int
PyArray_AxisConverter(PyObject *obj, int *axis)
::
int
PyArray_BoolConverter(PyObject *object, npy_bool *val)
::
int
PyArray_ByteorderConverter(PyObject *obj, char *endian)
::
int
PyArray_OrderConverter(PyObject *object, NPY_ORDER *val)
::
unsigned char
PyArray_EquivTypes(PyArray_Descr *type1, PyArray_Descr *type2)
::
PyObject *
PyArray_Zeros(int nd, npy_intp const *dims, PyArray_Descr *type, int
is_f_order)
Zeros
::
PyObject *
PyArray_Empty(int nd, npy_intp const *dims, PyArray_Descr *type, int
is_f_order)
Empty
::
PyObject *
PyArray_Where(PyObject *condition, PyObject *x, PyObject *y)
Where
::
PyObject *
PyArray_Arange(double start, double stop, double step, int type_num)
Arange,
::
PyObject *
PyArray_ArangeObj(PyObject *start, PyObject *stop, PyObject
*step, PyArray_Descr *dtype)
ArangeObj,
::
int
PyArray_SortkindConverter(PyObject *obj, NPY_SORTKIND *sortkind)
::
PyObject *
PyArray_LexSort(PyObject *sort_keys, int axis)
Returns an index array that shows the indexes for the lexicographic sort along
the given axis.
::
PyObject *
PyArray_Round(PyArrayObject *a, int decimals, PyArrayObject *out)
Round
::
unsigned char
PyArray_EquivTypenums(int typenum1, int typenum2)
::
int
PyArray_RegisterDataType(PyArray_Descr *descr)
::
int
PyArray_RegisterCastFunc(PyArray_Descr *descr, int
totype, PyArray_VectorUnaryFunc *castfunc)
::
int
PyArray_RegisterCanCast(PyArray_Descr *descr, int
totype, NPY_SCALARKIND scalar)
::
void
PyArray_InitArrFuncs(PyArray_ArrFuncs *f)
::
PyObject *
PyArray_IntTupleFromIntp(int len, npy_intp const *vals)
PyArray_IntTupleFromIntp
::
int
PyArray_TypeNumFromName(char const *str)
::
int
PyArray_ClipmodeConverter(PyObject *object, NPY_CLIPMODE *val)
::
int
PyArray_OutputConverter(PyObject *object, PyArrayObject **address)
::
PyObject *
PyArray_BroadcastToShape(PyObject *obj, npy_intp *dims, int nd)
::
void
_PyArray_SigintHandler(int signum)
::
void*
_PyArray_GetSigintBuf(void )
::
int
PyArray_DescrAlignConverter(PyObject *obj, PyArray_Descr **at)
any object with the .fields attribute and/or .itemsize attribute (if the
.fields attribute does not give the total size -- i.e. a partial record
naming). If itemsize is given it must be >= size computed from fields
::
int
PyArray_DescrAlignConverter2(PyObject *obj, PyArray_Descr **at)
::
int
PyArray_SearchsideConverter(PyObject *obj, void *addr)
::
PyObject *
PyArray_CheckAxis(PyArrayObject *arr, int *axis, int flags)
PyArray_CheckAxis
::
npy_intp
PyArray_OverflowMultiplyList(npy_intp const *l1, int n)
::
int
PyArray_CompareString(const char *s1, const char *s2, size_t len)
::
PyObject*
PyArray_MultiIterFromObjects(PyObject **mps, int n, int nadd, ... )
::
int
PyArray_GetEndianness(void )
::
unsigned int
PyArray_GetNDArrayCFeatureVersion(void )
::
PyObject *
PyArray_Correlate2(PyObject *op1, PyObject *op2, int mode)
correlate(a1,a2,mode)
::
PyObject*
PyArray_NeighborhoodIterNew(PyArrayIterObject *x, const npy_intp
*bounds, int mode, PyArrayObject*fill)
::
void
PyArray_SetDatetimeParseFunction(PyObject *NPY_UNUSED(op) )
::
void
PyArray_DatetimeToDatetimeStruct(npy_datetime NPY_UNUSED(val)
, NPY_DATETIMEUNIT NPY_UNUSED(fr)
, npy_datetimestruct *result)
Fill the datetime struct from the value and resolution unit.
::
void
PyArray_TimedeltaToTimedeltaStruct(npy_timedelta NPY_UNUSED(val)
, NPY_DATETIMEUNIT NPY_UNUSED(fr)
, npy_timedeltastruct *result)
Fill the timedelta struct from the timedelta value and resolution unit.
::
npy_datetime
PyArray_DatetimeStructToDatetime(NPY_DATETIMEUNIT NPY_UNUSED(fr)
, npy_datetimestruct *NPY_UNUSED(d) )
Create a datetime value from a filled datetime struct and resolution unit.
::
npy_datetime
PyArray_TimedeltaStructToTimedelta(NPY_DATETIMEUNIT NPY_UNUSED(fr)
, npy_timedeltastruct
*NPY_UNUSED(d) )
Create a timdelta value from a filled timedelta struct and resolution unit.
::
NpyIter *
NpyIter_New(PyArrayObject *op, npy_uint32 flags, NPY_ORDER
order, NPY_CASTING casting, PyArray_Descr*dtype)
::
NpyIter *
NpyIter_MultiNew(int nop, PyArrayObject **op_in, npy_uint32
flags, NPY_ORDER order, NPY_CASTING
casting, npy_uint32 *op_flags, PyArray_Descr
**op_request_dtypes)
Allocate a new iterator for more than one array object, using
standard NumPy broadcasting rules and the default buffer size.
::
NpyIter *
NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32
flags, NPY_ORDER order, NPY_CASTING
casting, npy_uint32 *op_flags, PyArray_Descr
**op_request_dtypes, int oa_ndim, int
**op_axes, npy_intp *itershape, npy_intp
buffersize)
::
NpyIter *
NpyIter_Copy(NpyIter *iter)
::
int
NpyIter_Deallocate(NpyIter *iter)
Deallocate an iterator.
::
npy_bool
NpyIter_HasDelayedBufAlloc(NpyIter *iter)
::
npy_bool
NpyIter_HasExternalLoop(NpyIter *iter)
::
int
NpyIter_EnableExternalLoop(NpyIter *iter)
::
npy_intp *
NpyIter_GetInnerStrideArray(NpyIter *iter)
Get the array of strides for the inner loop (when HasExternalLoop is true)
This function may be safely called without holding the Python GIL.
::
npy_intp *
NpyIter_GetInnerLoopSizePtr(NpyIter *iter)
Get a pointer to the size of the inner loop (when HasExternalLoop is true)
This function may be safely called without holding the Python GIL.
::
int
NpyIter_Reset(NpyIter *iter, char **errmsg)
::
int
NpyIter_ResetBasePointers(NpyIter *iter, char **baseptrs, char
**errmsg)
Resets the iterator to its initial state, with new base data pointers.
This function requires great caution.
::
int
NpyIter_ResetToIterIndexRange(NpyIter *iter, npy_intp istart, npy_intp
iend, char **errmsg)
::
int
NpyIter_GetNDim(NpyIter *iter)
::
int
NpyIter_GetNOp(NpyIter *iter)
::
NpyIter_IterNextFunc *
NpyIter_GetIterNext(NpyIter *iter, char **errmsg)
::
npy_intp
NpyIter_GetIterSize(NpyIter *iter)
::
void
NpyIter_GetIterIndexRange(NpyIter *iter, npy_intp *istart, npy_intp
*iend)
::
npy_intp
NpyIter_GetIterIndex(NpyIter *iter)
::
int
NpyIter_GotoIterIndex(NpyIter *iter, npy_intp iterindex)
::
npy_bool
NpyIter_HasMultiIndex(NpyIter *iter)
::
int
NpyIter_GetShape(NpyIter *iter, npy_intp *outshape)
::
NpyIter_GetMultiIndexFunc *
NpyIter_GetGetMultiIndex(NpyIter *iter, char **errmsg)
::
int
NpyIter_GotoMultiIndex(NpyIter *iter, npy_intp const *multi_index)
Sets the iterator to the specified multi-index, which must have the
correct number of entries for 'ndim'. It is only valid
when NPY_ITER_MULTI_INDEX was passed to the constructor. This operation
fails if the multi-index is out of bounds.
::
int
NpyIter_RemoveMultiIndex(NpyIter *iter)
::
npy_bool
NpyIter_HasIndex(NpyIter *iter)
::
npy_bool
NpyIter_IsBuffered(NpyIter *iter)
::
npy_bool
NpyIter_IsGrowInner(NpyIter *iter)
::
npy_intp
NpyIter_GetBufferSize(NpyIter *iter)
::
npy_intp *
NpyIter_GetIndexPtr(NpyIter *iter)
::
int
NpyIter_GotoIndex(NpyIter *iter, npy_intp flat_index)
char **
NpyIter_GetDataPtrArray(NpyIter *iter)
This function may be safely called without holding the Python GIL.
::
PyArray_Descr **
NpyIter_GetDescrArray(NpyIter *iter)
Get the array of data type pointers (1 per object being iterated)
::
PyArrayObject **
NpyIter_GetOperandArray(NpyIter *iter)
::
PyArrayObject *
NpyIter_GetIterView(NpyIter *iter, npy_intp i)
Returns a view to the i-th object with the iterator's internal axes
::
void
NpyIter_GetReadFlags(NpyIter *iter, char *outreadflags)
::
void
NpyIter_GetWriteFlags(NpyIter *iter, char *outwriteflags)
::
void
NpyIter_DebugPrint(NpyIter *iter)
For debugging
::
npy_bool
NpyIter_IterationNeedsAPI(NpyIter *iter)
void
NpyIter_GetInnerFixedStrideArray(NpyIter *iter, npy_intp *out_strides)
Get an array of strides which are fixed. Any strides which may
change during iteration receive the value NPY_MAX_INTP. Once
the iterator is ready to iterate, call this to get the strides
which will always be fixed in the inner loop, then choose optimized
inner loop functions which take advantage of those fixed strides.
This function may be safely called without holding the Python GIL.
::
int
NpyIter_RemoveAxis(NpyIter *iter, int axis)
::
npy_intp *
NpyIter_GetAxisStrideArray(NpyIter *iter, int axis)
::
npy_bool
NpyIter_RequiresBuffering(NpyIter *iter)
::
char **
NpyIter_GetInitialDataPtrArray(NpyIter *iter)
This function may be safely called without holding the Python GIL.
::
int
NpyIter_CreateCompatibleStrides(NpyIter *iter, npy_intp
itemsize, npy_intp *outstrides)
A use case for this function is to match the shape and layout of
the iterator and tack on one or more dimensions. For example,
in order to generate a vector per input value for a numerical gradient,
you pass in ndim*itemsize for itemsize, then add another dimension to
the end with size ndim and stride itemsize. To do the Hessian matrix,
you do the same thing but add two dimensions, or take advantage of
the symmetry and pack it into 1 dimension with a particular encoding.
::
int
PyArray_CastingConverter(PyObject *obj, NPY_CASTING *casting)
::
npy_intp
PyArray_CountNonzero(PyArrayObject *self)
Returns -1 on error.
::
PyArray_Descr *
PyArray_PromoteTypes(PyArray_Descr *type1, PyArray_Descr *type2)
Produces the smallest size and lowest kind type to which both
input types can be cast.
::
PyArray_Descr *
PyArray_MinScalarType(PyArrayObject *arr)
If arr is a scalar (has 0 dimensions) with a built-in number data type,
finds the smallest type size/kind which can still represent its data.
Otherwise, returns the array's data type.
::
PyArray_Descr *
PyArray_ResultType(npy_intp narrs, PyArrayObject *arrs[] , npy_intp
ndtypes, PyArray_Descr *descrs[] )
Produces the result type of a bunch of inputs, using the same rules
as `np.result_type`.
::
npy_bool
PyArray_CanCastArrayTo(PyArrayObject *arr, PyArray_Descr
*to, NPY_CASTING casting)
Returns 1 if the array object may be cast to the given data type using
the casting rule, 0 otherwise. This differs from PyArray_CanCastTo in
that it handles scalar arrays (0 dimensions) specially, by checking
their value.
::
npy_bool
PyArray_CanCastTypeTo(PyArray_Descr *from, PyArray_Descr
*to, NPY_CASTING casting)
::
PyArrayObject *
PyArray_EinsteinSum(char *subscripts, npy_intp nop, PyArrayObject
**op_in, PyArray_Descr *dtype, NPY_ORDER
order, NPY_CASTING casting, PyArrayObject *out)
::
PyObject *
PyArray_NewLikeArray(PyArrayObject *prototype, NPY_ORDER
order, PyArray_Descr *dtype, int subok)
Creates a new array with the same shape as the provided one,
with possible memory layout order and data type changes.
NOTE: If dtype is not NULL, steals the dtype reference. On failure or when
dtype->subarray is true, dtype will be decrefed.
::
int
PyArray_GetArrayParamsFromObject(PyObject *NPY_UNUSED(op)
, PyArray_Descr
*NPY_UNUSED(requested_dtype)
, npy_bool NPY_UNUSED(writeable)
, PyArray_Descr
**NPY_UNUSED(out_dtype) , int
*NPY_UNUSED(out_ndim) , npy_intp
*NPY_UNUSED(out_dims) , PyArrayObject
**NPY_UNUSED(out_arr) , PyObject
*NPY_UNUSED(context) )
::
int
PyArray_ConvertClipmodeSequence(PyObject *object, NPY_CLIPMODE
*modes, int n)
::
PyObject *
PyArray_MatrixProduct2(PyObject *op1, PyObject
*op2, PyArrayObject*out)
Numeric.matrixproduct2(a,v,out)
just like inner product but does the swapaxes stuff on the fly
::
npy_bool
NpyIter_IsFirstVisit(NpyIter *iter, int iop)
::
int
PyArray_SetBaseObject(PyArrayObject *arr, PyObject *obj)
::
void
PyArray_CreateSortedStridePerm(int ndim, npy_intp const
*strides, npy_stride_sort_item
*out_strideperm)
::
void
PyArray_RemoveAxesInPlace(PyArrayObject *arr, const npy_bool *flags)
::
void
PyArray_DebugPrint(PyArrayObject *obj)
Prints the raw data of the ndarray in a form useful for debugging
low-level C issues.
::
int
PyArray_FailUnlessWriteable(PyArrayObject *obj, const char *name)
::
int
PyArray_SetUpdateIfCopyBase(PyArrayObject *arr, PyArrayObject *base)
::
void *
PyDataMem_NEW(size_t size)
::
void
PyDataMem_FREE(void *ptr)
::
void *
PyDataMem_RENEW(void *ptr, size_t size)
::
PyDataMem_EventHookFunc *
PyDataMem_SetEventHook(PyDataMem_EventHookFunc *newhook, void
*user_data, void **old_data)
When the hook is called, the GIL will be held by the calling
thread. The hook should be written to be reentrant, if it performs
operations that might cause new allocation events (such as the
creation/destruction numpy objects, or creating/destroying Python
objects which might cause a gc)
::
void
PyArray_MapIterSwapAxes(PyArrayMapIterObject *mit, PyArrayObject
**ret, int getmap)
Swap the axes to or from their inserted form. MapIter always puts the
advanced (array) indices first in the iteration. But if they are
consecutive, will insert/transpose them back before returning.
This is stored as `mit->consec != 0` (the place where they are inserted)
For assignments, the opposite happens: The values to be assigned are
transposed (getmap=1 instead of getmap=0). `getmap=0` and `getmap=1`
undo the other operation.
::
PyObject *
PyArray_MapIterArray(PyArrayObject *a, PyObject *index)
::
void
PyArray_MapIterNext(PyArrayMapIterObject *mit)
Note that this function never handles an extra operand but provides
compatibility for an old (exposed) API.
::
int
PyArray_Partition(PyArrayObject *op, PyArrayObject *ktharray, int
axis, NPY_SELECTKIND which)
::
PyObject *
PyArray_ArgPartition(PyArrayObject *op, PyArrayObject *ktharray, int
axis, NPY_SELECTKIND which)
ArgPartition an array
::
int
PyArray_SelectkindConverter(PyObject *obj, NPY_SELECTKIND *selectkind)
::
void *
PyDataMem_NEW_ZEROED(size_t size, size_t elsize)
::
int
PyArray_CheckAnyScalarExact(PyObject *obj)
::
PyObject *
PyArray_MapIterArrayCopyIfOverlap(PyArrayObject *a, PyObject
*index, int
copy_if_overlap, PyArrayObject
*extra_op)
::
int
PyArray_ResolveWritebackIfCopy(PyArrayObject *self)
If WRITEBACKIFCOPY and self has data, reset the base WRITEABLE flag,
copy the local data to base, release the local data, and set flags
appropriately. Return 0 if not relevant, 1 if success, < 0 on failure
::
int
PyArray_SetWritebackIfCopyBase(PyArrayObject *arr, PyArrayObject
*base)