numpy  2.0.0
src/multiarray/scalartypes.c.src File Reference
#include "Python.h"
#include "structmember.h"
#include "numpy/arrayobject.h"
#include "numpy/npy_math.h"
#include "numpy/halffloat.h"
#include "numpy/arrayscalars.h"
#include "npy_pycompat.h"
#include "npy_config.h"
#include "mapping.h"
#include "ctors.h"
#include "usertypes.h"
#include "numpyos.h"
#include "common.h"
#include "scalartypes.h"
#include "_datetime.h"
#include "datetime_strings.h"

Defines

#define PY_SSIZE_T_CLEAN
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define _MULTIARRAYMODULE
#define _FMT1   "%%.%i" NPY_@NAME@_FMT
#define _FMT2   "%%+.%i" NPY_@NAME@_FMT
#define _FMT1   "%%.%i" NPY_@NAME@_FMT
#define _FMT2   "%%+.%i" NPY_@NAME@_FMT
#define HALFPREC_REPR   5
#define HALFPREC_STR   5
#define FLOATPREC_REPR   8
#define FLOATPREC_STR   6
#define DOUBLEPREC_REPR   17
#define DOUBLEPREC_STR   12
#define LONGDOUBLEPREC_REPR   DOUBLEPREC_REPR
#define LONGDOUBLEPREC_STR   DOUBLEPREC_STR
#define PREC   @NAME@PREC_@KIND@
#define BASEFLAGS   Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES
#define LEAFFLAGS   Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES
#define _WORK(num)
#define _WORK1   _WORK(1)
#define _WORKz   _WORK(0)
#define _WORK0
#define _NPY_UNUSED2_1
#define _NPY_UNUSED2_z
#define _NPY_UNUSED2_0   NPY_UNUSED
#define _NPY_UNUSED1_0
#define _NPY_UNUSED1_1
#define _NPY_UNUSED1_2   NPY_UNUSED
#define NAME_bool   "bool"
#define NAME_void   "void"
#define NAME_string   "string"
#define NAME_unicode   "unicode"
#define _THIS_DOC   "Composed of two " _THIS_SIZE2 " bit floats"
#define NPY_SIZEOF_BYTE   1
#define _FROM_BSIZE   NPY_SIZEOF_@FROM_BASENAME@
#define _FROM_NUM   (NPY_@FROM_NAME@)
#define _TO_BSIZE   NPY_SIZEOF_@TO_BASENAME@
#define _TO_NUM   (NPY_@TO_NAME@)

Functions

