diff options
Diffstat (limited to 'numpy/core/src/scalarmathmodule.c.src')
-rw-r--r-- | numpy/core/src/scalarmathmodule.c.src | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src index f1f7d5ad2..5dc72a87a 100644 --- a/numpy/core/src/scalarmathmodule.c.src +++ b/numpy/core/src/scalarmathmodule.c.src @@ -11,6 +11,7 @@ #include "numpy/ufuncobject.h" #include "numpy/arrayscalars.h" +#include "npy_3kcompat.h" /** numarray adapted routines.... **/ @@ -629,6 +630,9 @@ _@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1, /**end repeat**/ +#if defined(NPY_PY3K) +#define CODEGEN_SKIP_divide_FLAG +#endif /**begin repeat #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong)*13, (float, double, longdouble, cfloat, cdouble, clongdouble)*6, (float, double, longdouble)*2# @@ -640,6 +644,8 @@ _@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1, #OName=(Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong)*12, Float*4, Double*6, (Float, Double, LongDouble, CFloat, CDouble, CLongDouble)*6, (Float, Double, LongDouble)*2# **/ +#if !defined(CODEGEN_SKIP_@oper@_FLAG) + static PyObject * @name@_@oper@(PyObject *a, PyObject *b) { @@ -740,8 +746,12 @@ static PyObject * #endif return ret; } +#endif + /**end repeat**/ +#undef CODEGEN_SKIP_divide_FLAG + /**begin repeat #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float, double, longdouble, cfloat, cdouble, clongdouble# #Name=Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble# @@ -924,13 +934,19 @@ static PyObject * #define @name@_invert NULL /**end repeat**/ +#if defined(NPY_PY3K) +#define NONZERO_NAME(prefix, suffix) prefix##bool##suffix +#else +#define NONZERO_NAME(prefix, suffix) prefix##nonzero##suffix +#endif + /**begin repeat * #name = byte, ubyte, short, ushort, int, uint, long, ulong, longlong, * ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble# * #simp=1*13,0*3# */ static int -@name@_nonzero(PyObject *a) +NONZERO_NAME(@name@_,)(PyObject *a) { int ret; @name@ arg1; @@ -939,7 +955,7 @@ static int if (PyErr_Occurred()) { return -1; } - return PyGenericArrType_Type.tp_as_number->nb_nonzero(a); + return PyGenericArrType_Type.tp_as_number->NONZERO_NAME(nb_,)(a); } /* @@ -1008,6 +1024,7 @@ static PyObject * } /**end repeat**/ +#if !defined(NPY_PY3K) /**begin repeat * @@ -1026,6 +1043,7 @@ static PyObject * } /**end repeat**/ +#endif /**begin repeat * #oper=le,ge,lt,gt,eq,ne# @@ -1099,30 +1117,50 @@ static PyNumberMethods @name@_as_number = { (binaryfunc)@name@_add, /*nb_add*/ (binaryfunc)@name@_subtract, /*nb_subtract*/ (binaryfunc)@name@_multiply, /*nb_multiply*/ +#if defined(NPY_PY3K) +#else (binaryfunc)@name@_divide, /*nb_divide*/ +#endif (binaryfunc)@name@_remainder, /*nb_remainder*/ (binaryfunc)@name@_divmod, /*nb_divmod*/ (ternaryfunc)@name@_power, /*nb_power*/ (unaryfunc)@name@_negative, (unaryfunc)@name@_positive, /*nb_pos*/ (unaryfunc)@name@_absolute, /*nb_abs*/ +#if defined(NPY_PY3K) + (inquiry)@name@_bool, /*nb_bool*/ +#else (inquiry)@name@_nonzero, /*nb_nonzero*/ +#endif (unaryfunc)@name@_invert, /*nb_invert*/ (binaryfunc)@name@_lshift, /*nb_lshift*/ (binaryfunc)@name@_rshift, /*nb_rshift*/ (binaryfunc)@name@_and, /*nb_and*/ (binaryfunc)@name@_xor, /*nb_xor*/ (binaryfunc)@name@_or, /*nb_or*/ +#if defined(NPY_PY3K) +#else 0, /*nb_coerce*/ +#endif (unaryfunc)@name@_int, /*nb_int*/ +#if defined(NPY_PY3K) + (unaryfunc)0, /*nb_reserved*/ +#else (unaryfunc)@name@_long, /*nb_long*/ +#endif (unaryfunc)@name@_float, /*nb_float*/ +#if defined(NPY_PY3K) +#else (unaryfunc)@name@_oct, /*nb_oct*/ (unaryfunc)@name@_hex, /*nb_hex*/ +#endif 0, /*inplace_add*/ 0, /*inplace_subtract*/ 0, /*inplace_multiply*/ +#if defined(NPY_PY3K) +#else 0, /*inplace_divide*/ +#endif 0, /*inplace_remainder*/ 0, /*inplace_power*/ 0, /*inplace_lshift*/ |