numpy  2.0.0
src/multiarray/multiarraymodule.c File Reference
#include "Python.h"
#include "structmember.h"
#include "numpy/arrayobject.h"
#include "numpy/arrayscalars.h"
#include "numpy/npy_math.h"
#include "npy_config.h"
#include "npy_pycompat.h"
#include "arraytypes.h"
#include "arrayobject.h"
#include "hashdescr.h"
#include "descriptor.h"
#include "calculation.h"
#include "number.h"
#include "scalartypes.h"
#include "numpymemoryview.h"
#include "convert_datatype.h"
#include "conversion_utils.h"
#include "nditer_pywrap.h"
#include "methods.h"
#include "_datetime.h"
#include "datetime_strings.h"
#include "datetime_busday.h"
#include "datetime_busdaycal.h"
#include "item_selection.h"
#include "shape.h"
#include "ctors.h"
#include <setjmp.h>
#include <signal.h>
#include "__multiarray_api.c"

Defines

#define PY_SSIZE_T_CLEAN
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define _MULTIARRAYMODULE
#define STRIDING_OK(op, order)
#define _test_code()
#define SINGLE_INHERIT(child, parent)
#define DUAL_INHERIT(child, parent1, parent2)
#define DUAL_INHERIT_COMPARE(child, parent1, parent2)
#define DUAL_INHERIT2(child, parent1, parent2)
#define _addnew(key, val, one)
#define _addone(key, val)
#define RETVAL
#define ADDCONST(NAME)

Functions