static PyObject * gentype_alloc (PyTypeObject *type, Py_ssize_t nitems)
static void gentype_dealloc (PyObject *v)
static PyObject * gentype_power (PyObject *m1, PyObject *m2, PyObject *NPY_UNUSED(m3))
static PyObject * gentype_generic_method (PyObject *self, PyObject *args, PyObject *kwds, char *str)
static PyObject *gentype_ name (PyObject *m1, PyObject *m2)
static PyObject * gentype_multiply (PyObject *m1, PyObject *m2)
static PyObject *gentype_ name (PyObject *m1)
static int gentype_nonzero_number (PyObject *m1)
static PyObject * gentype_str (PyObject *self)
static PyObject * gentype_repr (PyObject *self)
NPY_NO_EXPORT void format_ name (char *buf, size_t buflen,@type @val, unsigned int prec)
NPY_NO_EXPORT void format_half (char *buf, size_t buflen, npy_half val, unsigned int prec)
static PyObject *name type_ form (PyObject *self)
static PyObject * datetimetype_repr (PyObject *self)
static PyObject * timedeltatype_repr (PyObject *self)
static PyObject * datetimetype_str (PyObject *self)
static PyObject * timedeltatype_str (PyObject *self)
static PyObject *name type_ kind (PyObject *self)
static int name type_print (PyObject *v, FILE *fp, int flags)
static PyObject * gentype_richcompare (PyObject *self, PyObject *other, int cmp_op)
static PyObject * gentype_ndim_get (PyObject *NPY_UNUSED(self))
static PyObject * gentype_flags_get (PyObject *NPY_UNUSED(self))
static PyObject * voidtype_flags_get (PyVoidScalarObject *self)
static PyObject * voidtype_dtypedescr_get (PyVoidScalarObject *self)
static PyObject * gentype_data_get (PyObject *self)
static PyObject * gentype_itemsize_get (PyObject *self)
static PyObject * gentype_size_get (PyObject *NPY_UNUSED(self))
NPY_NO_EXPORT void gentype_struct_free (void *ptr, void *arg)
static PyObject * gentype_struct_get (PyObject *self)
static PyObject * gentype_priority_get (PyObject *NPY_UNUSED(self))
static PyObject * gentype_shape_get (PyObject *NPY_UNUSED(self))
static PyObject * gentype_interface_get (PyObject *self)
static PyObject * gentype_typedescr_get (PyObject *self)
static PyObject * gentype_base_get (PyObject *NPY_UNUSED(self))
static PyArray_Descr_realdescr_fromcomplexscalar (PyObject *self, int *typenum)
static PyObject * gentype_real_get (PyObject *self)
static PyObject * gentype_imag_get (PyObject *self)
static PyObject * gentype_flat_get (PyObject *self)
static PyObject * gentype_transpose_get (PyObject *self)
static PyObject * gentype_getarray (PyObject *scalar, PyObject *args)
static PyObject * gentype_wraparray (PyObject *NPY_UNUSED(scalar), PyObject *args)
static PyObject * gentype_itemset (PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args))
static PyObject * gentype_squeeze (PyObject *self, PyObject *args)
static Py_ssize_t gentype_getreadbuf (PyObject *, Py_ssize_t, void **)
static PyObject * gentype_byteswap (PyObject *self, PyObject *args)
static PyObject *gentype_ name (PyObject *self, PyObject *args, PyObject *kwds)
static PyObject * voidtype_getfield (PyVoidScalarObject *self, PyObject *args, PyObject *kwds)
static PyObject * gentype_setfield (PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args), PyObject *NPY_UNUSED(kwds))
static PyObject * voidtype_setfield (PyVoidScalarObject *self, PyObject *args, PyObject *kwds)
static PyObject * gentype_reduce (PyObject *self, PyObject *NPY_UNUSED(args))
static PyObject * gentype_setstate (PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args))
static PyObject * gentype_dump (PyObject *self, PyObject *args)
static PyObject * gentype_dumps (PyObject *self, PyObject *args)
static PyObject * gentype_setflags (PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args), PyObject *NPY_UNUSED(kwds))
static PyObject *name _complex (PyObject *self, PyObject *NPY_UNUSED(args), PyObject *NPY_UNUSED(kwds))
static Py_ssize_t voidtype_length (PyVoidScalarObject *self)
static PyObject * voidtype_item (PyVoidScalarObject *self, Py_ssize_t n)
static PyObject * voidtype_subscript (PyVoidScalarObject *self, PyObject *ind)
static int voidtype_ass_item (PyVoidScalarObject *self, Py_ssize_t n, PyObject *val)
static int voidtype_ass_subscript (PyVoidScalarObject *self, PyObject *ind, PyObject *val)
static Py_ssize_t gentype_getsegcount (PyObject *self, Py_ssize_t *lenp)
static Py_ssize_t gentype_getcharbuf (PyObject *self, Py_ssize_t segment, constchar **ptrptr)
static void void_dealloc (PyVoidScalarObject *v)
static void object_arrtype_dealloc (PyObject *v)
static PyObject *name _arrtype_new (PyTypeObject *_NPY_UNUSED1_ @default @(type), PyObject *args, PyObject *_NPY_UNUSED2_ @work @(kwds))
static PyObject *name _arrtype_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * bool_arrtype_new (PyTypeObject *NPY_UNUSED(type), PyObject *args, PyObject *NPY_UNUSED(kwds))
static PyObject * bool_arrtype_and (PyObject *a, PyObject *b)
static PyObject * bool_arrtype_or (PyObject *a, PyObject *b)
static PyObject * bool_arrtype_xor (PyObject *a, PyObject *b)
static int bool_arrtype_nonzero (PyObject *a)
static PyObject * void_arrtype_new (PyTypeObject *type, PyObject *args, PyObject *NPY_UNUSED(kwds))
static long lname _arrtype_hash (PyObject *obj)
static long char longlong_arrtype_hash (PyObject *obj)
static long half_arrtype_hash (PyObject *obj)
static long object_arrtype_hash (PyObject *obj)
static long void_arrtype_hash (PyObject *obj)
static PyObject * object_arrtype_getattro (PyObjectScalarObject *obj, PyObject *attr)
static int object_arrtype_setattro (PyObjectScalarObject *obj, PyObject *attr, PyObject *val)
static PyObject * object_arrtype_concat (PyObjectScalarObject *self, PyObject *other)
static Py_ssize_t object_arrtype_length (PyObjectScalarObject *self)
static PyObject * object_arrtype_repeat (PyObjectScalarObject *self, Py_ssize_t count)
static PyObject * object_arrtype_subscript (PyObjectScalarObject *self, PyObject *key)
static int object_arrtype_ass_subscript (PyObjectScalarObject *self, PyObject *key, PyObject *value)
static int object_arrtype_contains (PyObjectScalarObject *self, PyObject *ob)
static PyObject * object_arrtype_inplace_concat (PyObjectScalarObject *self, PyObject *o)
static PyObject * object_arrtype_inplace_repeat (PyObjectScalarObject *self, Py_ssize_t count)
static Py_ssize_t object_arrtype_getsegcount (PyObjectScalarObject *self, Py_ssize_t *lenp)
static Py_ssize_t object_arrtype_getreadbuf (PyObjectScalarObject *self, Py_ssize_t segment, void **ptrptr)
static Py_ssize_t object_arrtype_getwritebuf (PyObjectScalarObject *self, Py_ssize_t segment, void **ptrptr)
static Py_ssize_t object_arrtype_getcharbuf (PyObjectScalarObject *self, Py_ssize_t segment, constchar **ptrptr)
static PyObject * object_arrtype_call (PyObjectScalarObject *obj, PyObject *args, PyObject *kwds)
static PyObject * gen_arrtype_subscript (PyObject *self, PyObject *key)
NPY_NO_EXPORT void initialize_casting_tables (void)
NPY_NO_EXPORT void initialize_numeric_types (void)
NPY_NO_EXPORT int _typenum_fromtypeobj (PyObject *type, int user)

Variables

NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues []
NPY_NO_EXPORT PyTypeObject PyTimeIntegerArrType_Type
NPY_NO_EXPORT PyTypeObject Py NAME ArrType_Type
static char * _datetime_verbose_strings [NPY_DATETIME_NUMUNITS]
static PyNumberMethods gentype_as_number
static PyGetSetDef gentype_getsets []
static char doc_getarray [] = "sc.__array__(|type) return 0-dim array"
static char doc_sc_wraparray [] = "sc.__array_wrap__(obj) return scalar from array"
static PyMethodDef gentype_methods []
static PyGetSetDef voidtype_getsets []
static PyMethodDef voidtype_methods []
static PyMethodDef name type_methods []
static PyMappingMethods voidtype_as_mapping
static PySequenceMethods voidtype_as_sequence
static PyBufferProcs gentype_as_buffer
NPY_NO_EXPORT PyTypeObject PyGenericArrType_Type
NPY_NO_EXPORT PyNumberMethods bool_arrtype_as_number
static PySequenceMethods object_arrtype_as_sequence
static PyMappingMethods object_arrtype_as_mapping
static PyBufferProcs object_arrtype_as_buffer
NPY_NO_EXPORT PyTypeObject PyObjectArrType_Type
static PyMappingMethods gentype_as_mapping
static PyNumberMethods longdoubletype_as_number
static PyNumberMethods clongdoubletype_as_number
static PyTypeObject * typeobjects []

Define Documentation

#define _FMT1   "%%.%i" NPY_@NAME@_FMT
begin repeat
name = float, double, longdouble# #NAME = FLOAT, DOUBLE, LONGDOUBLE# #type = npy_float, npy_double, npy_longdouble# suff = f, d, l#
end repeat*
begin repeat
name = cfloat, cdouble, clongdouble# #NAME = FLOAT, DOUBLE, LONGDOUBLE# #type = npy_cfloat, npy_cdouble, npy_clongdouble# suff = f, d, l#
#define _FMT1   "%%.%i" NPY_@NAME@_FMT
begin repeat
name = float, double, longdouble# #NAME = FLOAT, DOUBLE, LONGDOUBLE# #type = npy_float, npy_double, npy_longdouble# suff = f, d, l#
end repeat*
begin repeat
name = cfloat, cdouble, clongdouble# #NAME = FLOAT, DOUBLE, LONGDOUBLE# #type = npy_cfloat, npy_cdouble, npy_clongdouble# suff = f, d, l#
#define _FMT2   "%%+.%i" NPY_@NAME@_FMT
#define _FMT2   "%%+.%i" NPY_@NAME@_FMT
#define _FROM_BSIZE   NPY_SIZEOF_@FROM_BASENAME@
#define _FROM_NUM   (NPY_@FROM_NAME@)

Referenced by _arrtype_hash().

#define _NPY_UNUSED1_0
#define _NPY_UNUSED1_1
#define _NPY_UNUSED1_2   NPY_UNUSED
#define _NPY_UNUSED2_0   NPY_UNUSED
#define _NPY_UNUSED2_1
begin repeat
name = byte, short, int, long, longlong, ubyte, ushort, uint, ulong,
ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, object#
#Name = Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong,
ULongLong, Half, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, String, Unicode, Object#
TYPE = BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG,
ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, OBJECT#
System Message: WARNING/2 (<string>, line 11) Definition list ends without a blank line; unexpected unindent.

#work = 0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,z,z,0# #default = 0*17,1*2,2#

#define _NPY_UNUSED2_z
#define _THIS_DOC   "Composed of two " _THIS_SIZE2 " bit floats"
begin repeat
#NAME = CFloat, CDouble, CLongDouble# name = complex*3# #CNAME = FLOAT, DOUBLE, LONGDOUBLE#
#define _TO_BSIZE   NPY_SIZEOF_@TO_BASENAME@
#define _TO_NUM   (NPY_@TO_NAME@)

Referenced by _arrtype_hash().

#define _WORK (   num)
Value:
if (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) { \
        PyTypeObject *sup; \ \
        sup = (PyTypeObject *)PyTuple_GET_ITEM(type->tp_bases, num); \
        robj = sup->tp_new(type, args, kwds); \
        if (robj != NULL) goto finish;              \
        if (PyTuple_GET_SIZE(args)!=1) return NULL; \
        PyErr_Clear(); \ \
    }
string and unicode inherit from Python Type first and so GET_ITEM is different to get to the Python Type.

ok is a work-around for a bug in complex_new that doesn't allocate
memory from the sub-types memory allocator.
#define _WORK0
#define _WORK1   _WORK(1)
#define _WORKz   _WORK(0)
#define BASEFLAGS   Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES
#define DOUBLEPREC_REPR   17
#define DOUBLEPREC_STR   12
#define FLOATPREC_REPR   8
#define FLOATPREC_STR   6
#define HALFPREC_REPR   5
The REPR values are finfo.precision + 2
#define HALFPREC_STR   5
#define LEAFFLAGS   Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES
#define NAME_bool   "bool"
#define NAME_string   "string"
#define NAME_unicode   "unicode"
#define NAME_void   "void"
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define NPY_SIZEOF_BYTE   1
#define PREC   @NAME@PREC_@KIND@
float type str and repr
These functions will return NULL if PyString creation fails.
begin repeat
name = half, float, double, longdouble# #Name = Half, Float, Double, LongDouble# #NAME = HALF, FLOAT, DOUBLE, LONGDOUBLE# #hascomplex = 0, 1, 1, 1#
begin repeat1
kind = str, repr# #KIND = STR, REPR#

