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 "numpy/npy_3kcompat.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 "nditer_pywrap.h"
#include "methods.h"
#include "_datetime.h"
#include "datetime_strings.h"
#include "datetime_busday.h"
#include "datetime_busdaycal.h"
#include <setjmp.h>
#include <signal.h>
#include "__multiarray_api.c"

Defines

#define PY_SSIZE_T_CLEAN
#define NPY_NO_DEPRECATED_API
#define _MULTIARRAYMODULE
#define NPY_NO_PREFIX
#define PyAO   PyArrayObject
#define _ARET(x)   PyArray_Return((PyArrayObject *)(x))
#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)
static PyObject * _swap_and_concat (PyObject *op, int axis, int n)
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)
NPY_NO_EXPORT int PyArray_OrderConverter (PyObject *object, NPY_ORDER *val)
NPY_NO_EXPORT int PyArray_ClipmodeConverter (PyObject *object, NPY_CLIPMODE *val)
NPY_NO_EXPORT int PyArray_ConvertClipmodeSequence (PyObject *object, NPY_CLIPMODE *modes, int n)
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)
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)
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)
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
SIGJMP_BUF _NPY_SIGINT_BUF
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 _ARET (   x)    PyArray_Return((PyArrayObject *)(x))
#define _MULTIARRAYMODULE
#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_promote_types().

#define ADDCONST (   NAME)
Value:
s = PyInt_FromLong(NPY_##NAME);             \
    PyDict_SetItemString(d, #NAME, s);          \
    Py_DECREF(s)
#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;
#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;                                                      \
    }
#define DUAL_INHERIT_COMPARE (   child,
  parent1,
  parent2 
)
Value:
Py##child##ArrType_Type.tp_compare =                                \
        Py##parent1##_Type.tp_compare;
#define NPY_NO_DEPRECATED_API
#define NPY_NO_PREFIX
#define PY_SSIZE_T_CLEAN
Id:
multiarraymodule.c,v 1.36 2005/09/14 00:14:00 teoliphant Exp
#define PyAO   PyArrayObject
#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;                                                      \
    }
