#ifndef NDARRAYTYPES_H
#define NDARRAYTYPES_H
#include "npy_common.h"
#include "npy_endian.h"
#include "npy_cpu.h"
#include "utils.h"
#define NPY_NO_EXPORT NPY_VISIBILITY_HIDDEN
/* Only use thread if configured in config and python supports it */
#if defined WITH_THREAD && !NPY_NO_SMP
#define NPY_ALLOW_THREADS 1
#else
#define NPY_ALLOW_THREADS 0
#endif
#ifndef __has_extension
#define __has_extension(x) 0
#endif
#if !defined(_NPY_NO_DEPRECATIONS) && \
((defined(__GNUC__)&& __GNUC__ >= 6) || \
__has_extension(attribute_deprecated_with_message))
#define NPY_ATTR_DEPRECATE(text) __attribute__ ((deprecated (text)))
#else
#define NPY_ATTR_DEPRECATE(text)
#endif
/*
* There are several places in the code where an array of dimensions
* is allocated statically. This is the size of that static
* allocation.
*
* The array creation itself could have arbitrary dimensions but all
* the places where static allocation is used would need to be changed
* to dynamic (including inside of several structures)
*/
#define NPY_MAXDIMS 32
#define NPY_MAXARGS 32
/* Used for Converter Functions "O&" code in ParseTuple */
#define NPY_FAIL 0
#define NPY_SUCCEED 1
/*
* Binary compatibility version number. This number is increased
* whenever the C-API is changed such that binary compatibility is
* broken, i.e. whenever a recompile of extension modules is needed.
*/
#define NPY_VERSION NPY_ABI_VERSION
/*
* Minor API version. This number is increased whenever a change is
* made to the C-API -- whether it breaks binary compatibility or not.
* Some changes, such as adding a function pointer to the end of the
* function table, can be made without breaking binary compatibility.
* In this case, only the NPY_FEATURE_VERSION (*not* NPY_VERSION)
* would be increased. Whenever binary compatibility is broken, both
* NPY_VERSION and NPY_FEATURE_VERSION should be increased.
*/
#define NPY_FEATURE_VERSION NPY_API_VERSION
enum NPY_TYPES { NPY_BOOL=0,
NPY_BYTE, NPY_UBYTE,
NPY_SHORT, NPY_USHORT,
NPY_INT, NPY_UINT,
NPY_LONG, NPY_ULONG,
NPY_LONGLONG, NPY_ULONGLONG,
NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE,
NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE,
NPY_OBJECT=17,
NPY_STRING, NPY_UNICODE,
NPY_VOID,
/*
* New 1.6 types appended, may be integrated
* into the above in 2.0.
*/
NPY_DATETIME, NPY_TIMEDELTA, NPY_HALF,
NPY_NTYPES,
NPY_NOTYPE,
NPY_CHAR NPY_ATTR_DEPRECATE("Use NPY_STRING"),
NPY_USERDEF=256, /* leave room for characters */
/* The number of types not including the new 1.6 types */
NPY_NTYPES_ABI_COMPATIBLE=21
};
#ifdef _MSC_VER
#pragma deprecated(NPY_CHAR)
#endif
/* basetype array priority */
#define NPY_PRIORITY 0.0
/* default subtype priority */
#define NPY_SUBTYPE_PRIORITY 1.0
/* default scalar priority */
#define NPY_SCALAR_PRIORITY -1000000.0
/* How many floating point types are there (excluding half) */
#define NPY_NUM_FLOATTYPE 3
/*
* These characters correspond to the array type and the struct
* module
*/
enum NPY_TYPECHAR {
NPY_BOOLLTR = '?',
NPY_BYTELTR = 'b',
NPY_UBYTELTR = 'B',
NPY_SHORTLTR = 'h',
NPY_USHORTLTR = 'H',
NPY_INTLTR = 'i',
NPY_UINTLTR = 'I',
NPY_LONGLTR = 'l',
NPY_ULONGLTR = 'L',
NPY_LONGLONGLTR = 'q',
NPY_ULONGLONGLTR = 'Q',
NPY_HALFLTR = 'e',
NPY_FLOATLTR = 'f',
NPY_DOUBLELTR = 'd',
NPY_LONGDOUBLELTR = 'g',
NPY_CFLOATLTR = 'F',
NPY_CDOUBLELTR = 'D',
NPY_CLONGDOUBLELTR = 'G',
NPY_OBJECTLTR = 'O',
NPY_STRINGLTR = 'S',
NPY_STRINGLTR2 = 'a',
NPY_UNICODELTR = 'U',
NPY_VOIDLTR = 'V',
NPY_DATETIMELTR = 'M',
NPY_TIMEDELTALTR = 'm',
NPY_CHARLTR = 'c',
/*
* No Descriptor, just a define -- this let's
* Python users specify an array of integers
* large enough to hold a pointer on the
* platform
*/
NPY_INTPLTR = 'p',
NPY_UINTPLTR = 'P',
/*
* These are for dtype 'kinds', not dtype 'typecodes'
* as the above are for.
*/
NPY_GENBOOLLTR ='b',
NPY_SIGNEDLTR = 'i',
NPY_UNSIGNEDLTR = 'u',
NPY_FLOATINGLTR = 'f',
NPY_COMPLEXLTR = 'c'
};
/*
* Changing this may break Numpy API compatibility
* due to changing offsets in PyArray_ArrFuncs, so be
* careful. Here we have reused the mergesort slot for
* any kind of stable sort, the actual implementation will
* depend on the data type.
*/
typedef enum {
NPY_QUICKSORT=0,
NPY_HEAPSORT=1,
NPY_MERGESORT=2,
NPY_STABLESORT=2,
} NPY_SORTKIND;
#define NPY_NSORTS (NPY_STABLESORT + 1)
typedef enum {
NPY_INTROSELECT=0
} NPY_SELECTKIND;
#define NPY_NSELECTS (NPY_INTROSELECT + 1)
typedef enum {
NPY_SEARCHLEFT=0,
NPY_SEARCHRIGHT=1
} NPY_SEARCHSIDE;
#define NPY_NSEARCHSIDES (NPY_SEARCHRIGHT + 1)
typedef enum {
NPY_NOSCALAR=-1,
NPY_BOOL_SCALAR,
NPY_INTPOS_SCALAR,
NPY_INTNEG_SCALAR,
NPY_FLOAT_SCALAR,
NPY_COMPLEX_SCALAR,
NPY_OBJECT_SCALAR
} NPY_SCALARKIND;
#define NPY_NSCALARKINDS (NPY_OBJECT_SCALAR + 1)
/* For specifying array memory layout or iteration order */
typedef enum {
/* Fortran order if inputs are all Fortran, C otherwise */
NPY_ANYORDER=-1,
/* C order */
NPY_CORDER=0,
/* Fortran order */
NPY_FORTRANORDER=1,
/* An order as close to the inputs as possible */
NPY_KEEPORDER=2
} NPY_ORDER;
/* For specifying allowed casting in operations which support it */
typedef enum {
/* Only allow identical types */
NPY_NO_CASTING=0,
/* Allow identical and byte swapped types */
NPY_EQUIV_CASTING=1,
/* Only allow safe casts */
NPY_SAFE_CASTING=2,
/* Allow safe casts or casts within the same kind */
NPY_SAME_KIND_CASTING=3,
/* Allow any casts */
NPY_UNSAFE_CASTING=4
} NPY_CASTING;
typedef enum {
NPY_CLIP=0,
NPY_WRAP=1,
NPY_RAISE=2
} NPY_CLIPMODE;
/* The special not-a-time (NaT) value */
#define NPY_DATETIME_NAT NPY_MIN_INT64
/*
* Upper bound on the length of a DATETIME ISO 8601 string
* YEAR: 21 (64-bit year)
* MONTH: 3
* DAY: 3
* HOURS: 3
* MINUTES: 3
* SECONDS: 3
* ATTOSECONDS: 1 + 3*6
* TIMEZONE: 5
* NULL TERMINATOR: 1
*/
#define NPY_DATETIME_MAX_ISO8601_STRLEN (21 + 3*5 + 1 + 3*6 + 6 + 1)
/* The FR in the unit names stands for frequency */
typedef enum {
/* Force signed enum type, must be -1 for code compatibility */
NPY_FR_ERROR = -1, /* error or undetermined */
/* Start of valid units */
NPY_FR_Y = 0, /* Years */
NPY_FR_M = 1, /* Months */
NPY_FR_W = 2, /* Weeks */
/* Gap where 1.6 NPY_FR_B (value 3) was */
NPY_FR_D = 4, /* Days */
NPY_FR_h = 5, /* hours */
NPY_FR_m = 6, /* minutes */
NPY_FR_s = 7, /* seconds */
NPY_FR_ms = 8, /* milliseconds */
NPY_FR_us = 9, /* microseconds */
NPY_FR_ns = 10, /* nanoseconds */
NPY_FR_ps = 11, /* picoseconds */
NPY_FR_fs = 12, /* femtoseconds */
NPY_FR_as = 13, /* attoseconds */
NPY_FR_GENERIC = 14 /* unbound units, can convert to anything */
} NPY_DATETIMEUNIT;
/*
* NOTE: With the NPY_FR_B gap for 1.6 ABI compatibility, NPY_DATETIME_NUMUNITS
* is technically one more than the actual number of units.
*/
#define NPY_DATETIME_NUMUNITS (NPY_FR_GENERIC + 1)
#define NPY_DATETIME_DEFAULTUNIT NPY_FR_GENERIC
/*
* Business day conventions for mapping invalid business
* days to valid business days.
*/
typedef enum {
/* Go forward in time to the following business day. */
NPY_BUSDAY_FORWARD,
NPY_BUSDAY_FOLLOWING = NPY_BUSDAY_FORWARD,
/* Go backward in time to the preceding business day. */
NPY_BUSDAY_BACKWARD,
NPY_BUSDAY_PRECEDING = NPY_BUSDAY_BACKWARD,
/*
* Go forward in time to the following business day, unless it
* crosses a month boundary, in which case go backward
*/
NPY_BUSDAY_MODIFIEDFOLLOWING,
/*
* Go backward in time to the preceding business day, unless it
* crosses a month boundary, in which case go forward.
*/
NPY_BUSDAY_MODIFIEDPRECEDING,
/* Produce a NaT for non-business days. */
NPY_BUSDAY_NAT,
/* Raise an exception for non-business days. */
NPY_BUSDAY_RAISE
} NPY_BUSDAY_ROLL;
/************************************************************
* NumPy Auxiliary Data for inner loops, sort functions, etc.
************************************************************/
/*
* When creating an auxiliary data struct, this should always appear
* as the first member, like this:
*
* typedef struct {
* NpyAuxData base;
* double constant;
* } constant_multiplier_aux_data;
*/
typedef struct NpyAuxData_tag NpyAuxData;
/* Function pointers for freeing or cloning auxiliary data */
typedef void (NpyAuxData_FreeFunc) (NpyAuxData *);
typedef NpyAuxData *(NpyAuxData_CloneFunc) (NpyAuxData *);
struct NpyAuxData_tag {
NpyAuxData_FreeFunc *free;
NpyAuxData_CloneFunc *clone;
/* To allow for a bit of expansion without breaking the ABI */
void *reserved[2];
};
/* Macros to use for freeing and cloning auxiliary data */
#define NPY_AUXDATA_FREE(auxdata) \
do { \
if ((auxdata) != NULL) { \
(auxdata)->free(auxdata); \
} \
} while(0)
#define NPY_AUXDATA_CLONE(auxdata) \
((auxdata)->clone(auxdata))
#define NPY_ERR(str) fprintf(stderr, #str); fflush(stderr);
#define NPY_ERR2(str) fprintf(stderr, str); fflush(stderr);
#define NPY_STRINGIFY(x) #x
#define NPY_TOSTRING(x) NPY_STRINGIFY(x)
Loading ...