Function Documentation

static long c lname _arrtype_hash ( PyObject *  obj) [static]
********** Define Hash functions ***************
begin repeat
#lname = bool, ubyte, ushort# name = Bool,UByte, UShort#
end repeat*
begin repeat
#lname = byte, short, uint, ulong# name = Byte, Short, UInt, ULong#
end repeat*
begin repeat
#lname = datetime, timedelta# name = Datetime, Timedelta#
end repeat*
Wrong thing to do for longdouble, but....
begin repeat
#lname = float, longdouble# name = Float, LongDouble#
borrowed from complex_hash

References _FROM_NUM, _TO_NUM, NPY_DATETIME, NPY_STRING, NPY_TIMEDELTA, NPY_UNICODE, and NPY_VOID.

static PyObject* name _arrtype_new ( PyTypeObject *_NPY_UNUSED1_ @default @  type,
PyObject *  args,
PyObject *_NPY_UNUSED2_ @work @  kwds 
) [static]
allow base-class (if any) to do conversion If successful, this will jump to finish:
typecode is new reference and stolen by PyArray_FromAny but not PyArray_Scalar
It is expected at this point that robj is a PyArrayScalar (even for Object Data Type)
0-d array
In OBJECT case, robj is no longer a PyArrayScalar at this point but the remaining code assumes it is
Normal return
This return path occurs when the requested type is not created but another scalar object is created instead (i.e. when the base-class does the conversion in _WORK macro)
Need to allocate new type and copy data-area over
typecode will be NULL
static PyObject* name _arrtype_new ( PyTypeObject *  type,
PyObject *  args,
PyObject *  kwds 
) [static]
end repeat*
begin repeat
name = datetime, timedelta# #Name = Datetime, Timedelta# #NAME = DATETIME, TIMEDELTA# #is_datetime = 1, 0#
Allocate the return scalar
Incorporate the metadata if its provided
Parse the provided metadata input
A unit of -1 signals that convert_pyobject_to_datetime should populate.
Make datetime default to NaT, timedelta default to zero
static PyObject* name _complex ( PyObject *  self,
PyObject *  NPY_UNUSEDargs,
PyObject *  NPY_UNUSEDkwds 
) [static]
casting complex numbers (that don't inherit from Python complex) to Python complex
begin repeat
name = cfloat, clongdouble# #Name = CFloat, CLongDouble#

Referenced by voidtype_setfield().

static PyArray_Descr* _realdescr_fromcomplexscalar ( PyObject *  self,
int *  typenum 
) [static]
NPY_NO_EXPORT int _typenum_fromtypeobj ( PyObject *  type,
int  user 
)
Search any registered types
static PyObject* bool_arrtype_and ( PyObject *  a,
PyObject *  b 
) [static]
static PyObject* bool_arrtype_new ( PyTypeObject *  NPY_UNUSEDtype,
PyObject *  args,
PyObject *  NPY_UNUSEDkwds 
) [static]
end repeat*
bool->tp_new only returns Py_True or Py_False
static int bool_arrtype_nonzero ( PyObject *  a) [static]
static PyObject* bool_arrtype_or ( PyObject *  a,
PyObject *  b 
) [static]
static PyObject* bool_arrtype_xor ( PyObject *  a,
PyObject *  b 
) [static]
static PyObject* datetimetype_repr ( PyObject *  self) [static]
end repeat*
Because we're defaulting to local time, display hours with minutes precision, so that 30-minute timezone offsets can work.
For straight units or generic units, the unit will be deduced from the string, so it's not necessary to specify it.
static PyObject* datetimetype_str ( PyObject *  self) [static]
Because we're defaulting to local time, display hours with minutes precision, so that 30-minute timezone offsets can work.

References name, and Py_TYPE.

static PyObject* name type_ form ( PyObject *  self) [static]
over-ride repr and str of array-scalar strings and unicode to remove NULL bytes and then call the corresponding functions of string and unicode.
begin repeat
name = string*2,unicode*2# form = (repr,str)*2# #Name = String*2,Unicode*2# #NAME = STRING*2,UNICODE*2# #extra = AndSize*2,,# #type = npy_char*2, Py_UNICODE*2#
NPY_NO_EXPORT void format_half ( char *  buf,
size_t  buflen,
npy_half  val,
unsigned int  prec 
)
end repeat*
static PyObject* gen_arrtype_subscript ( PyObject *  self,
PyObject *  key 
) [static]
Only [...], [...,<???>], [<???>, ...], is allowed for indexing a scalar
These return a new N-d array with a copy of the data where N is the number of None's in <???>.
Must be a Tuple
static PyObject* gentype_alloc ( PyTypeObject *  type,
Py_ssize_t  nitems 
) [static]
end repeat*
static PyObject* gentype_base_get ( PyObject *  NPY_UNUSEDself) [static]
static PyObject* gentype_byteswap ( PyObject *  self,
PyObject *  args 
) [static]
get the data, copyswap it and pass it to a new Array scalar
static PyObject* gentype_data_get ( PyObject *  self) [static]
static void gentype_dealloc ( PyObject *  v) [static]
static PyObject* gentype_dump ( PyObject *  self,
PyObject *  args 
) [static]

Referenced by gentype_wraparray().

static PyObject* gentype_dumps ( PyObject *  self,
PyObject *  args 
) [static]
static PyObject* gentype_flags_get ( PyObject *  NPY_UNUSEDself) [static]
static PyObject* gentype_flat_get ( PyObject *  self) [static]
static PyObject* gentype_generic_method ( PyObject *  self,
PyObject *  args,
PyObject *  kwds,
char *  str 
) [static]

References PyArray_FromScalar().

static PyObject* gentype_getarray ( PyObject *  scalar,
PyObject *  args 
) [static]

References gentype_wraparray().

static Py_ssize_t gentype_getcharbuf ( PyObject *  self,
Py_ssize_t  segment,
constchar **  ptrptr 
) [static]
!defined(NPY_PY3K)
static Py_ssize_t gentype_getreadbuf ( PyObject *  self,
Py_ssize_t  segment,
void **  ptrptr 
) [static]
static Py_ssize_t gentype_getsegcount ( PyObject *  self,
Py_ssize_t *  lenp 
) [static]

References NPY_MAX_INT.

static PyObject* gentype_imag_get ( PyObject *  self) [static]
static PyObject* gentype_interface_get ( PyObject *  self) [static]
static PyObject* gentype_itemset ( PyObject *  NPY_UNUSEDself,
PyObject *  NPY_UNUSEDargs 
) [static]
end repeat*
static PyObject* gentype_itemsize_get ( PyObject *  self) [static]
static PyObject* gentype_multiply ( PyObject *  m1,
PyObject *  m2 
) [static]
end repeat*
Try to convert m2 to an int and try sequence repeat
Try to convert m1 to an int and try sequence repeat

<

no effect if not set
static PyObject* gentype_ndim_get ( PyObject *  NPY_UNUSEDself) [static]
static int gentype_nonzero_number ( PyObject *  m1) [static]
end repeat*
static PyObject* gentype_power ( PyObject *  m1,
PyObject *  m2,
PyObject *  NPY_UNUSEDm3 
) [static]
static PyObject* gentype_priority_get ( PyObject *  NPY_UNUSEDself) [static]
static PyObject* gentype_real_get ( PyObject *  self) [static]
static PyObject* gentype_reduce ( PyObject *  self,
PyObject *  NPY_UNUSEDargs 
) [static]
Return a tuple of (callable object, arguments)
We need to expand the buffer so that we always write UCS4 to disk for pickle of unicode scalars.
This could be in a unicode_reduce function, but that would require re-factoring.

References voidtype_getfield().

static PyObject* gentype_repr ( PyObject *  self) [static]
XXX: Why are we using str here?
static PyObject* gentype_richcompare ( PyObject *  self,
PyObject *  other,
int  cmp_op 
) [static]
static PyObject* gentype_setfield ( PyObject *  NPY_UNUSEDself,
PyObject *  NPY_UNUSEDargs,
PyObject *  NPY_UNUSEDkwds 
) [static]
static PyObject* gentype_setflags ( PyObject *  NPY_UNUSEDself,
PyObject *  NPY_UNUSEDargs,
PyObject *  NPY_UNUSEDkwds 
) [static]
setting flags cannot be done for scalars
static PyObject* gentype_setstate ( PyObject *  NPY_UNUSEDself,
PyObject *  NPY_UNUSEDargs 
) [static]
ignores everything

Referenced by gentype_wraparray().

static PyObject* gentype_shape_get ( PyObject *  NPY_UNUSEDself) [static]
static PyObject* gentype_size_get ( PyObject *  NPY_UNUSEDself) [static]
static PyObject* gentype_squeeze ( PyObject *  self,
PyObject *  args 
) [static]
static PyObject* gentype_str ( PyObject *  self) [static]
NPY_NO_EXPORT void gentype_struct_free ( void *  ptr,
void *  arg 
)
static PyObject* gentype_struct_get ( PyObject *  self) [static]
static PyObject* gentype_transpose_get ( PyObject *  self) [static]
static PyObject* gentype_typedescr_get ( PyObject *  self) [static]
static PyObject* gentype_wraparray ( PyObject *  NPY_UNUSEDscalar,
PyObject *  args 
) [static]
static long half_arrtype_hash ( PyObject *  obj) [static]
end repeat*
end repeat*
Default for built-in types is object scalar
Default for next largest type is -1, signalling no bigger
Compile-time loop of scalar kinds
begin repeat
#NAME = BOOL,
BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
#BIGGERTYPE = -1,
NPY_SHORT, NPY_USHORT, NPY_INT, NPY_UINT, NPY_LONG, NPY_ULONG, NPY_LONGLONG, NPY_ULONGLONG, -1, -1, NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE, -1, NPY_CDOUBLE, NPY_CLONGDOUBLE, -1#
#SCKIND = BOOL,
(INTNEG, INTPOS)*5, FLOAT*4, COMPLEX*3#
end repeat*
Identity
Bool -> <Anything> except datetime (since
it conceptually has no zero)
<Anything> -> Object
<Anything> -> Void
Compile-time loop of casting rules
begin repeat
#FROM_NAME = BYTE, UBYTE, SHORT, USHORT, INT, UINT,
LONG, ULONG, LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
#FROM_BASENAME = BYTE, BYTE, SHORT, SHORT, INT, INT,
LONG, LONG, LONGLONG, LONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, FLOAT, DOUBLE, LONGDOUBLE#
#from_isint = 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0#
#from_isuint = 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 0, 0, 0, 0, 0, 0#
#from_isfloat = 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0, 0#
#from_iscomplex = 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 1#
Allow casts from any integer to the TIMEDELTA type
begin repeat1
#TO_NAME = BYTE, UBYTE, SHORT, USHORT, INT, UINT,
LONG, ULONG, LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
#TO_BASENAME = BYTE, BYTE, SHORT, SHORT, INT, INT,
LONG, LONG, LONGLONG, LONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, FLOAT, DOUBLE, LONGDOUBLE#
#to_isint = 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0#
#to_isuint = 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 0, 0, 0, 0, 0, 0#
#to_isfloat = 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0, 0#
#to_iscomplex = 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 1#
NOTE: _FROM_BSIZE and _TO_BSIZE are the sizes of the "base type"
which is the same as the size of the type except for complex, where it is the size of the real type.
end repeat1*
end repeat*
Now that the _can_cast_safely table is finished, we can use it to build the _type_promotion table
Don't let number promote to string/unicode/void/datetime/timedelta
Promoting these types requires examining their contents
Except they can convert to OBJECT
Don't let number promote to string/unicode/void
If there's no kind (void/string/etc)
Start with the type of larger kind
Try the next larger type of this kind
If there is no larger, try a larger kind
Use -1 to signal no promoted type found
begin repeat
#NAME= Number, Integer, SignedInteger, UnsignedInteger, Inexact,
Floating, ComplexFloating, Flexible, Character#
end repeat*
begin repeat
name = bool, byte, short, int, long, longlong, ubyte, ushort, uint,
ulong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, void, object, datetime, timedelta#
#NAME = Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt,
ULong, ULongLong, Half, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, String, Unicode, Void, Object, Datetime, Timedelta#
end repeat*
begin repeat
name = bool, byte, short, ubyte, ushort, uint, ulong, ulonglong,
half, float, longdouble, cfloat, clongdouble, void, object, datetime, timedelta#
#NAME = Bool, Byte, Short, UByte, UShort, UInt, ULong, ULongLong,
Half, Float, LongDouble, CFloat, CLongDouble, Void, Object, Datetime, Timedelta#
end repeat*
begin repeat
name = cfloat, clongdouble# #NAME = CFloat, CLongDouble#
end repeat*
begin repeat
name = repr, str#
end repeat*
These need to be coded specially because getitem does not return a normal Python type
begin repeat
name = int, float, repr, str# kind = tp_as_number->nb*2, tp*2#
end repeat*
begin repeat
name = long, hex, oct# kind = tp_as_number->nb*3#
end repeat*
static PyObject* name type_ kind ( PyObject *  self) [static]

Referenced by _getitem(), and npy_asinh().

static long char longlong_arrtype_hash ( PyObject *  obj) [static]
end repeat*
begin repeat
#char = ,u# #Char = ,U# #ext = && (x >= LONG_MIN),#
static PyObject *gentype_ name ( PyObject *  self,
PyObject *  args 
) [static]
begin repeat <blockquote>

name = add, subtract, remainder, divmod, lshift, rshift,
and, xor, or, floor_divide, true_divide#

</blockquote>

end repeat*
begin repeat <blockquote> name = divide#</blockquote>
These gentype_* functions do not take keyword arguments. The proper flag is METH_VARARGS.
begin repeat <blockquote>

name = tolist, item, tostring, astype, copy, __deepcopy__, searchsorted,
view, swapaxes, conj, conjugate, nonzero, flatten, ravel, fill, transpose, newbyteorder#

</blockquote>

static PyObject *char longdoubletype_ name ( PyObject *  self) [static]
begin repeat <blockquote> name = positive, negative, absolute, invert, int, float#</blockquote>
end repeat*
begin repeat <blockquote> name = long, oct, hex#</blockquote>
end repeat*
Could improve this with a PyLong_FromLongDouble(longdouble ldval) but this would need some more work...
begin repeat <blockquote> name = (int, float)*2# #KIND = (Long, Float)*2# #char = ,,c*2# #CHAR = ,,C*2# #POST = ,,.real*2#</blockquote>
end repeat*
begin repeat <blockquote> name = (long, hex, oct)*2# #KIND = (Long*3)*2# #char = ,,,c*3# #CHAR = ,,,C*3# #POST = ,,,.real*3#</blockquote>
static void format_ name ( char *  buf,
size_t  buflen,
@type @  val,
unsigned int  prec 
)
XXX: Find a correct size here for format string
If nothing but digits after sign, append ".0"
XXX: Find a correct size here for format string
Ideally, we should handle this nan/inf stuff in NumpyOS_ascii_format*
FIXME We need a better way to handle the error message
FIXME We need a better way to handle the error message
static PyObject* gentype_ name ( PyObject *  self,
PyObject *  args,
PyObject *  kwds 
) [static]
These gentype_* functions take keyword arguments. The proper flag is METH_VARARGS | METH_KEYWORDS.
begin repeat <blockquote>

name = take, getfield, put, repeat, tofile, mean, trace, diagonal, clip,
std, var, sum, cumsum, prod, cumprod, compress, sort, argsort, round, argmax, argmin, max, min, ptp, any, all, resize, reshape, choose#

</blockquote>

static int object_arrtype_ass_subscript ( PyObjectScalarObject self,
PyObject *  key,
PyObject *  value 
) [static]
static PyObject* object_arrtype_call ( PyObjectScalarObject obj,
PyObject *  args,
PyObject *  kwds 
) [static]
static PyObject* object_arrtype_concat ( PyObjectScalarObject self,
PyObject *  other 
) [static]
static int object_arrtype_contains ( PyObjectScalarObject self,
PyObject *  ob 
) [static]
static void object_arrtype_dealloc ( PyObject *  v) [static]
static PyObject* object_arrtype_getattro ( PyObjectScalarObject obj,
PyObject *  attr 
) [static]
object arrtype getattro and setattro
first look in object and then hand off to generic type
static Py_ssize_t object_arrtype_getcharbuf ( PyObjectScalarObject self,
Py_ssize_t  segment,
constchar **  ptrptr 
) [static]
static Py_ssize_t object_arrtype_getreadbuf ( PyObjectScalarObject self,
Py_ssize_t  segment,
void **  ptrptr 
) [static]
static Py_ssize_t object_arrtype_getsegcount ( PyObjectScalarObject self,
Py_ssize_t *  lenp 
) [static]
static Py_ssize_t object_arrtype_getwritebuf ( PyObjectScalarObject self,
Py_ssize_t  segment,
void **  ptrptr 
) [static]
static long object_arrtype_hash ( PyObject *  obj) [static]
static PyObject* object_arrtype_inplace_concat ( PyObjectScalarObject self,
PyObject *  o 
) [static]
static PyObject* object_arrtype_inplace_repeat ( PyObjectScalarObject self,
Py_ssize_t  count 
) [static]
static Py_ssize_t object_arrtype_length ( PyObjectScalarObject self) [static]
static PyObject* object_arrtype_repeat ( PyObjectScalarObject self,
Py_ssize_t  count 
) [static]
static int object_arrtype_setattro ( PyObjectScalarObject obj,
PyObject *  attr,
PyObject *  val 
) [static]
first look in object and then hand off to generic type
static PyObject* object_arrtype_subscript ( PyObjectScalarObject self,
PyObject *  key 
) [static]
static PyObject* timedeltatype_repr ( PyObject *  self) [static]
The value
Can't use "lld" in Python < 2.7, Python3 < 3.2, or if HAVE_LONG_LONG is not defined
The metadata unit

References name.

static PyObject* timedeltatype_str ( PyObject *  self) [static]
Can't use "lld" in Python < 2.7, Python3 < 3.2, or if HAVE_LONG_LONG is not defined

References Py_TYPE, and PyArray_FromScalar().

static int name type_print ( PyObject *  v,
FILE *  fp,
int  flags 
) [static]
end repeat1*
end repeat*
float type print (control print a, where a is a float type instance)
begin repeat
name = half, float, double, longdouble# #Name = Half, Float, Double, LongDouble# #NAME = HALF, FLOAT, DOUBLE, LONGDOUBLE# #hascomplex = 0, 1, 1, 1#
static long void_arrtype_hash ( PyObject *  obj) [static]
just hash the pointer
static PyObject* void_arrtype_new ( PyTypeObject *  type,
PyObject *  args,
PyObject *  NPY_UNUSEDkwds 
) [static]
For a VOID scalar first see if obj is an integer or long and create new memory of that size (filled with 0) for the scalar
static void void_dealloc ( PyVoidScalarObject v) [static]
static int voidtype_ass_item ( PyVoidScalarObject self,
Py_ssize_t  n,
PyObject *  val 
) [static]

Referenced by gentype_dumps().

static int voidtype_ass_subscript ( PyVoidScalarObject self,
PyObject *  ind,
PyObject *  val 
) [static]
look up in fields
try to convert it to a number

References PyArrayScalar_RETURN_FALSE.

static PyObject* voidtype_dtypedescr_get ( PyVoidScalarObject self) [static]
static PyObject* voidtype_flags_get ( PyVoidScalarObject self) [static]
static PyObject* voidtype_getfield ( PyVoidScalarObject self,
PyObject *  args,
PyObject *  kwds 
) [static]
end repeat*

Referenced by gentype_reduce(), and voidtype_setfield().

static PyObject* voidtype_item ( PyVoidScalarObject self,
Py_ssize_t  n 
) [static]

Referenced by gentype_dumps(), and voidtype_setfield().

static Py_ssize_t voidtype_length ( PyVoidScalarObject self) [static]
end repeat*
******* As_mapping functions for void array scalar *******
return the number of fields

Referenced by gentype_dumps(), and voidtype_setfield().

static PyObject* voidtype_setfield ( PyVoidScalarObject self,
PyObject *  args,
PyObject *  kwds 
) [static]
static PyObject* voidtype_subscript ( PyVoidScalarObject self,
PyObject *  ind 
) [static]
get field by name or number
look up in fields
try to convert it to a number

Referenced by voidtype_setfield().


Variable Documentation

Initial value:
 {
    "years",
    "months",
    "weeks",
    "<invalid>",
    "days",
    "hours",
    "minutes",
    "seconds",
    "milliseconds",
    "microseconds",
    "nanoseconds",
    "picoseconds",
    "femtoseconds",
    "attoseconds",
    "generic time units"
}
Initial value:
 {
    {PyObject_HEAD_INIT(&PyBoolArrType_Type) 0},
    {PyObject_HEAD_INIT(&PyBoolArrType_Type) 1},
}
NPY_NO_EXPORT PyTypeObject Py NAME ArrType_Type
Inheritance is established later when tp_bases is set (or tp_base for single inheritance)
begin repeat
name = number, integer, signedinteger, unsignedinteger, inexact,
floating, complexfloating, flexible, character#
#NAME = Number, Integer, SignedInteger, UnsignedInteger, Inexact,
Floating, ComplexFloating, Flexible, Character#
begin repeat
name = bool, string, unicode, void# #NAME = Bool, String, Unicode, Void# #ex = _,_,_,#
end repeat*
begin repeat
#NAME = Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong,
ULongLong, Half, Float, Double, LongDouble, Datetime, Timedelta#
System Message: WARNING/2 (<string>, line 4) Definition list ends without a blank line; unexpected unindent.

name = int*5, uint*5, float*4, datetime, timedelta# #CNAME = (CHAR, SHORT, INT, LONG, LONGLONG)*2, HALF, FLOAT, DOUBLE,

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

<blockquote class="last"> LONGDOUBLE, DATETIME, TIMEDELTA#</blockquote>

Referenced by OBJECT_dot(), and OBJECT_fillwithscalar().

Arithmetic methods -- only so we can override &, |, ^.

System Message: WARNING/2 (<string>, line 1); backlink Inline substitution_reference start-string without end-string.
PyNumberMethods clongdoubletype_as_number [static]
char doc_getarray[] = "sc.__array__(|type) return 0-dim array" [static]
0-dim array from scalar object
char doc_sc_wraparray[] = "sc.__array_wrap__(obj) return scalar from array" [static]
PyBufferProcs gentype_as_buffer [static]
PyMappingMethods gentype_as_mapping [static]
Initial value:
 {
    NULL,
    (binaryfunc)gen_arrtype_subscript,
    NULL
}
end repeat*
PyNumberMethods gentype_as_number [static]
end repeat*

<

!defined(NPY_PY3K)
PyGetSetDef gentype_getsets[] [static]
PyMethodDef gentype_methods[] [static]
end repeat*
need to fill in doc-strings for these methods on import -- copy from array docstrings
PyNumberMethods longdoubletype_as_number [static]
PyBufferProcs object_arrtype_as_buffer [static]
Initial value:
 {







    (getreadbufferproc)object_arrtype_getreadbuf,
    (getwritebufferproc)object_arrtype_getwritebuf,
    (getsegcountproc)object_arrtype_getsegcount,
    (getcharbufferproc)object_arrtype_getcharbuf,






}
PyMappingMethods object_arrtype_as_mapping [static]
Initial value:
PySequenceMethods object_arrtype_as_sequence [static]
TimeInteger is deleted, but still here to fill the API slot
PyMethodDef name type_methods[] [static]
Initial value:
 {
    {"__complex__",
        (PyCFunction)@name@_complex,
        METH_VARARGS | METH_KEYWORDS, NULL},
    {NULL, NULL, 0, NULL}
}
begin repeat
name = cfloat,clongdouble#
PyTypeObject* typeobjects[] [static]
Initial value:
 {
    &PyBoolArrType_Type,
    &PyByteArrType_Type,
    &PyUByteArrType_Type,
    &PyShortArrType_Type,
    &PyUShortArrType_Type,
    &PyIntArrType_Type,
    &PyUIntArrType_Type,
    &PyLongArrType_Type,
    &PyULongArrType_Type,
    &PyLongLongArrType_Type,
    &PyULongLongArrType_Type,
    &PyFloatArrType_Type,
    &PyDoubleArrType_Type,
    &PyLongDoubleArrType_Type,
    &PyCFloatArrType_Type,
    &PyCDoubleArrType_Type,
    &PyCLongDoubleArrType_Type,
    &PyObjectArrType_Type,
    &PyStringArrType_Type,
    &PyUnicodeArrType_Type,
    &PyVoidArrType_Type,
    &PyDatetimeArrType_Type,
    &PyTimedeltaArrType_Type,
    &PyHalfArrType_Type
}
the order of this table is important
PyMappingMethods voidtype_as_mapping [static]
Initial value:
 {






    (inquiry)voidtype_length,                    

    (binaryfunc)voidtype_subscript,              
    (objobjargproc)voidtype_ass_subscript,       
}
PySequenceMethods voidtype_as_sequence [static]
PyGetSetDef voidtype_getsets[] [static]
Initial value:
 {
    {"flags",
        (getter)voidtype_flags_get,
        (setter)0,
        "integer value of flags",
        NULL},
    {"dtype",
        (getter)voidtype_dtypedescr_get,
        (setter)0,
        "dtype object",
        NULL},
    {NULL, NULL, NULL, NULL, NULL}
}
PyMethodDef voidtype_methods[] [static]
Initial value:
 {
    {"getfield",
        (PyCFunction)voidtype_getfield,
        METH_VARARGS | METH_KEYWORDS, NULL},
    {"setfield",
        (PyCFunction)voidtype_setfield,
        METH_VARARGS | METH_KEYWORDS, NULL},
    {NULL, NULL, 0, NULL}
}