#define STRIDING_OK (   op,
  order 
)
Value:
((order) == NPY_ANYORDER ||          \
                                ((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

Referenced by _vec_string_no_args().

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.

References Bool, PyArray_DescrFromType(), and PyArray_EquivTypes().

Referenced by PyArray_ConvertClipmodeSequence().

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_ClipmodeConverter(), and PyArray_ConvertClipmodeSequence().

static PyObject* _prepend_ones ( PyArrayObject arr,
int  nd,
int  ndmin 
) [static]
  • END C-API FUNCTIONS *

steals a reference to arr --- so don't increment here

References NPY_ARRAY_ENSUREARRAY.

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.

NPY_NO_EXPORT void* _PyArray_GetSigintBuf ( void  )
static int _pyarray_revert ( PyArrayObject ret) [static]
Revert a one dimensional array in-place
Return 0 on success, other value on failure
NPY_NO_EXPORT void _PyArray_SigintHandler ( int  signum)
static void _SigSegv_Handler ( int  signum) [static]
static PyObject* _swap_and_concat ( PyObject *  op,
int  axis,
int  n 
) [static]
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 _array_fromobject(), array_arange(), array_concatenate(), array_copyto(), array_correlate(), array_correlate2(), array_count_nonzero(), array_einsum(), array_empty(), array_empty_like(), array_fastCopyAndTranspose(), array_frombuffer(), array_fromfile(), array_fromiter(), array_fromstring(), array_innerproduct(), array_lexsort(), array_matrixproduct(), array_putmask(), array_scalar(), array_where(), array_zeros(), and NpyIter_NestedIters().

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]

Referenced by _vec_string_no_args().

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

Referenced by _vec_string().

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

Referenced by _vec_string_no_args().

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

Get the boolean where mask
Use the 'move' function which handles overlapping
MoveInto doesn't accept a casting rule, must check it ourselves.
Use the 'move' function which handles overlapping

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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

Referenced by _vec_string().

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_no_args().

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

Referenced by _vec_string_no_args().

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_no_args().

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

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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

References NPY_MAXARGS.

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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

Referenced by _vec_string_no_args().

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]

References _test_code.

Referenced by _vec_string().

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

Referenced by _vec_string_no_args().

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_no_args().

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_no_args().

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

<

XXX ?

Referenced by _vec_string_no_args().

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 _vec_string().

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

Referenced by _vec_string().

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

Referenced by _vec_string().

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

Referenced by einsum_sub_op_from_str().

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

References PyArray_CastingConverter().

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

References einsum_list_to_subscripts(), NPY_ARRAY_ENSUREARRAY, NPY_MAXARGS, and PyArray_FromAny().

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

Referenced by _vec_string().

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

References PyArrayObject::dimensions, MAX_DIMS, PyArrayObject::nd, NPY_ARRAY_ALIGNED, NPY_BEGIN_THREADS_DEF, Py_TYPE, PyArray_DescrFromType(), PyArray_FromAny(), and PyArray_ObjectType().

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

Referenced by _vec_string().

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 _pya_free, and PyArrayObject::nd.

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 _pya_malloc, PyArrayObject::data, PyArrayObject::dimensions, and PyArrayObject::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_ClipmodeConverter ( PyObject *  object,
NPY_CLIPMODE val 
)
Convert an object to NPY_RAISE / NPY_CLIP / NPY_WRAP

References _equivalent_subarrays(), _arr_descr::base, PyArray_EquivTypes(), and _arr_descr::shape.

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 MAX_DIMS or bigger, then each sequence object will be flattened before concatenation</blockquote>

Make sure these arrays are legal to concatenate. Must have same dimensions except d0

References MAX_DIMS, Py_TYPE, PyArray_GetPriority(), and PyArray_Ravel().

NPY_NO_EXPORT int PyArray_ConvertClipmodeSequence ( PyObject *  object,
NPY_CLIPMODE modes,
int  n 
)
Convert an object to an array of n NPY_CLIPMODE values.
This is intended to be used in functions where a different mode could be applied to each axis, like in ravel_multi_index.

Get the clip mode(s)

References _equivalent_fields(), _equivalent_subarrays(), _PyArray_Descr::byteorder, _PyArray_Descr::elsize, FALSE, _PyArray_Descr::fields, has_equivalent_datetime_metadata(), _PyArray_Descr::kind, NPY_DATETIME, NPY_TIMEDELTA, NPY_VOID, PyArray_ISNBO, _PyArray_Descr::subarray, TRUE, and _PyArray_Descr::type_num.

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)
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])

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 _equivalent_fields(), PyArray_CanCastTypeTo(), and PyArray_ClipmodeConverter().

NPY_NO_EXPORT int PyArray_Free ( PyObject *  op,
void *  ptr 
)
End Deprecated
Free pointers created if As2D is called
NPY_NO_EXPORT int PyArray_GetEndianness ( void  )
NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCFeatureVersion ( void  )
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_Concatenate().

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
NPY_NO_EXPORT npy_intp PyArray_MultiplyList ( npy_intp l1,
int  n 
)
Multiply a List

References NPY_MAX_INTP.

Referenced by get_decsrcref_fields_transfer_function(), and PyArray_ArgMax().

NPY_NO_EXPORT int PyArray_OrderConverter ( PyObject *  object,
NPY_ORDER val 
)
Convert an object to FORTRAN / C / ANY / KEEP

Leave the desired default from the caller for NULL/Py_None

Referenced by array_byteswap().

NPY_NO_EXPORT npy_intp PyArray_OverflowMultiplyList ( npy_intp l1,
int  n 
)
Multiply a List of Non-negative numbers with over-flow detection.
NPY_NO_EXPORT NPY_SCALARKIND PyArray_ScalarKind ( int  typenum,
PyArrayObject **  arr 
)
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 PyArray_CanCastSafely().

NPY_NO_EXPORT PyObject* PyArray_Where ( PyObject *  condition,
PyObject *  x,
PyObject *  y 
)
Where
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.

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

Referenced by _vec_string().


Variable Documentation

SIGJMP_BUF _NPY_SIGINT_BUF
struct PyMethodDef array_module_methods[] [static]
NPY_NO_EXPORT int NPY_NUMUSERTYPES = 0
NPY_NO_EXPORT PyTypeObject PyBigArray_Type
Internal APIs
Only here for API compatibility