NPY_NO_EXPORT double PyArray_GetPriority (PyObject *obj, double default_)
NPY_NO_EXPORT int PyArray_MultiplyIntList (int *l1, int n)
NPY_NO_EXPORT npy_intp PyArray_MultiplyList (npy_intp *l1, int n)
NPY_NO_EXPORT npy_intp PyArray_OverflowMultiplyList (npy_intp *l1, int n)
NPY_NO_EXPORT void * PyArray_GetPtr (PyArrayObject *obj, npy_intp *ind)
NPY_NO_EXPORT int PyArray_CompareLists (npy_intp *l1, npy_intp *l2, int n)
NPY_NO_EXPORT int PyArray_AsCArray (PyObject **op, void *ptr, npy_intp *dims, int nd, PyArray_Descr *typedescr)
NPY_NO_EXPORT int PyArray_As1D (PyObject **op, char **ptr, int *d1, int typecode)
NPY_NO_EXPORT int PyArray_As2D (PyObject **op, char ***ptr, int *d1, int *d2, int typecode)
NPY_NO_EXPORT int PyArray_Free (PyObject *op, void *ptr)
NPY_NO_EXPORT PyArrayObjectPyArray_ConcatenateArrays (int narrays, PyArrayObject **arrays, int axis)
NPY_NO_EXPORT PyArrayObjectPyArray_ConcatenateFlattenedArrays (int narrays, PyArrayObject **arrays, NPY_ORDER order)
NPY_NO_EXPORT PyObject * PyArray_Concatenate (PyObject *op, int axis)
static int _signbit_set (PyArrayObject *arr)
NPY_NO_EXPORT NPY_SCALARKIND PyArray_ScalarKind (int typenum, PyArrayObject **arr)
NPY_NO_EXPORT int PyArray_CanCoerceScalar (int thistype, int neededtype, NPY_SCALARKIND scalar)
static PyArrayObjectnew_array_for_sum (PyArrayObject *ap1, PyArrayObject *ap2, PyArrayObject *out, int nd, npy_intp dimensions[], int typenum)
NPY_NO_EXPORT PyObject * PyArray_InnerProduct (PyObject *op1, PyObject *op2)
NPY_NO_EXPORT PyObject * PyArray_MatrixProduct2 (PyObject *op1, PyObject *op2, PyArrayObject *out)
NPY_NO_EXPORT PyObject * PyArray_MatrixProduct (PyObject *op1, PyObject *op2)
NPY_NO_EXPORT PyObject * PyArray_CopyAndTranspose (PyObject *op)
static PyArrayObject_pyarray_correlate (PyArrayObject *ap1, PyArrayObject *ap2, int typenum, int mode, int *inverted)
static int _pyarray_revert (PyArrayObject *ret)
NPY_NO_EXPORT PyObject * PyArray_Correlate2 (PyObject *op1, PyObject *op2, int mode)
NPY_NO_EXPORT PyObject * PyArray_Correlate (PyObject *op1, PyObject *op2, int mode)
static PyObject * array_putmask (PyObject *NPY_UNUSED(module), PyObject *args, PyObject *kwds)
static int _equivalent_fields (PyObject *field1, PyObject *field2)
static int _equivalent_subarrays (PyArray_ArrayDescr *sub1, PyArray_ArrayDescr *sub2)
NPY_NO_EXPORT unsigned char PyArray_EquivTypes (PyArray_Descr *type1, PyArray_Descr *type2)
NPY_NO_EXPORT unsigned char PyArray_EquivTypenums (int typenum1, int typenum2)
static PyObject * _prepend_ones (PyArrayObject *arr, int nd, int ndmin, NPY_ORDER order)
static PyObject * _array_fromobject (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws)
static PyObject * array_copyto (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
static PyObject * array_empty (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
static PyObject * array_empty_like (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
static PyObject * array_scalar (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
static PyObject * array_zeros (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
static PyObject * array_count_nonzero (PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
static PyObject * array_fromstring (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *keywds)
static PyObject * array_fromfile (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *keywds)
static PyObject * array_fromiter (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *keywds)
static PyObject * array_frombuffer (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *keywds)
static PyObject * array_concatenate (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static PyObject * array_innerproduct (PyObject *NPY_UNUSED(dummy), PyObject *args)
static PyObject * array_matrixproduct (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static int einsum_sub_op_from_str (PyObject *args, PyObject **str_obj, char **subscripts, PyArrayObject **op)
static int einsum_list_to_subscripts (PyObject *obj, char *subscripts, int subsize)
static int einsum_sub_op_from_lists (PyObject *args, char *subscripts, int subsize, PyArrayObject **op)
static PyObject * array_einsum (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static PyObject * array_fastCopyAndTranspose (PyObject *NPY_UNUSED(dummy), PyObject *args)
static PyObject * array_correlate (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static PyObject * array_correlate2 (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static PyObject * array_arange (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws)
NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCVersion (void)
NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCFeatureVersion (void)
static PyObject * array__get_ndarray_c_version (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
NPY_NO_EXPORT int PyArray_GetEndianness (void)
static PyObject * array__reconstruct (PyObject *NPY_UNUSED(dummy), PyObject *args)
static PyObject * array_set_string_function (PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
static PyObject * array_set_ops_function (PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args), PyObject *kwds)
static PyObject * array_set_datetimeparse_function (PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args), PyObject *NPY_UNUSED(kwds))
NPY_NO_EXPORT PyObject * PyArray_Where (PyObject *condition, PyObject *x, PyObject *y)
static PyObject * array_where (PyObject *NPY_UNUSED(ignored), PyObject *args)
static PyObject * array_lexsort (PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
static PyObject * array_can_cast_safely (PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
static PyObject * array_promote_types (PyObject *NPY_UNUSED(dummy), PyObject *args)
static PyObject * array_min_scalar_type (PyObject *NPY_UNUSED(dummy), PyObject *args)
static PyObject * array_result_type (PyObject *NPY_UNUSED(dummy), PyObject *args)
static PyObject * array_datetime_data (PyObject *NPY_UNUSED(dummy), PyObject *args)
static PyObject * new_buffer (PyObject *NPY_UNUSED(dummy), PyObject *args)
static PyObject * buffer_buffer (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static void _SigSegv_Handler (int signum)
static PyObject * as_buffer (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static PyObject * format_longfloat (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static PyObject * compare_chararrays (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
static PyObject * _vec_string_with_args (PyArrayObject *char_array, PyArray_Descr *type, PyObject *method, PyObject *args)
static PyObject * _vec_string_no_args (PyArrayObject *char_array, PyArray_Descr *type, PyObject *method)
static PyObject * _vec_string (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
NPY_NO_EXPORT void _PyArray_SigintHandler (int signum)
NPY_NO_EXPORT void * _PyArray_GetSigintBuf (void)
static PyObject * test_interrupt (PyObject *NPY_UNUSED(self), PyObject *args)
NPY_NO_EXPORT
PyDataMem_EventHookFunc
PyDataMem_SetEventHook (PyDataMem_EventHookFunc *newhook, void *user_data, void **old_data)
NPY_NO_EXPORT void * PyDataMem_NEW (size_t size)
NPY_NO_EXPORT void PyDataMem_FREE (void *ptr)
NPY_NO_EXPORT void * PyDataMem_RENEW (void *ptr, size_t size)
static int setup_scalartypes (PyObject *NPY_UNUSED(dict))
static void set_flaginfo (PyObject *d)
PyMODINIT_FUNC initmultiarray (void)

Variables

NPY_NO_EXPORT int NPY_NUMUSERTYPES = 0
NPY_NO_EXPORT PyTypeObject PyBigArray_Type
jmp_buf _NPY_SIGSEGV_BUF
NPY_SIGJMP_BUF _NPY_SIGINT_BUF
NPY_NO_EXPORT
PyDataMem_EventHookFunc
_PyDataMem_eventhook
NPY_NO_EXPORT void * _PyDataMem_eventhook_user_data
static struct PyMethodDef array_module_methods []

Define Documentation

#define _addnew (   key,
  val,
  one 
)
Value:
PyDict_SetItemString(newd, #key, s=PyInt_FromLong(val));    \
    Py_DECREF(s);                                               \
    PyDict_SetItemString(newd, #one, s=PyInt_FromLong(val));    \
    Py_DECREF(s)
#define _addone (   key,
  val 
)
Value:
PyDict_SetItemString(newd, #key, s=PyInt_FromLong(val));    \
    Py_DECREF(s)
#define _test_code ( )
Value:
{ \
        test = *((char*)memptr); \
        if (!ro) { \
            *((char *)memptr) = '\0'; \
            *((char *)memptr) = test; \
        } \
        test = *((char*)memptr+size-1); \
        if (!ro) { \
            *((char *)memptr+size-1) = '\0'; \
            *((char *)memptr+size-1) = test; \
        } \
    }

Referenced by array_can_cast_safely().

#define ADDCONST (   NAME)
Value:
s = PyInt_FromLong(NPY_##NAME);             \
    PyDict_SetItemString(d, #NAME, s);          \
    Py_DECREF(s)

Referenced by setup_scalartypes().

#define DUAL_INHERIT (   child,
  parent1,
  parent2 
)
Value:
Py##child##ArrType_Type.tp_base = &Py##parent2##ArrType_Type;       \
    Py##child##ArrType_Type.tp_bases =                                  \
        Py_BuildValue("(OO)", &Py##parent2##ArrType_Type,               \
                      &Py##parent1##_Type);                             \
    if (PyType_Ready(&Py##child##ArrType_Type) < 0) {                   \
        PyErr_Print();                                                  \
        PyErr_Format(PyExc_SystemError,                                 \
                     "could not initialize Py%sArrType_Type",           \
                     #child);                                           \
        return -1;                                                      \
    }                                                                   \
    Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;

Referenced by PyDataMem_FREE(), PyDataMem_NEW(), and PyDataMem_SetEventHook().

#define DUAL_INHERIT2 (   child,
  parent1,
  parent2 
)
Value:
Py##child##ArrType_Type.tp_base = &Py##parent1##_Type;              \
    Py##child##ArrType_Type.tp_bases =                                  \
        Py_BuildValue("(OO)", &Py##parent1##_Type,                      \
                      &Py##parent2##ArrType_Type);                      \
    Py##child##ArrType_Type.tp_richcompare =                            \
        Py##parent1##_Type.tp_richcompare;                              \
    DUAL_INHERIT_COMPARE(child, parent1, parent2)                       \
    Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;       \
    if (PyType_Ready(&Py##child##ArrType_Type) < 0) {                   \
        PyErr_Print();                                                  \
        PyErr_Format(PyExc_SystemError,                                 \
                     "could not initialize Py%sArrType_Type",           \
                     #child);                                           \
        return -1;                                                      \
    }

Referenced by PyDataMem_RENEW().

#define DUAL_INHERIT_COMPARE (   child,
  parent1,
  parent2 
)
Value:
Py##child##ArrType_Type.tp_compare =                                \
        Py##parent1##_Type.tp_compare;
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
Id:
multiarraymodule.c,v 1.36 2005/09/14 00:14:00 teoliphant Exp
#define RETVAL
Initialization function for the module
#define SINGLE_INHERIT (   child,
  parent 
)
Value:
Py##child##ArrType_Type.tp_base = &Py##parent##ArrType_Type;        \
    if (PyType_Ready(&Py##child##ArrType_Type) < 0) {                   \
        PyErr_Print();                                                  \
        PyErr_Format(PyExc_SystemError,                                 \
                     "could not initialize Py%sArrType_Type",           \
                     #child);                                           \
        return -1;                                                      \
    }

Referenced by PyDataMem_FREE(), PyDataMem_NEW(), PyDataMem_RENEW(), and PyDataMem_SetEventHook().

#define STRIDING_OK (   op,
  order 
)
Value:
((order) == NPY_ANYORDER || \
                 (order) == NPY_KEEPORDER || \
                 ((order) == NPY_CORDER && PyArray_ISCONTIGUOUS(op)) || \
                 ((order) == NPY_FORTRANORDER && PyArray_ISFORTRAN(op)))

Function Documentation

static PyObject* _array_fromobject ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  kws 
) [static]
fast exit if simple call
One more chance
order == NPY_ANYORDER &&
create a new array from the same data with ones in the shape steals a reference to ret
static int _equivalent_fields ( PyObject *  field1,
PyObject *  field2 
) [static]
Compare the field dictionaries for two types.
Return 1 if the contents are the same, 0 if not.

Referenced by PyArray_Correlate2().

static int _equivalent_subarrays ( PyArray_ArrayDescr sub1,
PyArray_ArrayDescr sub2 
) [static]
Compare the subarray data for two types. Return 1 if they are the same, 0 if not.

Referenced by PyArray_Correlate2().

static PyObject* _prepend_ones ( PyArrayObject arr,
int  nd,
int  ndmin,
NPY_ORDER  order 
) [static]
  • END C-API FUNCTIONS *
steals a reference to arr --- so don't increment here

References NPY_BOOL, NPY_SAME_KIND_CASTING, PyArray_AssignArray(), PyArray_CastingConverter(), PyArray_Converter(), PyArray_DescrFromType(), PyArray_FromAny(), and PyArray_Type.

static PyArrayObject* _pyarray_correlate ( PyArrayObject ap1,
PyArrayObject ap2,
int  typenum,
int  mode,
int *  inverted 
) [static]
Implementation which is common between PyArray_Correlate and PyArray_Correlate2.
inverted is set to 1 if computed correlate(ap2, ap1), 0 otherwise
Need to choose an output array that can hold a sum -- use priority to determine which subtype.

References _pyarray_revert(), NPY_ARRAY_DEFAULT, PyArray_Conjugate(), PyArray_DescrFromType(), PyArray_FromAny(), PyArray_ISCOMPLEX, and PyArray_ObjectType().

static int _pyarray_revert ( PyArrayObject ret) [static]
Revert a one dimensional array in-place
Return 0 on success, other value on failure

Referenced by _pyarray_correlate().

static int _signbit_set ( PyArrayObject arr) [static]

<

points to the npy_byte to test

Referenced by PyArray_Concatenate().

static void _SigSegv_Handler ( int  signum) [static]

Referenced by array_can_cast_safely().

static PyObject* _vec_string_no_args ( PyArrayObject char_array,
PyArray_Descr type,
PyObject *  method 
) [static]
This is a faster version of _vec_string_args to use when there are no additional arguments to the string method. This doesn't require a broadcast iterator (and broadcast iterators don't work with 1 argument anyway).

References _PyDataMem_eventhook_user_data.

static PyObject* _vec_string_with_args ( PyArrayObject char_array,
PyArray_Descr type,
PyObject *  method,
PyObject *  args 
) [static]
Steals ref to arg
static PyObject* array__get_ndarray_c_version ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]
static PyObject* array__reconstruct ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]
static PyObject* array_arange ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  kws 
) [static]
static PyObject* array_can_cast_safely ( PyObject *  NPY_UNUSEDself,
PyObject *  args,
PyObject *  kwds 
) [static]
If the first parameter is an object or scalar, use CanCastArrayTo
Otherwise use CanCastTypeTo

References _SigSegv_Handler(), _test_code, NPY_FALSE, NPY_TRUE, and PyArray_BoolConverter().

Referenced by _vec_string().

static PyObject* array_concatenate ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _vec_string().

static PyObject* array_copyto ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  kwds 
) [static]
Get the boolean where mask
static PyObject* array_correlate ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _vec_string().

static PyObject* array_correlate2 ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _vec_string().

static PyObject* array_count_nonzero ( PyObject *  NPY_UNUSEDself,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _vec_string().

static PyObject* array_datetime_data ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]

References NPY_MAXARGS.

static PyObject* array_einsum ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]
einsum('i,j', a, b), einsum('i,j->ij', a, b)
einsum(a, [0], b, [1]), einsum(a, [0], b, [1], [0,1])
Get the keyword arguments
If no output was supplied, possibly convert to a scalar
out is a borrowed reference

Referenced by _vec_string().

static PyObject* array_empty ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _vec_string().

static PyObject* array_empty_like ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  kwds 
) [static]
steals the reference to dtype if it's not NULL

Referenced by _vec_string().

static PyObject* array_fastCopyAndTranspose ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]

Referenced by _vec_string().

static PyObject* array_frombuffer ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  keywds 
) [static]

Referenced by _vec_string().

static PyObject* array_fromfile ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  keywds 
) [static]

Referenced by _vec_string().

static PyObject* array_fromiter ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  keywds 
) [static]

Referenced by _vec_string().

static PyObject* array_fromstring ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  keywds 
) [static]

Referenced by _vec_string().

static PyObject* array_innerproduct ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]

Referenced by _vec_string().

static PyObject* array_lexsort ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _vec_string().

static PyObject* array_matrixproduct ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _vec_string().

static PyObject* array_min_scalar_type ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]

Referenced by _vec_string().

static PyObject* array_promote_types ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]

Referenced by _vec_string().

static PyObject* array_putmask ( PyObject *  NPY_UNUSEDmodule,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _vec_string().

static PyObject* array_result_type ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]
static PyObject* array_scalar ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  kwds 
) [static]
This function is needed for supporting Pickles of numpy scalar objects.
free dptr which contains zeros

Referenced by _vec_string().

static PyObject* array_set_datetimeparse_function ( PyObject *  NPY_UNUSEDself,
PyObject *  NPY_UNUSEDargs,
PyObject *  NPY_UNUSEDkwds 
) [static]
static PyObject* array_set_ops_function ( PyObject *  NPY_UNUSEDself,
PyObject *  NPY_UNUSEDargs,
PyObject *  kwds 
) [static]
Should probably ensure that objects are at least callable
Leave this to the caller for now --- error will be raised later when use is attempted
static PyObject* array_set_string_function ( PyObject *  NPY_UNUSEDself,
PyObject *  args,
PyObject *  kwds 
) [static]
reset the array_repr function to built-in
static PyObject* array_where ( PyObject *  NPY_UNUSEDignored,
PyObject *  args 
) [static]

Referenced by _vec_string().

static PyObject* array_zeros ( PyObject *  NPY_UNUSEDignored,
PyObject *  args,
PyObject *  kwds 
) [static]
static PyObject* as_buffer ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]
Try to dereference the start and end of the memory region Catch segfault and report error if it occurs

Referenced by _PyArray_GetSigintBuf().

static PyObject* buffer_buffer ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _PyArray_GetSigintBuf().

static PyObject* compare_chararrays ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _PyArray_GetSigintBuf().

static int einsum_list_to_subscripts ( PyObject *  obj,
char *  subscripts,
int  subsize 
) [static]
Converts a list of subscripts to a string.
Returns -1 on error, the number of characters placed in subscripts otherwise.
Ellipsis
Subscript
Invalid
static int einsum_sub_op_from_lists ( PyObject *  args,
char *  subscripts,
int  subsize,
PyArrayObject **  op 
) [static]
Fills in the subscripts, with maximum size subsize, and op, with the values in the tuple 'args'.
Returns -1 on error, number of operands placed in op otherwise.
Set the operands to NULL
Get the operands and build the subscript string
Comma between the subscripts for each operand
Add the '->' to the string if provided
NULL-terminate the subscripts string
static int einsum_sub_op_from_str ( PyObject *  args,
PyObject **  str_obj,
char **  subscripts,
PyArrayObject **  op 
) [static]
Get the subscripts string
Set the operands to NULL
Get the operands
static PyObject* format_longfloat ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  kwds 
) [static]

Referenced by _PyArray_GetSigintBuf().

PyMODINIT_FUNC initmultiarray ( void  )
Create the module and add the functions
Initialize access to the PyDateTime API
Add some symbolic constants to the module
FIXME There is no error handling here
Initialize types in numpymemoryview.c
PyExc_Exception should catch all the standard errors that are now raised instead of the string exception "multiarray.error" This is for backward compatibility with existing code.
FIXME There is no error handling here
Business day calendar object
static PyArrayObject* new_array_for_sum ( PyArrayObject ap1,
PyArrayObject ap2,
PyArrayObject out,
int  nd,
npy_intp  dimensions[],
int  typenum 
) [static]
Make a new empty array, of the passed size, of a type that takes the priority of ap1 and ap2 into account.
Need to choose an output array that can hold a sum -- use priority to determine which subtype.
verify that out is usable
static PyObject* new_buffer ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]

Referenced by _PyArray_GetSigintBuf().

NPY_NO_EXPORT int PyArray_As1D ( PyObject **  op,
char **  ptr,
int *  d1,
int  typecode 
)
Deprecated --- Use PyArray_AsCArray instead
Convert to a 1D C-array

References DEPRECATE, PyArray_AsCArray(), and PyArray_DescrFromType().

NPY_NO_EXPORT int PyArray_As2D ( PyObject **  op,
char ***  ptr,
int *  d1,
int *  d2,
int  typecode 
)
Convert to a 2D C-array

References PyArray_free, and PyArray_NDIM.

NPY_NO_EXPORT int PyArray_AsCArray ( PyObject **  op,
void *  ptr,
npy_intp dims,
int  nd,
PyArray_Descr typedescr 
)
simulates a C-style 1-3 dimensional array which can be accesed using ptr[i] or ptr[i][j] or ptr[i][j][k] -- requires pointer allocation for 2-d and 3-d.
For 2-d and up, ptr is NOT equivalent to a statically defined 2-d or 3-d array. In particular, it cannot be passed into a function that requires a true pointer to a fixed-size array.
Simulate a C-array
steals a reference to typedescr -- can be NULL

References PyArray_DATA, PyArray_DIMS, PyArray_malloc, and PyArray_STRIDES.

Referenced by PyArray_As1D().

NPY_NO_EXPORT int PyArray_CanCoerceScalar ( int  thistype,
int  neededtype,
NPY_SCALARKIND  scalar 
)
Determines whether the data type 'thistype', with
scalar kind 'scalar', can be coerced into 'neededtype'.
If 'thistype' is not a scalar, it must be safely castable
The lookup table gives us exactly what we need for this comparison, which PyArray_ScalarKind would not.
The rule is that positive scalars can be coerced to a signed ints, but negative scalars cannot be coerced to unsigned ints.

System Message: ERROR/3 (<string>, line 7) Unexpected indentation.

<blockquote>

_npy_scalar_kinds_table[int]==NEGINT > POSINT,
so 1 is returned, but
_npy_scalar_kinds_table[uint]==POSINT < NEGINT,
so 0 is returned, as required.

</blockquote>

NPY_NO_EXPORT int PyArray_CompareLists ( npy_intp l1,
npy_intp l2,
int  n 
)
Compare Lists

References NPY_ARRAY_CARRAY, and PyArray_FromAny().

Referenced by PyArray_TakeFrom().

NPY_NO_EXPORT PyObject* PyArray_Concatenate ( PyObject *  op,
int  axis 
)
Concatenate <blockquote> Concatenate an arbitrary Python sequence into an array. op is a python object supporting the sequence interface. Its elements will be concatenated together to form a single multidimensional array. If axis is NPY_MAXDIMS or bigger, then each sequence object will be flattened before concatenation</blockquote>
Convert the input list into arrays
'narrays' was set to how far we got in the conversion

References _npy_scalar_kinds_table, _signbit_set(), _PyArray_Descr::f, NPY_INTNEG_SCALAR, NPY_INTPOS_SCALAR, NPY_NOSCALAR, NPY_NTYPES, PyArray_DescrFromType(), PyTypeNum_ISUSERDEF, and PyArray_ArrFuncs::scalarkind.

NPY_NO_EXPORT PyArrayObject* PyArray_ConcatenateArrays ( int  narrays,
PyArrayObject **  arrays,
int  axis 
)
Concatenates a list of ndarrays.
All the arrays must have the same 'ndim'
Handle standard Python negative indexing
Figure out the final concatenated shape starting from the first array's shape.
Build up the size of the concatenation axis
Validate that the rest of the dimensions match
Get the priority subtype for the array
Get the resulting dtype from combining all the arrays
Figure out the permutation to apply to the strides to match the memory layout of the input arrays, using ambiguity resolution rules matching that of the NpyIter.
Allocate the array for the result. This steals the 'dtype' reference.
Create a view which slides through ret for assigning the successive input arrays.
Set the dimension to match the input array's
Copy the data for this array
Slide to the start of the next window
Concatenates a list of ndarrays, flattening each in the specified order.
Figure out the final concatenated shape starting from the first array's shape.
Check for overflow
Get the priority subtype for the array
Get the resulting dtype from combining all the arrays
Allocate the array for the result. This steals the 'dtype' reference.
Create a view which slides through ret for assigning the successive input arrays.
Adjust the window dimensions for this array
Copy the data for this array
Slide to the start of the next window
NPY_NO_EXPORT PyObject* PyArray_CopyAndTranspose ( PyObject *  op)
Copy and Transpose <blockquote> Could deprecate this function, as there isn't a speed benefit over calling Transpose and then Copy.</blockquote>
Make sure we have an array
Set up the transpose operation
Do the transpose (always returns a view)
TODO: Change this to NPY_KEEPORDER for NumPy 2.0
NPY_NO_EXPORT PyObject* PyArray_Correlate ( PyObject *  op1,
PyObject *  op2,
int  mode 
)
Numeric.correlate(a1,a2,mode)

References has_equivalent_datetime_metadata().

NPY_NO_EXPORT PyObject* PyArray_Correlate2 ( PyObject *  op1,
PyObject *  op2,
int  mode 
)
correlate(a1,a2,mode) <blockquote> This function computes the usual correlation (correlate(a1, a2) != correlate(a2, a1), and conjugate the second argument for complex inputs</blockquote>
If we inverted input orders, we need to reverse the output array (i.e. ret = ret[::-1])

References _equivalent_fields(), _equivalent_subarrays(), _arr_descr::base, _PyArray_Descr::byteorder, _PyArray_Descr::elsize, _PyArray_Descr::fields, NPY_DATETIME, NPY_FALSE, NPY_NO_EXPORT, NPY_TIMEDELTA, NPY_TRUE, NPY_VOID, PyArray_EquivTypes(), PyArray_ISNBO, _arr_descr::shape, _PyArray_Descr::subarray, and _PyArray_Descr::type_num.

NPY_NO_EXPORT unsigned char PyArray_EquivTypenums ( int  typenum1,
int  typenum2 
)
NPY_NO_EXPORT unsigned char PyArray_EquivTypes ( PyArray_Descr type1,
PyArray_Descr type2 
)
This function returns true if the two typecodes are
equivalent (same basic kind and same itemsize).

Referenced by PyArray_Correlate2().

NPY_NO_EXPORT int PyArray_Free ( PyObject *  op,
void *  ptr 
)
End Deprecated
Free pointers created if As2D is called
Returns the built-in (at compilation time) C API version
NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCVersion ( void  )
Included at the very first so not auto-grabbed and thus not labeled.
NPY_NO_EXPORT double PyArray_GetPriority ( PyObject *  obj,
double  default_ 
)
Get Priority from object

Referenced by PyArray_ScalarKind().

NPY_NO_EXPORT void* PyArray_GetPtr ( PyArrayObject obj,
npy_intp ind 
)
Produce a pointer into array
NPY_NO_EXPORT PyObject* PyArray_InnerProduct ( PyObject *  op1,
PyObject *  op2 
)
Could perhaps be redone to not make contiguous arrays
Numeric.innerproduct(a,v)
Need to choose an output array that can hold a sum -- use priority to determine which subtype.
NPY_NO_EXPORT PyObject* PyArray_MatrixProduct ( PyObject *  op1,
PyObject *  op2 
)
Numeric.matrixproduct(a,v)
just like inner product but does the swapaxes stuff on the fly
NPY_NO_EXPORT PyObject* PyArray_MatrixProduct2 ( PyObject *  op1,
PyObject *  op2,
PyArrayObject out 
)
Numeric.matrixproduct(a,v,out)
just like inner product but does the swapaxes stuff on the fly
fprintf(stderr, "nd=d dimensions=", nd); for(i=0; i<j; i++) fprintf(stderr, "d ", dimensions[i]); fprintf(stderr, "n");
Choose which subtype to return
Ensure that multiarray.dot(<Nx0>,<0xM>) -> zeros((N,M))
Ensure that multiarray.dot([],[]) -> 0
only for OBJECT arrays
NPY_NO_EXPORT int PyArray_MultiplyIntList ( int *  l1,
int  n 
)
Multiply a List of ints
Multiply a List of Non-negative numbers with over-flow detection.
ScalarKind <blockquote> Returns the scalar kind of a type number, with an optional tweak based on the scalar value itself. If no scalar is provided, it returns INTPOS_SCALAR for both signed and unsigned integers, otherwise it checks the sign of any signed integer to choose INTNEG_SCALAR when appropriate.</blockquote>
Signed integer types are INTNEG in the table

References Py_TYPE, and PyArray_GetPriority().

NPY_NO_EXPORT PyObject* PyArray_Where ( PyObject *  condition,
PyObject *  x,
PyObject *  y 
)
Where
NPY_NO_EXPORT void PyDataMem_FREE ( void *  ptr)
Free memory for array data.

References DUAL_INHERIT, and SINGLE_INHERIT.

Referenced by _new_sort().

NPY_NO_EXPORT void* PyDataMem_NEW ( size_t  size)
Allocates memory for array data.

References DUAL_INHERIT, and SINGLE_INHERIT.

Referenced by _new_sort().

NPY_NO_EXPORT void* PyDataMem_RENEW ( void *  ptr,
size_t  size 
)
Reallocate/resize memory for array data.

References DUAL_INHERIT2, and SINGLE_INHERIT.

Referenced by array_fromfile_binary(), and PyArray_Arange().

NPY_NO_EXPORT PyDataMem_EventHookFunc* PyDataMem_SetEventHook ( PyDataMem_EventHookFunc newhook,
void *  user_data,
void **  old_data 
)
Sets the allocation event hook for numpy array data.
Takes a PyDataMem_EventHookFunc *, which has the signature:
System Message: WARNING/2 (<string>, line 4); backlink Inline emphasis start-string without end-string.

<blockquote>

void hook(void *old, void *new, size_t size, void *user_data).

System Message: WARNING/2 (<string>, line 3); backlink Inline emphasis start-string without end-string.
System Message: WARNING/2 (<string>, line 3); backlink Inline emphasis start-string without end-string.
System Message: WARNING/2 (<string>, line 3); backlink Inline emphasis start-string without end-string.

</blockquote>

System Message: WARNING/2 (<string>, line 4) Block quote ends without a blank line; unexpected unindent.

Also takes a void *user_data, and void **old_data.

System Message: WARNING/2 (<string>, line 4); backlink Inline emphasis start-string without end-string.
System Message: WARNING/2 (<string>, line 4); backlink Inline strong start-string without end-string.

Returns a pointer to the previous hook or NULL. If old_data is non-NULL, the previous user_data pointer will be copied to it.

If not NULL, hook will be called at the end of each PyDataMem_NEW/FREE/RENEW:

result = PyDataMem_NEW(size) -> (*hook)(NULL, result, size, user_data) PyDataMem_FREE(ptr) -> (*hook)(ptr, NULL, 0, user_data) result = PyDataMem_RENEW(ptr, size) -> (*hook)(ptr, result, size, user_data)

System Message: WARNING/2 (<string>, line 10); backlink Inline emphasis start-string without end-string.
System Message: WARNING/2 (<string>, line 10); backlink Inline emphasis start-string without end-string.
System Message: WARNING/2 (<string>, line 10); backlink Inline emphasis start-string without end-string.

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/descruction numpy objects, or creating/destroying Python objects which might cause a gc)

References DUAL_INHERIT, and SINGLE_INHERIT.

static void set_flaginfo ( PyObject *  d) [static]
place a flag dictionary in d
static int setup_scalartypes ( PyObject *  NPY_UNUSEDdict) [static]
Establish scalar-type hierarchy <blockquote>
For dual inheritance we need to make sure that the objects being inherited from have the tp->mro object initialized. This is not necessarily true for the basic type objects of Python (it is checked for single inheritance but not dual in PyType_Ready).
Thus, we call PyType_Ready on the standard Python Types, here. </blockquote>
Datetime doesn't fit in any category
Timedelta is an integer with an associated unit
fprintf(stderr,
"tp_free = p, PyObject_Del = p, int_tp_free = p, base.tp_free = pn",
PyIntArrType_Type.tp_free, PyObject_Del, PyInt_Type.tp_free, PySignedIntegerArrType_Type.tp_free);
Clean up string and unicode array types so they act more like strings -- get their tables from the standard types.

References ADDCONST.

static PyObject* test_interrupt ( PyObject *  NPY_UNUSEDself,
PyObject *  args 
) [static]

Variable Documentation

struct PyMethodDef array_module_methods[] [static]
Internal APIs
Only here for API compatibility