numpy 2.0.0
src/multiarray/common.c File Reference
#include <Python.h>
#include "numpy/arrayobject.h"
#include "npy_config.h"
#include "numpy/npy_3kcompat.h"
#include "usertypes.h"
#include "common.h"
#include "buffer.h"

Defines

#define PY_SSIZE_T_CLEAN
#define NPY_NO_DEPRECATED_API
#define _MULTIARRAYMODULE
#define NPY_NO_PREFIX

Functions

NPY_NO_EXPORT PyArray_Descr_array_find_python_scalar_type (PyObject *op)
static PyArray_Descr_use_default_type (PyObject *op)
NPY_NO_EXPORT PyArray_Descr_array_find_type (PyObject *op, PyArray_Descr *minitype, int max)
NPY_NO_EXPORT PyArray_Descr_array_typedescr_fromstr (char *str)
NPY_NO_EXPORT char * index2ptr (PyArrayObject *mp, intp i)
NPY_NO_EXPORT int _zerofill (PyArrayObject *ret)
NPY_NO_EXPORT int _IsAligned (PyArrayObject *ap)
NPY_NO_EXPORT Bool _IsWriteable (PyArrayObject *ap)

Define Documentation

#define _MULTIARRAYMODULE
#define NPY_NO_DEPRECATED_API
#define NPY_NO_PREFIX
#define PY_SSIZE_T_CLEAN

Function Documentation

NPY_NO_EXPORT PyArray_Descr* _array_find_python_scalar_type ( PyObject *  op)

bools are a subclass of int
if integer can fit into a longlong then return that

References PyArray_BOOL, PyArray_CDOUBLE, PyArray_DescrFromType(), PyArray_DOUBLE, PyArray_LONG, PyArray_LONGLONG, and PyArray_OBJECT.

NPY_NO_EXPORT PyArray_Descr* _array_find_type ( PyObject *  op,
PyArray_Descr minitype,
int  max 
)
op is an object to be converted to an ndarray.
minitype is the minimum type-descriptor needed.
max is the maximum number of dimensions -- used for recursive call to avoid infinite recursion...

These need to come first because if op already carries a descr structure, then we want it to be the result if minitype is NULL.
VOID Arrays should not occur by "default" unless input was already a VOID

References PyArray_DESCR.

NPY_NO_EXPORT PyArray_Descr* _array_typedescr_fromstr ( char *  str)
new reference

Need to make a new PyArray_Descr

References NPY_BOOL.

NPY_NO_EXPORT int _IsAligned ( PyArrayObject ap)

The special casing for STRING and VOID types was removed in accordance with http://projects.scipy.org/numpy/ticket/1227 It used to be that IsAligned always returned True for these types, which is indeed the case when they are created using PyArray_DescrConverter(), but not necessarily when using PyArray_DescrAlignConverter().

Referenced by array_trace(), and PyArray_UpdateFlags().

NPY_NO_EXPORT Bool _IsWriteable ( PyArrayObject ap)

If we own our own data, then no-problem
Get to the final base object If it is a writeable array, then return TRUE If we can find an array object or a writeable buffer object as the final base object or a string object (for pickling support memory savings).

  • this last could be removed if a proper pickleable buffer was added to Python.
here so pickle support works seamlessly and unpickled array can be set and reset writeable -- could be abused --

Referenced by PyArray_UpdateFlags().

static PyArray_Descr* _use_default_type ( PyObject *  op) [static]
NPY_NO_EXPORT int _zerofill ( PyArrayObject ret)
NPY_NO_EXPORT char* index2ptr ( PyArrayObject mp,
intp  i 
)

Referenced by array_length().