From bb3238bcddf75846385ec280f9d673416b5b2b3c Mon Sep 17 00:00:00 2001 From: Henning Peters Date: Tue, 19 Apr 2016 19:50:42 +0200 Subject: [PATCH] pin numpy to >=1.7, ship headers --- buildbot.json | 2 + include/numpy/__multiarray_api.h | 538 ++++++++---------- include/numpy/__ufunc_api.h | 95 ++-- include/numpy/_numpyconfig.h | 4 +- include/numpy/arrayobject.h | 11 + include/numpy/multiarray_api.txt | 82 +-- include/numpy/ndarrayobject.h | 30 +- include/numpy/ndarraytypes.h | 178 ++---- include/numpy/noprefix.h | 14 +- include/numpy/npy_3kcompat.h | 107 ++-- include/numpy/npy_common.h | 179 +----- include/numpy/npy_cpu.h | 41 +- ..._deprecated_api.h => npy_deprecated_api.h} | 21 +- include/numpy/npy_endian.h | 27 +- include/numpy/npy_math.h | 129 +---- include/numpy/numpyconfig.h | 21 +- include/numpy/ufunc_api.txt | 19 +- include/numpy/ufuncobject.h | 165 ++++-- requirements.txt | 4 +- setup.py | 9 +- 20 files changed, 661 insertions(+), 1015 deletions(-) rename include/numpy/{npy_1_7_deprecated_api.h => npy_deprecated_api.h} (91%) diff --git a/buildbot.json b/buildbot.json index d3a073961..8ccfe534f 100644 --- a/buildbot.json +++ b/buildbot.json @@ -2,6 +2,7 @@ "build": { "sdist": [ "pip install -r requirements.txt", + "pip install \"numpy<1.8\"", "python setup.py sdist" ], "install": [ @@ -9,6 +10,7 @@ ], "wheel": [ "python untar.py source.tar.gz .", + "pip install \"numpy<1.8\"", "python setup.py bdist_wheel", "python cpdist.py dist" ] diff --git a/include/numpy/__multiarray_api.h b/include/numpy/__multiarray_api.h index 20e1f4c5f..c949d732f 100644 --- a/include/numpy/__multiarray_api.h +++ b/include/numpy/__multiarray_api.h @@ -1,5 +1,5 @@ -#if defined(_MULTIARRAYMODULE) || defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE) +#ifdef _MULTIARRAYMODULE typedef struct { PyObject_HEAD @@ -16,7 +16,7 @@ NPY_NO_EXPORT PyTypeObject PyArrayNeighborhoodIter_Type; NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues[2]; #endif -NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCVersion \ +NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCVersion \ (void); #ifdef NPY_ENABLE_SEPARATE_COMPILATION extern NPY_NO_EXPORT PyTypeObject PyBigArray_Type; @@ -252,353 +252,353 @@ NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues[2]; NPY_NO_EXPORT PyTypeObject PyVoidArrType_Type; #endif -NPY_NO_EXPORT int PyArray_SetNumericOps \ +NPY_NO_EXPORT int PyArray_SetNumericOps \ (PyObject *); -NPY_NO_EXPORT PyObject * PyArray_GetNumericOps \ +NPY_NO_EXPORT PyObject * PyArray_GetNumericOps \ (void); -NPY_NO_EXPORT int PyArray_INCREF \ +NPY_NO_EXPORT int PyArray_INCREF \ (PyArrayObject *); -NPY_NO_EXPORT int PyArray_XDECREF \ +NPY_NO_EXPORT int PyArray_XDECREF \ (PyArrayObject *); -NPY_NO_EXPORT void PyArray_SetStringFunction \ +NPY_NO_EXPORT void PyArray_SetStringFunction \ (PyObject *, int); -NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromType \ +NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromType \ (int); -NPY_NO_EXPORT PyObject * PyArray_TypeObjectFromType \ +NPY_NO_EXPORT PyObject * PyArray_TypeObjectFromType \ (int); -NPY_NO_EXPORT char * PyArray_Zero \ +NPY_NO_EXPORT char * PyArray_Zero \ (PyArrayObject *); -NPY_NO_EXPORT char * PyArray_One \ +NPY_NO_EXPORT char * PyArray_One \ (PyArrayObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) NPY_GCC_NONNULL(2) PyObject * PyArray_CastToType \ +NPY_NO_EXPORT PyObject * PyArray_CastToType \ (PyArrayObject *, PyArray_Descr *, int); -NPY_NO_EXPORT int PyArray_CastTo \ +NPY_NO_EXPORT int PyArray_CastTo \ (PyArrayObject *, PyArrayObject *); -NPY_NO_EXPORT int PyArray_CastAnyTo \ +NPY_NO_EXPORT int PyArray_CastAnyTo \ (PyArrayObject *, PyArrayObject *); -NPY_NO_EXPORT int PyArray_CanCastSafely \ +NPY_NO_EXPORT int PyArray_CanCastSafely \ (int, int); -NPY_NO_EXPORT npy_bool PyArray_CanCastTo \ +NPY_NO_EXPORT npy_bool PyArray_CanCastTo \ (PyArray_Descr *, PyArray_Descr *); -NPY_NO_EXPORT int PyArray_ObjectType \ +NPY_NO_EXPORT int PyArray_ObjectType \ (PyObject *, int); -NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromObject \ +NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromObject \ (PyObject *, PyArray_Descr *); -NPY_NO_EXPORT PyArrayObject ** PyArray_ConvertToCommonType \ +NPY_NO_EXPORT PyArrayObject ** PyArray_ConvertToCommonType \ (PyObject *, int *); -NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromScalar \ +NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromScalar \ (PyObject *); -NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromTypeObject \ +NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromTypeObject \ (PyObject *); -NPY_NO_EXPORT npy_intp PyArray_Size \ +NPY_NO_EXPORT npy_intp PyArray_Size \ (PyObject *); -NPY_NO_EXPORT PyObject * PyArray_Scalar \ +NPY_NO_EXPORT PyObject * PyArray_Scalar \ (void *, PyArray_Descr *, PyObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromScalar \ +NPY_NO_EXPORT PyObject * PyArray_FromScalar \ (PyObject *, PyArray_Descr *); -NPY_NO_EXPORT void PyArray_ScalarAsCtype \ +NPY_NO_EXPORT void PyArray_ScalarAsCtype \ (PyObject *, void *); -NPY_NO_EXPORT int PyArray_CastScalarToCtype \ +NPY_NO_EXPORT int PyArray_CastScalarToCtype \ (PyObject *, void *, PyArray_Descr *); -NPY_NO_EXPORT int PyArray_CastScalarDirect \ +NPY_NO_EXPORT int PyArray_CastScalarDirect \ (PyObject *, PyArray_Descr *, void *, int); -NPY_NO_EXPORT PyObject * PyArray_ScalarFromObject \ +NPY_NO_EXPORT PyObject * PyArray_ScalarFromObject \ (PyObject *); -NPY_NO_EXPORT PyArray_VectorUnaryFunc * PyArray_GetCastFunc \ +NPY_NO_EXPORT PyArray_VectorUnaryFunc * PyArray_GetCastFunc \ (PyArray_Descr *, int); -NPY_NO_EXPORT PyObject * PyArray_FromDims \ +NPY_NO_EXPORT PyObject * PyArray_FromDims \ (int, int *, int); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_FromDimsAndDataAndDescr \ +NPY_NO_EXPORT PyObject * PyArray_FromDimsAndDataAndDescr \ (int, int *, PyArray_Descr *, char *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromAny \ +NPY_NO_EXPORT PyObject * PyArray_FromAny \ (PyObject *, PyArray_Descr *, int, int, int, PyObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_EnsureArray \ +NPY_NO_EXPORT PyObject * PyArray_EnsureArray \ (PyObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_EnsureAnyArray \ +NPY_NO_EXPORT PyObject * PyArray_EnsureAnyArray \ (PyObject *); -NPY_NO_EXPORT PyObject * PyArray_FromFile \ +NPY_NO_EXPORT PyObject * PyArray_FromFile \ (FILE *, PyArray_Descr *, npy_intp, char *); -NPY_NO_EXPORT PyObject * PyArray_FromString \ +NPY_NO_EXPORT PyObject * PyArray_FromString \ (char *, npy_intp, PyArray_Descr *, npy_intp, char *); -NPY_NO_EXPORT PyObject * PyArray_FromBuffer \ +NPY_NO_EXPORT PyObject * PyArray_FromBuffer \ (PyObject *, PyArray_Descr *, npy_intp, npy_intp); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromIter \ +NPY_NO_EXPORT PyObject * PyArray_FromIter \ (PyObject *, PyArray_Descr *, npy_intp); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_Return \ +NPY_NO_EXPORT PyObject * PyArray_Return \ (PyArrayObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) NPY_GCC_NONNULL(2) PyObject * PyArray_GetField \ +NPY_NO_EXPORT PyObject * PyArray_GetField \ (PyArrayObject *, PyArray_Descr *, int); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) NPY_GCC_NONNULL(2) int PyArray_SetField \ +NPY_NO_EXPORT int PyArray_SetField \ (PyArrayObject *, PyArray_Descr *, int, PyObject *); -NPY_NO_EXPORT PyObject * PyArray_Byteswap \ +NPY_NO_EXPORT PyObject * PyArray_Byteswap \ (PyArrayObject *, npy_bool); -NPY_NO_EXPORT PyObject * PyArray_Resize \ +NPY_NO_EXPORT PyObject * PyArray_Resize \ (PyArrayObject *, PyArray_Dims *, int, NPY_ORDER); -NPY_NO_EXPORT int PyArray_MoveInto \ +NPY_NO_EXPORT int PyArray_MoveInto \ (PyArrayObject *, PyArrayObject *); -NPY_NO_EXPORT int PyArray_CopyInto \ +NPY_NO_EXPORT int PyArray_CopyInto \ (PyArrayObject *, PyArrayObject *); -NPY_NO_EXPORT int PyArray_CopyAnyInto \ +NPY_NO_EXPORT int PyArray_CopyAnyInto \ (PyArrayObject *, PyArrayObject *); -NPY_NO_EXPORT int PyArray_CopyObject \ +NPY_NO_EXPORT int PyArray_CopyObject \ (PyArrayObject *, PyObject *); -NPY_NO_EXPORT NPY_GCC_NONNULL(1) PyObject * PyArray_NewCopy \ +NPY_NO_EXPORT PyObject * PyArray_NewCopy \ (PyArrayObject *, NPY_ORDER); -NPY_NO_EXPORT PyObject * PyArray_ToList \ +NPY_NO_EXPORT PyObject * PyArray_ToList \ (PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_ToString \ +NPY_NO_EXPORT PyObject * PyArray_ToString \ (PyArrayObject *, NPY_ORDER); -NPY_NO_EXPORT int PyArray_ToFile \ +NPY_NO_EXPORT int PyArray_ToFile \ (PyArrayObject *, FILE *, char *, char *); -NPY_NO_EXPORT int PyArray_Dump \ +NPY_NO_EXPORT int PyArray_Dump \ (PyObject *, PyObject *, int); -NPY_NO_EXPORT PyObject * PyArray_Dumps \ +NPY_NO_EXPORT PyObject * PyArray_Dumps \ (PyObject *, int); -NPY_NO_EXPORT int PyArray_ValidType \ +NPY_NO_EXPORT int PyArray_ValidType \ (int); -NPY_NO_EXPORT void PyArray_UpdateFlags \ +NPY_NO_EXPORT void PyArray_UpdateFlags \ (PyArrayObject *, int); -NPY_NO_EXPORT NPY_GCC_NONNULL(1) PyObject * PyArray_New \ +NPY_NO_EXPORT PyObject * PyArray_New \ (PyTypeObject *, int, npy_intp *, int, npy_intp *, void *, int, int, PyObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) NPY_GCC_NONNULL(1) NPY_GCC_NONNULL(2) PyObject * PyArray_NewFromDescr \ +NPY_NO_EXPORT PyObject * PyArray_NewFromDescr \ (PyTypeObject *, PyArray_Descr *, int, npy_intp *, npy_intp *, void *, int, PyObject *); -NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNew \ +NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNew \ (PyArray_Descr *); -NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNewFromType \ +NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNewFromType \ (int); -NPY_NO_EXPORT double PyArray_GetPriority \ +NPY_NO_EXPORT double PyArray_GetPriority \ (PyObject *, double); -NPY_NO_EXPORT PyObject * PyArray_IterNew \ +NPY_NO_EXPORT PyObject * PyArray_IterNew \ (PyObject *); -NPY_NO_EXPORT PyObject * PyArray_MultiIterNew \ +NPY_NO_EXPORT PyObject * PyArray_MultiIterNew \ (int, ...); -NPY_NO_EXPORT int PyArray_PyIntAsInt \ +NPY_NO_EXPORT int PyArray_PyIntAsInt \ (PyObject *); -NPY_NO_EXPORT npy_intp PyArray_PyIntAsIntp \ +NPY_NO_EXPORT npy_intp PyArray_PyIntAsIntp \ (PyObject *); -NPY_NO_EXPORT int PyArray_Broadcast \ +NPY_NO_EXPORT int PyArray_Broadcast \ (PyArrayMultiIterObject *); -NPY_NO_EXPORT void PyArray_FillObjectArray \ +NPY_NO_EXPORT void PyArray_FillObjectArray \ (PyArrayObject *, PyObject *); -NPY_NO_EXPORT int PyArray_FillWithScalar \ +NPY_NO_EXPORT int PyArray_FillWithScalar \ (PyArrayObject *, PyObject *); -NPY_NO_EXPORT npy_bool PyArray_CheckStrides \ +NPY_NO_EXPORT npy_bool PyArray_CheckStrides \ (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *); -NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNewByteorder \ +NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNewByteorder \ (PyArray_Descr *, char); -NPY_NO_EXPORT PyObject * PyArray_IterAllButAxis \ +NPY_NO_EXPORT PyObject * PyArray_IterAllButAxis \ (PyObject *, int *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_CheckFromAny \ +NPY_NO_EXPORT PyObject * PyArray_CheckFromAny \ (PyObject *, PyArray_Descr *, int, int, int, PyObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromArray \ +NPY_NO_EXPORT PyObject * PyArray_FromArray \ (PyArrayObject *, PyArray_Descr *, int); -NPY_NO_EXPORT PyObject * PyArray_FromInterface \ +NPY_NO_EXPORT PyObject * PyArray_FromInterface \ (PyObject *); -NPY_NO_EXPORT PyObject * PyArray_FromStructInterface \ +NPY_NO_EXPORT PyObject * PyArray_FromStructInterface \ (PyObject *); -NPY_NO_EXPORT PyObject * PyArray_FromArrayAttr \ +NPY_NO_EXPORT PyObject * PyArray_FromArrayAttr \ (PyObject *, PyArray_Descr *, PyObject *); -NPY_NO_EXPORT NPY_SCALARKIND PyArray_ScalarKind \ +NPY_NO_EXPORT NPY_SCALARKIND PyArray_ScalarKind \ (int, PyArrayObject **); -NPY_NO_EXPORT int PyArray_CanCoerceScalar \ +NPY_NO_EXPORT int PyArray_CanCoerceScalar \ (int, int, NPY_SCALARKIND); -NPY_NO_EXPORT PyObject * PyArray_NewFlagsObject \ +NPY_NO_EXPORT PyObject * PyArray_NewFlagsObject \ (PyObject *); -NPY_NO_EXPORT npy_bool PyArray_CanCastScalar \ +NPY_NO_EXPORT npy_bool PyArray_CanCastScalar \ (PyTypeObject *, PyTypeObject *); -NPY_NO_EXPORT int PyArray_CompareUCS4 \ +NPY_NO_EXPORT int PyArray_CompareUCS4 \ (npy_ucs4 *, npy_ucs4 *, size_t); -NPY_NO_EXPORT int PyArray_RemoveSmallest \ +NPY_NO_EXPORT int PyArray_RemoveSmallest \ (PyArrayMultiIterObject *); -NPY_NO_EXPORT int PyArray_ElementStrides \ +NPY_NO_EXPORT int PyArray_ElementStrides \ (PyObject *); -NPY_NO_EXPORT void PyArray_Item_INCREF \ +NPY_NO_EXPORT void PyArray_Item_INCREF \ (char *, PyArray_Descr *); -NPY_NO_EXPORT void PyArray_Item_XDECREF \ +NPY_NO_EXPORT void PyArray_Item_XDECREF \ (char *, PyArray_Descr *); -NPY_NO_EXPORT PyObject * PyArray_FieldNames \ +NPY_NO_EXPORT PyObject * PyArray_FieldNames \ (PyObject *); -NPY_NO_EXPORT PyObject * PyArray_Transpose \ +NPY_NO_EXPORT PyObject * PyArray_Transpose \ (PyArrayObject *, PyArray_Dims *); -NPY_NO_EXPORT PyObject * PyArray_TakeFrom \ +NPY_NO_EXPORT PyObject * PyArray_TakeFrom \ (PyArrayObject *, PyObject *, int, PyArrayObject *, NPY_CLIPMODE); -NPY_NO_EXPORT PyObject * PyArray_PutTo \ +NPY_NO_EXPORT PyObject * PyArray_PutTo \ (PyArrayObject *, PyObject*, PyObject *, NPY_CLIPMODE); -NPY_NO_EXPORT PyObject * PyArray_PutMask \ +NPY_NO_EXPORT PyObject * PyArray_PutMask \ (PyArrayObject *, PyObject*, PyObject*); -NPY_NO_EXPORT PyObject * PyArray_Repeat \ +NPY_NO_EXPORT PyObject * PyArray_Repeat \ (PyArrayObject *, PyObject *, int); -NPY_NO_EXPORT PyObject * PyArray_Choose \ +NPY_NO_EXPORT PyObject * PyArray_Choose \ (PyArrayObject *, PyObject *, PyArrayObject *, NPY_CLIPMODE); -NPY_NO_EXPORT int PyArray_Sort \ +NPY_NO_EXPORT int PyArray_Sort \ (PyArrayObject *, int, NPY_SORTKIND); -NPY_NO_EXPORT PyObject * PyArray_ArgSort \ +NPY_NO_EXPORT PyObject * PyArray_ArgSort \ (PyArrayObject *, int, NPY_SORTKIND); -NPY_NO_EXPORT PyObject * PyArray_SearchSorted \ +NPY_NO_EXPORT PyObject * PyArray_SearchSorted \ (PyArrayObject *, PyObject *, NPY_SEARCHSIDE, PyObject *); -NPY_NO_EXPORT PyObject * PyArray_ArgMax \ +NPY_NO_EXPORT PyObject * PyArray_ArgMax \ (PyArrayObject *, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_ArgMin \ +NPY_NO_EXPORT PyObject * PyArray_ArgMin \ (PyArrayObject *, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Reshape \ +NPY_NO_EXPORT PyObject * PyArray_Reshape \ (PyArrayObject *, PyObject *); -NPY_NO_EXPORT PyObject * PyArray_Newshape \ +NPY_NO_EXPORT PyObject * PyArray_Newshape \ (PyArrayObject *, PyArray_Dims *, NPY_ORDER); -NPY_NO_EXPORT PyObject * PyArray_Squeeze \ +NPY_NO_EXPORT PyObject * PyArray_Squeeze \ (PyArrayObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_View \ +NPY_NO_EXPORT PyObject * PyArray_View \ (PyArrayObject *, PyArray_Descr *, PyTypeObject *); -NPY_NO_EXPORT PyObject * PyArray_SwapAxes \ +NPY_NO_EXPORT PyObject * PyArray_SwapAxes \ (PyArrayObject *, int, int); -NPY_NO_EXPORT PyObject * PyArray_Max \ +NPY_NO_EXPORT PyObject * PyArray_Max \ (PyArrayObject *, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Min \ +NPY_NO_EXPORT PyObject * PyArray_Min \ (PyArrayObject *, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Ptp \ +NPY_NO_EXPORT PyObject * PyArray_Ptp \ (PyArrayObject *, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Mean \ +NPY_NO_EXPORT PyObject * PyArray_Mean \ (PyArrayObject *, int, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Trace \ +NPY_NO_EXPORT PyObject * PyArray_Trace \ (PyArrayObject *, int, int, int, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Diagonal \ +NPY_NO_EXPORT PyObject * PyArray_Diagonal \ (PyArrayObject *, int, int, int); -NPY_NO_EXPORT PyObject * PyArray_Clip \ +NPY_NO_EXPORT PyObject * PyArray_Clip \ (PyArrayObject *, PyObject *, PyObject *, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Conjugate \ +NPY_NO_EXPORT PyObject * PyArray_Conjugate \ (PyArrayObject *, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Nonzero \ +NPY_NO_EXPORT PyObject * PyArray_Nonzero \ (PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Std \ +NPY_NO_EXPORT PyObject * PyArray_Std \ (PyArrayObject *, int, int, PyArrayObject *, int); -NPY_NO_EXPORT PyObject * PyArray_Sum \ +NPY_NO_EXPORT PyObject * PyArray_Sum \ (PyArrayObject *, int, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_CumSum \ +NPY_NO_EXPORT PyObject * PyArray_CumSum \ (PyArrayObject *, int, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Prod \ +NPY_NO_EXPORT PyObject * PyArray_Prod \ (PyArrayObject *, int, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_CumProd \ +NPY_NO_EXPORT PyObject * PyArray_CumProd \ (PyArrayObject *, int, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_All \ +NPY_NO_EXPORT PyObject * PyArray_All \ (PyArrayObject *, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Any \ +NPY_NO_EXPORT PyObject * PyArray_Any \ (PyArrayObject *, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Compress \ +NPY_NO_EXPORT PyObject * PyArray_Compress \ (PyArrayObject *, PyObject *, int, PyArrayObject *); -NPY_NO_EXPORT PyObject * PyArray_Flatten \ +NPY_NO_EXPORT PyObject * PyArray_Flatten \ (PyArrayObject *, NPY_ORDER); -NPY_NO_EXPORT PyObject * PyArray_Ravel \ +NPY_NO_EXPORT PyObject * PyArray_Ravel \ (PyArrayObject *, NPY_ORDER); -NPY_NO_EXPORT npy_intp PyArray_MultiplyList \ +NPY_NO_EXPORT npy_intp PyArray_MultiplyList \ (npy_intp *, int); -NPY_NO_EXPORT int PyArray_MultiplyIntList \ +NPY_NO_EXPORT int PyArray_MultiplyIntList \ (int *, int); -NPY_NO_EXPORT void * PyArray_GetPtr \ +NPY_NO_EXPORT void * PyArray_GetPtr \ (PyArrayObject *, npy_intp*); -NPY_NO_EXPORT int PyArray_CompareLists \ +NPY_NO_EXPORT int PyArray_CompareLists \ (npy_intp *, npy_intp *, int); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(5) int PyArray_AsCArray \ +NPY_NO_EXPORT int PyArray_AsCArray \ (PyObject **, void *, npy_intp *, int, PyArray_Descr*); -NPY_NO_EXPORT int PyArray_As1D \ +NPY_NO_EXPORT int PyArray_As1D \ (PyObject **, char **, int *, int); -NPY_NO_EXPORT int PyArray_As2D \ +NPY_NO_EXPORT int PyArray_As2D \ (PyObject **, char ***, int *, int *, int); -NPY_NO_EXPORT int PyArray_Free \ +NPY_NO_EXPORT int PyArray_Free \ (PyObject *, void *); -NPY_NO_EXPORT int PyArray_Converter \ +NPY_NO_EXPORT int PyArray_Converter \ (PyObject *, PyObject **); -NPY_NO_EXPORT int PyArray_IntpFromSequence \ +NPY_NO_EXPORT int PyArray_IntpFromSequence \ (PyObject *, npy_intp *, int); -NPY_NO_EXPORT PyObject * PyArray_Concatenate \ +NPY_NO_EXPORT PyObject * PyArray_Concatenate \ (PyObject *, int); -NPY_NO_EXPORT PyObject * PyArray_InnerProduct \ +NPY_NO_EXPORT PyObject * PyArray_InnerProduct \ (PyObject *, PyObject *); -NPY_NO_EXPORT PyObject * PyArray_MatrixProduct \ +NPY_NO_EXPORT PyObject * PyArray_MatrixProduct \ (PyObject *, PyObject *); -NPY_NO_EXPORT PyObject * PyArray_CopyAndTranspose \ +NPY_NO_EXPORT PyObject * PyArray_CopyAndTranspose \ (PyObject *); -NPY_NO_EXPORT PyObject * PyArray_Correlate \ +NPY_NO_EXPORT PyObject * PyArray_Correlate \ (PyObject *, PyObject *, int); -NPY_NO_EXPORT int PyArray_TypestrConvert \ +NPY_NO_EXPORT int PyArray_TypestrConvert \ (int, int); -NPY_NO_EXPORT int PyArray_DescrConverter \ +NPY_NO_EXPORT int PyArray_DescrConverter \ (PyObject *, PyArray_Descr **); -NPY_NO_EXPORT int PyArray_DescrConverter2 \ +NPY_NO_EXPORT int PyArray_DescrConverter2 \ (PyObject *, PyArray_Descr **); -NPY_NO_EXPORT int PyArray_IntpConverter \ +NPY_NO_EXPORT int PyArray_IntpConverter \ (PyObject *, PyArray_Dims *); -NPY_NO_EXPORT int PyArray_BufferConverter \ +NPY_NO_EXPORT int PyArray_BufferConverter \ (PyObject *, PyArray_Chunk *); -NPY_NO_EXPORT int PyArray_AxisConverter \ +NPY_NO_EXPORT int PyArray_AxisConverter \ (PyObject *, int *); -NPY_NO_EXPORT int PyArray_BoolConverter \ +NPY_NO_EXPORT int PyArray_BoolConverter \ (PyObject *, npy_bool *); -NPY_NO_EXPORT int PyArray_ByteorderConverter \ +NPY_NO_EXPORT int PyArray_ByteorderConverter \ (PyObject *, char *); -NPY_NO_EXPORT int PyArray_OrderConverter \ +NPY_NO_EXPORT int PyArray_OrderConverter \ (PyObject *, NPY_ORDER *); -NPY_NO_EXPORT unsigned char PyArray_EquivTypes \ +NPY_NO_EXPORT unsigned char PyArray_EquivTypes \ (PyArray_Descr *, PyArray_Descr *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_Zeros \ +NPY_NO_EXPORT PyObject * PyArray_Zeros \ (int, npy_intp *, PyArray_Descr *, int); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_Empty \ +NPY_NO_EXPORT PyObject * PyArray_Empty \ (int, npy_intp *, PyArray_Descr *, int); -NPY_NO_EXPORT PyObject * PyArray_Where \ +NPY_NO_EXPORT PyObject * PyArray_Where \ (PyObject *, PyObject *, PyObject *); -NPY_NO_EXPORT PyObject * PyArray_Arange \ +NPY_NO_EXPORT PyObject * PyArray_Arange \ (double, double, double, int); -NPY_NO_EXPORT PyObject * PyArray_ArangeObj \ +NPY_NO_EXPORT PyObject * PyArray_ArangeObj \ (PyObject *, PyObject *, PyObject *, PyArray_Descr *); -NPY_NO_EXPORT int PyArray_SortkindConverter \ +NPY_NO_EXPORT int PyArray_SortkindConverter \ (PyObject *, NPY_SORTKIND *); -NPY_NO_EXPORT PyObject * PyArray_LexSort \ +NPY_NO_EXPORT PyObject * PyArray_LexSort \ (PyObject *, int); -NPY_NO_EXPORT PyObject * PyArray_Round \ +NPY_NO_EXPORT PyObject * PyArray_Round \ (PyArrayObject *, int, PyArrayObject *); -NPY_NO_EXPORT unsigned char PyArray_EquivTypenums \ +NPY_NO_EXPORT unsigned char PyArray_EquivTypenums \ (int, int); -NPY_NO_EXPORT int PyArray_RegisterDataType \ +NPY_NO_EXPORT int PyArray_RegisterDataType \ (PyArray_Descr *); -NPY_NO_EXPORT int PyArray_RegisterCastFunc \ +NPY_NO_EXPORT int PyArray_RegisterCastFunc \ (PyArray_Descr *, int, PyArray_VectorUnaryFunc *); -NPY_NO_EXPORT int PyArray_RegisterCanCast \ +NPY_NO_EXPORT int PyArray_RegisterCanCast \ (PyArray_Descr *, int, NPY_SCALARKIND); -NPY_NO_EXPORT void PyArray_InitArrFuncs \ +NPY_NO_EXPORT void PyArray_InitArrFuncs \ (PyArray_ArrFuncs *); -NPY_NO_EXPORT PyObject * PyArray_IntTupleFromIntp \ +NPY_NO_EXPORT PyObject * PyArray_IntTupleFromIntp \ (int, npy_intp *); -NPY_NO_EXPORT int PyArray_TypeNumFromName \ +NPY_NO_EXPORT int PyArray_TypeNumFromName \ (char *); -NPY_NO_EXPORT int PyArray_ClipmodeConverter \ +NPY_NO_EXPORT int PyArray_ClipmodeConverter \ (PyObject *, NPY_CLIPMODE *); -NPY_NO_EXPORT int PyArray_OutputConverter \ +NPY_NO_EXPORT int PyArray_OutputConverter \ (PyObject *, PyArrayObject **); -NPY_NO_EXPORT PyObject * PyArray_BroadcastToShape \ +NPY_NO_EXPORT PyObject * PyArray_BroadcastToShape \ (PyObject *, npy_intp *, int); -NPY_NO_EXPORT void _PyArray_SigintHandler \ +NPY_NO_EXPORT void _PyArray_SigintHandler \ (int); -NPY_NO_EXPORT void* _PyArray_GetSigintBuf \ +NPY_NO_EXPORT void* _PyArray_GetSigintBuf \ (void); -NPY_NO_EXPORT int PyArray_DescrAlignConverter \ +NPY_NO_EXPORT int PyArray_DescrAlignConverter \ (PyObject *, PyArray_Descr **); -NPY_NO_EXPORT int PyArray_DescrAlignConverter2 \ +NPY_NO_EXPORT int PyArray_DescrAlignConverter2 \ (PyObject *, PyArray_Descr **); -NPY_NO_EXPORT int PyArray_SearchsideConverter \ +NPY_NO_EXPORT int PyArray_SearchsideConverter \ (PyObject *, void *); -NPY_NO_EXPORT PyObject * PyArray_CheckAxis \ +NPY_NO_EXPORT PyObject * PyArray_CheckAxis \ (PyArrayObject *, int *, int); -NPY_NO_EXPORT npy_intp PyArray_OverflowMultiplyList \ +NPY_NO_EXPORT npy_intp PyArray_OverflowMultiplyList \ (npy_intp *, int); -NPY_NO_EXPORT int PyArray_CompareString \ +NPY_NO_EXPORT int PyArray_CompareString \ (char *, char *, size_t); -NPY_NO_EXPORT PyObject * PyArray_MultiIterFromObjects \ +NPY_NO_EXPORT PyObject * PyArray_MultiIterFromObjects \ (PyObject **, int, int, ...); -NPY_NO_EXPORT int PyArray_GetEndianness \ +NPY_NO_EXPORT int PyArray_GetEndianness \ (void); -NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCFeatureVersion \ +NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCFeatureVersion \ (void); -NPY_NO_EXPORT PyObject * PyArray_Correlate2 \ +NPY_NO_EXPORT PyObject * PyArray_Correlate2 \ (PyObject *, PyObject *, int); -NPY_NO_EXPORT PyObject* PyArray_NeighborhoodIterNew \ +NPY_NO_EXPORT PyObject* PyArray_NeighborhoodIterNew \ (PyArrayIterObject *, npy_intp *, int, PyArrayObject*); #ifdef NPY_ENABLE_SEPARATE_COMPILATION extern NPY_NO_EXPORT PyTypeObject PyTimeIntegerArrType_Type; @@ -630,151 +630,151 @@ NPY_NO_EXPORT PyObject* PyArray_NeighborhoodIterNew \ NPY_NO_EXPORT PyTypeObject NpyIter_Type; #endif -NPY_NO_EXPORT void PyArray_SetDatetimeParseFunction \ +NPY_NO_EXPORT void PyArray_SetDatetimeParseFunction \ (PyObject *); -NPY_NO_EXPORT void PyArray_DatetimeToDatetimeStruct \ +NPY_NO_EXPORT void PyArray_DatetimeToDatetimeStruct \ (npy_datetime, NPY_DATETIMEUNIT, npy_datetimestruct *); -NPY_NO_EXPORT void PyArray_TimedeltaToTimedeltaStruct \ +NPY_NO_EXPORT void PyArray_TimedeltaToTimedeltaStruct \ (npy_timedelta, NPY_DATETIMEUNIT, npy_timedeltastruct *); -NPY_NO_EXPORT npy_datetime PyArray_DatetimeStructToDatetime \ +NPY_NO_EXPORT npy_datetime PyArray_DatetimeStructToDatetime \ (NPY_DATETIMEUNIT, npy_datetimestruct *); -NPY_NO_EXPORT npy_datetime PyArray_TimedeltaStructToTimedelta \ +NPY_NO_EXPORT npy_datetime PyArray_TimedeltaStructToTimedelta \ (NPY_DATETIMEUNIT, npy_timedeltastruct *); -NPY_NO_EXPORT NpyIter * NpyIter_New \ +NPY_NO_EXPORT NpyIter * NpyIter_New \ (PyArrayObject *, npy_uint32, NPY_ORDER, NPY_CASTING, PyArray_Descr*); -NPY_NO_EXPORT NpyIter * NpyIter_MultiNew \ +NPY_NO_EXPORT NpyIter * NpyIter_MultiNew \ (int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **); -NPY_NO_EXPORT NpyIter * NpyIter_AdvancedNew \ +NPY_NO_EXPORT NpyIter * NpyIter_AdvancedNew \ (int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **, int, int **, npy_intp *, npy_intp); -NPY_NO_EXPORT NpyIter * NpyIter_Copy \ +NPY_NO_EXPORT NpyIter * NpyIter_Copy \ (NpyIter *); -NPY_NO_EXPORT int NpyIter_Deallocate \ +NPY_NO_EXPORT int NpyIter_Deallocate \ (NpyIter *); -NPY_NO_EXPORT npy_bool NpyIter_HasDelayedBufAlloc \ +NPY_NO_EXPORT npy_bool NpyIter_HasDelayedBufAlloc \ (NpyIter *); -NPY_NO_EXPORT npy_bool NpyIter_HasExternalLoop \ +NPY_NO_EXPORT npy_bool NpyIter_HasExternalLoop \ (NpyIter *); -NPY_NO_EXPORT int NpyIter_EnableExternalLoop \ +NPY_NO_EXPORT int NpyIter_EnableExternalLoop \ (NpyIter *); -NPY_NO_EXPORT npy_intp * NpyIter_GetInnerStrideArray \ +NPY_NO_EXPORT npy_intp * NpyIter_GetInnerStrideArray \ (NpyIter *); -NPY_NO_EXPORT npy_intp * NpyIter_GetInnerLoopSizePtr \ +NPY_NO_EXPORT npy_intp * NpyIter_GetInnerLoopSizePtr \ (NpyIter *); -NPY_NO_EXPORT int NpyIter_Reset \ +NPY_NO_EXPORT int NpyIter_Reset \ (NpyIter *, char **); -NPY_NO_EXPORT int NpyIter_ResetBasePointers \ +NPY_NO_EXPORT int NpyIter_ResetBasePointers \ (NpyIter *, char **, char **); -NPY_NO_EXPORT int NpyIter_ResetToIterIndexRange \ +NPY_NO_EXPORT int NpyIter_ResetToIterIndexRange \ (NpyIter *, npy_intp, npy_intp, char **); -NPY_NO_EXPORT int NpyIter_GetNDim \ +NPY_NO_EXPORT int NpyIter_GetNDim \ (NpyIter *); -NPY_NO_EXPORT int NpyIter_GetNOp \ +NPY_NO_EXPORT int NpyIter_GetNOp \ (NpyIter *); -NPY_NO_EXPORT NpyIter_IterNextFunc * NpyIter_GetIterNext \ +NPY_NO_EXPORT NpyIter_IterNextFunc * NpyIter_GetIterNext \ (NpyIter *, char **); -NPY_NO_EXPORT npy_intp NpyIter_GetIterSize \ +NPY_NO_EXPORT npy_intp NpyIter_GetIterSize \ (NpyIter *); -NPY_NO_EXPORT void NpyIter_GetIterIndexRange \ +NPY_NO_EXPORT void NpyIter_GetIterIndexRange \ (NpyIter *, npy_intp *, npy_intp *); -NPY_NO_EXPORT npy_intp NpyIter_GetIterIndex \ +NPY_NO_EXPORT npy_intp NpyIter_GetIterIndex \ (NpyIter *); -NPY_NO_EXPORT int NpyIter_GotoIterIndex \ +NPY_NO_EXPORT int NpyIter_GotoIterIndex \ (NpyIter *, npy_intp); -NPY_NO_EXPORT npy_bool NpyIter_HasMultiIndex \ +NPY_NO_EXPORT npy_bool NpyIter_HasMultiIndex \ (NpyIter *); -NPY_NO_EXPORT int NpyIter_GetShape \ +NPY_NO_EXPORT int NpyIter_GetShape \ (NpyIter *, npy_intp *); -NPY_NO_EXPORT NpyIter_GetMultiIndexFunc * NpyIter_GetGetMultiIndex \ +NPY_NO_EXPORT NpyIter_GetMultiIndexFunc * NpyIter_GetGetMultiIndex \ (NpyIter *, char **); -NPY_NO_EXPORT int NpyIter_GotoMultiIndex \ +NPY_NO_EXPORT int NpyIter_GotoMultiIndex \ (NpyIter *, npy_intp *); -NPY_NO_EXPORT int NpyIter_RemoveMultiIndex \ +NPY_NO_EXPORT int NpyIter_RemoveMultiIndex \ (NpyIter *); -NPY_NO_EXPORT npy_bool NpyIter_HasIndex \ +NPY_NO_EXPORT npy_bool NpyIter_HasIndex \ (NpyIter *); -NPY_NO_EXPORT npy_bool NpyIter_IsBuffered \ +NPY_NO_EXPORT npy_bool NpyIter_IsBuffered \ (NpyIter *); -NPY_NO_EXPORT npy_bool NpyIter_IsGrowInner \ +NPY_NO_EXPORT npy_bool NpyIter_IsGrowInner \ (NpyIter *); -NPY_NO_EXPORT npy_intp NpyIter_GetBufferSize \ +NPY_NO_EXPORT npy_intp NpyIter_GetBufferSize \ (NpyIter *); -NPY_NO_EXPORT npy_intp * NpyIter_GetIndexPtr \ +NPY_NO_EXPORT npy_intp * NpyIter_GetIndexPtr \ (NpyIter *); -NPY_NO_EXPORT int NpyIter_GotoIndex \ +NPY_NO_EXPORT int NpyIter_GotoIndex \ (NpyIter *, npy_intp); -NPY_NO_EXPORT char ** NpyIter_GetDataPtrArray \ +NPY_NO_EXPORT char ** NpyIter_GetDataPtrArray \ (NpyIter *); -NPY_NO_EXPORT PyArray_Descr ** NpyIter_GetDescrArray \ +NPY_NO_EXPORT PyArray_Descr ** NpyIter_GetDescrArray \ (NpyIter *); -NPY_NO_EXPORT PyArrayObject ** NpyIter_GetOperandArray \ +NPY_NO_EXPORT PyArrayObject ** NpyIter_GetOperandArray \ (NpyIter *); -NPY_NO_EXPORT PyArrayObject * NpyIter_GetIterView \ +NPY_NO_EXPORT PyArrayObject * NpyIter_GetIterView \ (NpyIter *, npy_intp); -NPY_NO_EXPORT void NpyIter_GetReadFlags \ +NPY_NO_EXPORT void NpyIter_GetReadFlags \ (NpyIter *, char *); -NPY_NO_EXPORT void NpyIter_GetWriteFlags \ +NPY_NO_EXPORT void NpyIter_GetWriteFlags \ (NpyIter *, char *); -NPY_NO_EXPORT void NpyIter_DebugPrint \ +NPY_NO_EXPORT void NpyIter_DebugPrint \ (NpyIter *); -NPY_NO_EXPORT npy_bool NpyIter_IterationNeedsAPI \ +NPY_NO_EXPORT npy_bool NpyIter_IterationNeedsAPI \ (NpyIter *); -NPY_NO_EXPORT void NpyIter_GetInnerFixedStrideArray \ +NPY_NO_EXPORT void NpyIter_GetInnerFixedStrideArray \ (NpyIter *, npy_intp *); -NPY_NO_EXPORT int NpyIter_RemoveAxis \ +NPY_NO_EXPORT int NpyIter_RemoveAxis \ (NpyIter *, int); -NPY_NO_EXPORT npy_intp * NpyIter_GetAxisStrideArray \ +NPY_NO_EXPORT npy_intp * NpyIter_GetAxisStrideArray \ (NpyIter *, int); -NPY_NO_EXPORT npy_bool NpyIter_RequiresBuffering \ +NPY_NO_EXPORT npy_bool NpyIter_RequiresBuffering \ (NpyIter *); -NPY_NO_EXPORT char ** NpyIter_GetInitialDataPtrArray \ +NPY_NO_EXPORT char ** NpyIter_GetInitialDataPtrArray \ (NpyIter *); -NPY_NO_EXPORT int NpyIter_CreateCompatibleStrides \ +NPY_NO_EXPORT int NpyIter_CreateCompatibleStrides \ (NpyIter *, npy_intp, npy_intp *); -NPY_NO_EXPORT int PyArray_CastingConverter \ +NPY_NO_EXPORT int PyArray_CastingConverter \ (PyObject *, NPY_CASTING *); -NPY_NO_EXPORT npy_intp PyArray_CountNonzero \ +NPY_NO_EXPORT npy_intp PyArray_CountNonzero \ (PyArrayObject *); -NPY_NO_EXPORT PyArray_Descr * PyArray_PromoteTypes \ +NPY_NO_EXPORT PyArray_Descr * PyArray_PromoteTypes \ (PyArray_Descr *, PyArray_Descr *); -NPY_NO_EXPORT PyArray_Descr * PyArray_MinScalarType \ +NPY_NO_EXPORT PyArray_Descr * PyArray_MinScalarType \ (PyArrayObject *); -NPY_NO_EXPORT PyArray_Descr * PyArray_ResultType \ +NPY_NO_EXPORT PyArray_Descr * PyArray_ResultType \ (npy_intp, PyArrayObject **, npy_intp, PyArray_Descr **); -NPY_NO_EXPORT npy_bool PyArray_CanCastArrayTo \ +NPY_NO_EXPORT npy_bool PyArray_CanCastArrayTo \ (PyArrayObject *, PyArray_Descr *, NPY_CASTING); -NPY_NO_EXPORT npy_bool PyArray_CanCastTypeTo \ +NPY_NO_EXPORT npy_bool PyArray_CanCastTypeTo \ (PyArray_Descr *, PyArray_Descr *, NPY_CASTING); -NPY_NO_EXPORT PyArrayObject * PyArray_EinsteinSum \ +NPY_NO_EXPORT PyArrayObject * PyArray_EinsteinSum \ (char *, npy_intp, PyArrayObject **, PyArray_Descr *, NPY_ORDER, NPY_CASTING, PyArrayObject *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) NPY_GCC_NONNULL(1) PyObject * PyArray_NewLikeArray \ +NPY_NO_EXPORT PyObject * PyArray_NewLikeArray \ (PyArrayObject *, NPY_ORDER, PyArray_Descr *, int); -NPY_NO_EXPORT int PyArray_GetArrayParamsFromObject \ +NPY_NO_EXPORT int PyArray_GetArrayParamsFromObject \ (PyObject *, PyArray_Descr *, npy_bool, PyArray_Descr **, int *, npy_intp *, PyArrayObject **, PyObject *); -NPY_NO_EXPORT int PyArray_ConvertClipmodeSequence \ +NPY_NO_EXPORT int PyArray_ConvertClipmodeSequence \ (PyObject *, NPY_CLIPMODE *, int); -NPY_NO_EXPORT PyObject * PyArray_MatrixProduct2 \ +NPY_NO_EXPORT PyObject * PyArray_MatrixProduct2 \ (PyObject *, PyObject *, PyArrayObject*); -NPY_NO_EXPORT npy_bool NpyIter_IsFirstVisit \ +NPY_NO_EXPORT npy_bool NpyIter_IsFirstVisit \ (NpyIter *, int); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) int PyArray_SetBaseObject \ +NPY_NO_EXPORT int PyArray_SetBaseObject \ (PyArrayObject *, PyObject *); -NPY_NO_EXPORT void PyArray_CreateSortedStridePerm \ +NPY_NO_EXPORT void PyArray_CreateSortedStridePerm \ (int, npy_intp *, npy_stride_sort_item *); -NPY_NO_EXPORT void PyArray_RemoveAxesInPlace \ +NPY_NO_EXPORT void PyArray_RemoveAxesInPlace \ (PyArrayObject *, npy_bool *); -NPY_NO_EXPORT void PyArray_DebugPrint \ +NPY_NO_EXPORT void PyArray_DebugPrint \ (PyArrayObject *); -NPY_NO_EXPORT int PyArray_FailUnlessWriteable \ +NPY_NO_EXPORT int PyArray_FailUnlessWriteable \ (PyArrayObject *, const char *); -NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) int PyArray_SetUpdateIfCopyBase \ +NPY_NO_EXPORT int PyArray_SetUpdateIfCopyBase \ (PyArrayObject *, PyArrayObject *); -NPY_NO_EXPORT void * PyDataMem_NEW \ +NPY_NO_EXPORT void * PyDataMem_NEW \ (size_t); -NPY_NO_EXPORT void PyDataMem_FREE \ +NPY_NO_EXPORT void PyDataMem_FREE \ (void *); -NPY_NO_EXPORT void * PyDataMem_RENEW \ +NPY_NO_EXPORT void * PyDataMem_RENEW \ (void *, size_t); -NPY_NO_EXPORT PyDataMem_EventHookFunc * PyDataMem_SetEventHook \ +NPY_NO_EXPORT PyDataMem_EventHookFunc * PyDataMem_SetEventHook \ (PyDataMem_EventHookFunc *, void *, void **); #ifdef NPY_ENABLE_SEPARATE_COMPILATION extern NPY_NO_EXPORT NPY_CASTING NPY_DEFAULT_ASSIGN_CASTING; @@ -782,22 +782,6 @@ NPY_NO_EXPORT PyDataMem_EventHookFunc * PyDataMem_SetEventHook \ NPY_NO_EXPORT NPY_CASTING NPY_DEFAULT_ASSIGN_CASTING; #endif -NPY_NO_EXPORT void PyArray_MapIterSwapAxes \ - (PyArrayMapIterObject *, PyArrayObject **, int); -NPY_NO_EXPORT PyObject * PyArray_MapIterArray \ - (PyArrayObject *, PyObject *); -NPY_NO_EXPORT void PyArray_MapIterNext \ - (PyArrayMapIterObject *); -NPY_NO_EXPORT int PyArray_Partition \ - (PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND); -NPY_NO_EXPORT PyObject * PyArray_ArgPartition \ - (PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND); -NPY_NO_EXPORT int PyArray_SelectkindConverter \ - (PyObject *, NPY_SELECTKIND *); -NPY_NO_EXPORT void * PyDataMem_NEW_ZEROED \ - (size_t, size_t); -NPY_NO_EXPORT NPY_GCC_NONNULL(1) int PyArray_CheckAnyScalarExact \ - (PyObject *); #else @@ -1604,30 +1588,6 @@ static void **PyArray_API=NULL; (*(PyDataMem_EventHookFunc * (*)(PyDataMem_EventHookFunc *, void *, void **)) \ PyArray_API[291]) #define NPY_DEFAULT_ASSIGN_CASTING (*(NPY_CASTING *)PyArray_API[292]) -#define PyArray_MapIterSwapAxes \ - (*(void (*)(PyArrayMapIterObject *, PyArrayObject **, int)) \ - PyArray_API[293]) -#define PyArray_MapIterArray \ - (*(PyObject * (*)(PyArrayObject *, PyObject *)) \ - PyArray_API[294]) -#define PyArray_MapIterNext \ - (*(void (*)(PyArrayMapIterObject *)) \ - PyArray_API[295]) -#define PyArray_Partition \ - (*(int (*)(PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND)) \ - PyArray_API[296]) -#define PyArray_ArgPartition \ - (*(PyObject * (*)(PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND)) \ - PyArray_API[297]) -#define PyArray_SelectkindConverter \ - (*(int (*)(PyObject *, NPY_SELECTKIND *)) \ - PyArray_API[298]) -#define PyDataMem_NEW_ZEROED \ - (*(void * (*)(size_t, size_t)) \ - PyArray_API[299]) -#define PyArray_CheckAnyScalarExact \ - (*(int (*)(PyObject *)) \ - PyArray_API[300]) #if !defined(NO_IMPORT_ARRAY) && !defined(NO_IMPORT) static int diff --git a/include/numpy/__ufunc_api.h b/include/numpy/__ufunc_api.h index 6ebef2dec..fd81d07b5 100644 --- a/include/numpy/__ufunc_api.h +++ b/include/numpy/__ufunc_api.h @@ -13,88 +13,86 @@ NPY_NO_EXPORT PyTypeObject PyUFunc_Type; NPY_NO_EXPORT PyTypeObject PyUFunc_Type; #endif -NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndData \ - (PyUFuncGenericFunction *, void **, char *, int, int, int, int, const char *, const char *, int); -NPY_NO_EXPORT int PyUFunc_RegisterLoopForType \ +NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndData \ + (PyUFuncGenericFunction *, void **, char *, int, int, int, int, char *, char *, int); +NPY_NO_EXPORT int PyUFunc_RegisterLoopForType \ (PyUFuncObject *, int, PyUFuncGenericFunction, int *, void *); -NPY_NO_EXPORT int PyUFunc_GenericFunction \ +NPY_NO_EXPORT int PyUFunc_GenericFunction \ (PyUFuncObject *, PyObject *, PyObject *, PyArrayObject **); -NPY_NO_EXPORT void PyUFunc_f_f_As_d_d \ +NPY_NO_EXPORT void PyUFunc_f_f_As_d_d \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_d_d \ +NPY_NO_EXPORT void PyUFunc_d_d \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_f_f \ +NPY_NO_EXPORT void PyUFunc_f_f \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_g_g \ +NPY_NO_EXPORT void PyUFunc_g_g \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_F_F_As_D_D \ +NPY_NO_EXPORT void PyUFunc_F_F_As_D_D \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_F_F \ +NPY_NO_EXPORT void PyUFunc_F_F \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_D_D \ +NPY_NO_EXPORT void PyUFunc_D_D \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_G_G \ +NPY_NO_EXPORT void PyUFunc_G_G \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_O_O \ +NPY_NO_EXPORT void PyUFunc_O_O \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_ff_f_As_dd_d \ +NPY_NO_EXPORT void PyUFunc_ff_f_As_dd_d \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_ff_f \ +NPY_NO_EXPORT void PyUFunc_ff_f \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_dd_d \ +NPY_NO_EXPORT void PyUFunc_dd_d \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_gg_g \ +NPY_NO_EXPORT void PyUFunc_gg_g \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_FF_F_As_DD_D \ +NPY_NO_EXPORT void PyUFunc_FF_F_As_DD_D \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_DD_D \ +NPY_NO_EXPORT void PyUFunc_DD_D \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_FF_F \ +NPY_NO_EXPORT void PyUFunc_FF_F \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_GG_G \ +NPY_NO_EXPORT void PyUFunc_GG_G \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_OO_O \ +NPY_NO_EXPORT void PyUFunc_OO_O \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_O_O_method \ +NPY_NO_EXPORT void PyUFunc_O_O_method \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_OO_O_method \ +NPY_NO_EXPORT void PyUFunc_OO_O_method \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_On_Om \ +NPY_NO_EXPORT void PyUFunc_On_Om \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT int PyUFunc_GetPyValues \ +NPY_NO_EXPORT int PyUFunc_GetPyValues \ (char *, int *, int *, PyObject **); -NPY_NO_EXPORT int PyUFunc_checkfperr \ +NPY_NO_EXPORT int PyUFunc_checkfperr \ (int, PyObject *, int *); -NPY_NO_EXPORT void PyUFunc_clearfperr \ +NPY_NO_EXPORT void PyUFunc_clearfperr \ (void); -NPY_NO_EXPORT int PyUFunc_getfperr \ +NPY_NO_EXPORT int PyUFunc_getfperr \ (void); -NPY_NO_EXPORT int PyUFunc_handlefperr \ +NPY_NO_EXPORT int PyUFunc_handlefperr \ (int, PyObject *, int, int *); -NPY_NO_EXPORT int PyUFunc_ReplaceLoopBySignature \ +NPY_NO_EXPORT int PyUFunc_ReplaceLoopBySignature \ (PyUFuncObject *, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *); -NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndDataAndSignature \ - (PyUFuncGenericFunction *, void **, char *, int, int, int, int, const char *, const char *, int, const char *); -NPY_NO_EXPORT int PyUFunc_SetUsesArraysAsData \ +NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndDataAndSignature \ + (PyUFuncGenericFunction *, void **, char *, int, int, int, int, char *, char *, int, const char *); +NPY_NO_EXPORT int PyUFunc_SetUsesArraysAsData \ (void **, size_t); -NPY_NO_EXPORT void PyUFunc_e_e \ +NPY_NO_EXPORT void PyUFunc_e_e \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_e_e_As_f_f \ +NPY_NO_EXPORT void PyUFunc_e_e_As_f_f \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_e_e_As_d_d \ +NPY_NO_EXPORT void PyUFunc_e_e_As_d_d \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_ee_e \ +NPY_NO_EXPORT void PyUFunc_ee_e \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_ee_e_As_ff_f \ +NPY_NO_EXPORT void PyUFunc_ee_e_As_ff_f \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT void PyUFunc_ee_e_As_dd_d \ +NPY_NO_EXPORT void PyUFunc_ee_e_As_dd_d \ (char **, npy_intp *, npy_intp *, void *); -NPY_NO_EXPORT int PyUFunc_DefaultTypeResolver \ +NPY_NO_EXPORT int PyUFunc_DefaultTypeResolver \ (PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyObject *, PyArray_Descr **); -NPY_NO_EXPORT int PyUFunc_ValidateCasting \ +NPY_NO_EXPORT int PyUFunc_ValidateCasting \ (PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyArray_Descr **); -NPY_NO_EXPORT int PyUFunc_RegisterLoopForDescr \ - (PyUFuncObject *, PyArray_Descr *, PyUFuncGenericFunction, PyArray_Descr **, void *); #else @@ -114,7 +112,7 @@ static void **PyUFunc_API=NULL; #define PyUFunc_Type (*(PyTypeObject *)PyUFunc_API[0]) #define PyUFunc_FromFuncAndData \ - (*(PyObject * (*)(PyUFuncGenericFunction *, void **, char *, int, int, int, int, const char *, const char *, int)) \ + (*(PyObject * (*)(PyUFuncGenericFunction *, void **, char *, int, int, int, int, char *, char *, int)) \ PyUFunc_API[1]) #define PyUFunc_RegisterLoopForType \ (*(int (*)(PyUFuncObject *, int, PyUFuncGenericFunction, int *, void *)) \ @@ -204,7 +202,7 @@ static void **PyUFunc_API=NULL; (*(int (*)(PyUFuncObject *, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *)) \ PyUFunc_API[30]) #define PyUFunc_FromFuncAndDataAndSignature \ - (*(PyObject * (*)(PyUFuncGenericFunction *, void **, char *, int, int, int, int, const char *, const char *, int, const char *)) \ + (*(PyObject * (*)(PyUFuncGenericFunction *, void **, char *, int, int, int, int, char *, char *, int, const char *)) \ PyUFunc_API[31]) #define PyUFunc_SetUsesArraysAsData \ (*(int (*)(void **, size_t)) \ @@ -233,11 +231,8 @@ static void **PyUFunc_API=NULL; #define PyUFunc_ValidateCasting \ (*(int (*)(PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyArray_Descr **)) \ PyUFunc_API[40]) -#define PyUFunc_RegisterLoopForDescr \ - (*(int (*)(PyUFuncObject *, PyArray_Descr *, PyUFuncGenericFunction, PyArray_Descr **, void *)) \ - PyUFunc_API[41]) -static NPY_INLINE int +static int _import_umath(void) { PyObject *numpy = PyImport_ImportModule("numpy.core.umath"); diff --git a/include/numpy/_numpyconfig.h b/include/numpy/_numpyconfig.h index fc23ebc00..d55ffc38d 100644 --- a/include/numpy/_numpyconfig.h +++ b/include/numpy/_numpyconfig.h @@ -8,7 +8,6 @@ #define NPY_SIZEOF_LONGDOUBLE 16 #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 32 #define NPY_SIZEOF_PY_INTPTR_T 8 -#define NPY_SIZEOF_OFF_T 8 #define NPY_SIZEOF_PY_LONG_LONG 8 #define NPY_SIZEOF_LONGLONG 8 #define NPY_NO_SMP 0 @@ -20,11 +19,10 @@ #define NPY_HAVE_COMPLEX_DOUBLE 1 #define NPY_HAVE_COMPLEX_FLOAT 1 #define NPY_HAVE_COMPLEX_LONG_DOUBLE 1 -#define NPY_ENABLE_SEPARATE_COMPILATION 1 #define NPY_USE_C99_FORMATS 1 #define NPY_VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) #define NPY_ABI_VERSION 0x01000009 -#define NPY_API_VERSION 0x0000000A +#define NPY_API_VERSION 0x00000007 #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS 1 diff --git a/include/numpy/arrayobject.h b/include/numpy/arrayobject.h index 4f46d6b1a..a84766f63 100644 --- a/include/numpy/arrayobject.h +++ b/include/numpy/arrayobject.h @@ -1,3 +1,14 @@ + +/* This expects the following variables to be defined (besides + the usual ones from pyconfig.h + + SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no + long double is present on platform. + CHAR_BIT -- number of bits in a char (usually 8) + (should be in limits.h) + +*/ + #ifndef Py_ARRAYOBJECT_H #define Py_ARRAYOBJECT_H diff --git a/include/numpy/multiarray_api.txt b/include/numpy/multiarray_api.txt index 8156f9752..7e588f067 100644 --- a/include/numpy/multiarray_api.txt +++ b/include/numpy/multiarray_api.txt @@ -85,7 +85,7 @@ Get pointer to one of correct type for array For backward compatibility Cast an array using typecode structure. -steals reference to dtype --- cannot be NULL +steals reference to at --- cannot be NULL This function always makes a copy of arr, even if the dtype doesn't change. @@ -356,7 +356,6 @@ steals a reference to dtype (which cannot be NULL) Return either an array or the appropriate Python object if the array is 0d and matches a Python type. -steals reference to mp :: @@ -365,7 +364,6 @@ steals reference to mp offset) Get a subset of bytes from each element of the array -steals reference to typed, must not be NULL :: @@ -374,7 +372,6 @@ steals reference to typed, must not be NULL offset, PyObject *val) Set a subset of bytes from each element of the array -steals reference to dtype, must not be NULL :: @@ -1109,7 +1106,7 @@ as you get a new reference to it. PyArray_IntpFromSequence(PyObject *seq, npy_intp *vals, int maxvals) PyArray_IntpFromSequence -Returns the number of integers converted or -1 if an error occurred. +Returns the number of dimensions or -1 if an error occurred. vals must be large enough to hold maxvals :: @@ -2181,7 +2178,7 @@ int ndim = 0; npy_intp dims[NPY_MAXDIMS]; if (PyArray_GetArrayParamsFromObject(op, NULL, 1, &dtype, -&ndim, dims, &arr, NULL) < 0) { +&ndim, &dims, &arr, NULL) < 0) { return NULL; } if (arr == NULL) { @@ -2221,7 +2218,7 @@ could be applied to each axis, like in ravel_multi_index. PyArray_MatrixProduct2(PyObject *op1, PyObject *op2, PyArrayObject*out) -Numeric.matrixproduct2(a,v,out) +Numeric.matrixproduct(a,v,out) just like inner product but does the swapaxes stuff on the fly :: @@ -2287,10 +2284,6 @@ index zero for that axis. WARNING: If an axis flagged for removal has a shape equal to zero, the array will point to invalid memory. The caller must validate this! -If an axis flagged for removal has a shape larger then one, -the aligned flag (and in the future the contiguous flags), -may need explicite update. -(check also NPY_RELAXED_STRIDES_CHECKING) For example, this can be used to remove the reduction axes from a reduction result once its computation is complete. @@ -2380,70 +2373,3 @@ operations that might cause new allocation events (such as the creation/descruction numpy objects, or creating/destroying Python objects which might cause a gc) -:: - - void - PyArray_MapIterSwapAxes(PyArrayMapIterObject *mit, PyArrayObject - **ret, int getmap) - - -:: - - PyObject * - PyArray_MapIterArray(PyArrayObject *a, PyObject *index) - - -Use advanced indexing to iterate an array. Please note -that most of this public API is currently not guaranteed -to stay the same between versions. If you plan on using -it, please consider adding more utility functions here -to accommodate new features. - -:: - - void - PyArray_MapIterNext(PyArrayMapIterObject *mit) - -This function needs to update the state of the map iterator -and point mit->dataptr to the memory-location of the next object - -Note that this function never handles an extra operand but provides -compatibility for an old (exposed) API. - -:: - - int - PyArray_Partition(PyArrayObject *op, PyArrayObject *ktharray, int - axis, NPY_SELECTKIND which) - -Partition an array in-place - -:: - - PyObject * - PyArray_ArgPartition(PyArrayObject *op, PyArrayObject *ktharray, int - axis, NPY_SELECTKIND which) - -ArgPartition an array - -:: - - int - PyArray_SelectkindConverter(PyObject *obj, NPY_SELECTKIND *selectkind) - -Convert object to select kind - -:: - - void * - PyDataMem_NEW_ZEROED(size_t size, size_t elsize) - -Allocates zeroed memory for array data. - -:: - - int - PyArray_CheckAnyScalarExact(PyObject *obj) - -return true an object is exactly a numpy scalar - diff --git a/include/numpy/ndarrayobject.h b/include/numpy/ndarrayobject.h index c97a3a797..f00dd7744 100644 --- a/include/numpy/ndarrayobject.h +++ b/include/numpy/ndarrayobject.h @@ -14,7 +14,6 @@ extern "C" CONFUSE_EMACS everything when you're typing */ #endif -#include #include "ndarraytypes.h" /* Includes the "function" C-API -- these are all stored in a @@ -51,26 +50,14 @@ extern "C" CONFUSE_EMACS #define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \ PyArray_IsZeroDim(m)) -#if PY_MAJOR_VERSION >= 3 -#define PyArray_IsPythonNumber(obj) \ - (PyFloat_Check(obj) || PyComplex_Check(obj) || \ - PyLong_Check(obj) || PyBool_Check(obj)) -#define PyArray_IsIntegerScalar(obj) (PyLong_Check(obj) \ - || PyArray_IsScalar((obj), Integer)) -#define PyArray_IsPythonScalar(obj) \ - (PyArray_IsPythonNumber(obj) || PyBytes_Check(obj) || \ - PyUnicode_Check(obj)) -#else + #define PyArray_IsPythonNumber(obj) \ (PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \ PyLong_Check(obj) || PyBool_Check(obj)) -#define PyArray_IsIntegerScalar(obj) (PyInt_Check(obj) \ - || PyLong_Check(obj) \ - || PyArray_IsScalar((obj), Integer)) + #define PyArray_IsPythonScalar(obj) \ (PyArray_IsPythonNumber(obj) || PyString_Check(obj) || \ PyUnicode_Check(obj)) -#endif #define PyArray_IsAnyScalar(obj) \ (PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj)) @@ -78,6 +65,10 @@ extern "C" CONFUSE_EMACS #define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \ PyArray_CheckScalar(obj)) +#define PyArray_IsIntegerScalar(obj) (PyInt_Check(obj) \ + || PyLong_Check(obj) \ + || PyArray_IsScalar((obj), Integer)) + #define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? \ Py_INCREF(m), (m) : \ @@ -96,7 +87,7 @@ extern "C" CONFUSE_EMACS NULL) #define PyArray_FROM_OT(m,type) PyArray_FromAny(m, \ - PyArray_DescrFromType(type), 0, 0, 0, NULL) + PyArray_DescrFromType(type), 0, 0, 0, NULL); #define PyArray_FROM_OTF(m, type, flags) \ PyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \ @@ -234,8 +225,15 @@ PyArray_XDECREF_ERR(PyArrayObject *arr) (PyTuple_GET_ITEM((value), 2) == (key))) +/* Define python version independent deprecation macro */ + +#if PY_VERSION_HEX >= 0x02050000 #define DEPRECATE(msg) PyErr_WarnEx(PyExc_DeprecationWarning,msg,1) #define DEPRECATE_FUTUREWARNING(msg) PyErr_WarnEx(PyExc_FutureWarning,msg,1) +#else +#define DEPRECATE(msg) PyErr_Warn(PyExc_DeprecationWarning,msg) +#define DEPRECATE_FUTUREWARNING(msg) PyErr_Warn(PyExc_FutureWarning,msg) +#endif #ifdef __cplusplus diff --git a/include/numpy/ndarraytypes.h b/include/numpy/ndarraytypes.h index 8403ee29f..04d037ec8 100644 --- a/include/numpy/ndarraytypes.h +++ b/include/numpy/ndarraytypes.h @@ -1,6 +1,9 @@ #ifndef NDARRAYTYPES_H #define NDARRAYTYPES_H +/* numpyconfig.h is auto-generated by the installer */ +#include "numpyconfig.h" + #include "npy_common.h" #include "npy_endian.h" #include "npy_cpu.h" @@ -155,12 +158,6 @@ typedef enum { #define NPY_NSORTS (NPY_MERGESORT + 1) -typedef enum { - NPY_INTROSELECT=0 -} NPY_SELECTKIND; -#define NPY_NSELECTS (NPY_INTROSELECT + 1) - - typedef enum { NPY_SEARCHLEFT=0, NPY_SEARCHRIGHT=1 @@ -202,7 +199,13 @@ typedef enum { /* Allow safe casts or casts within the same kind */ NPY_SAME_KIND_CASTING=3, /* Allow any casts */ - NPY_UNSAFE_CASTING=4 + NPY_UNSAFE_CASTING=4, + + /* + * Temporary internal definition only, will be removed in upcoming + * release, see below + * */ + NPY_INTERNAL_UNSAFE_CASTING_BUT_WARN_UNLESS_SAME_KIND = 100, } NPY_CASTING; typedef enum { @@ -391,12 +394,6 @@ typedef int (PyArray_FillFunc)(void *, npy_intp, void *); typedef int (PyArray_SortFunc)(void *, npy_intp, void *); typedef int (PyArray_ArgSortFunc)(void *, npy_intp *, npy_intp, void *); -typedef int (PyArray_PartitionFunc)(void *, npy_intp, npy_intp, - npy_intp *, npy_intp *, - void *); -typedef int (PyArray_ArgPartitionFunc)(void *, npy_intp *, npy_intp, npy_intp, - npy_intp *, npy_intp *, - void *); typedef int (PyArray_FillWithScalarFunc)(void *, npy_intp, void *, void *); @@ -619,10 +616,6 @@ typedef struct _PyArray_Descr { * for NumPy 1.7.0. */ NpyAuxData *c_metadata; - /* Cached hash value (-1 if not yet computed). - * This was added for NumPy 2.0.0. - */ - npy_hash_t hash; } PyArray_Descr; typedef struct _arr_descr { @@ -637,8 +630,8 @@ typedef struct _arr_descr { * (PyArray_DATA and friends) to access fields here for a number of * releases. Direct access to the members themselves is deprecated. * To ensure that your code does not use deprecated access, - * #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION - * (or NPY_1_8_API_VERSION or higher as required). + * #define NPY_NO_DEPRECATED_API NPY_1_7_VERSION + * (or NPY_1_8_VERSION or higher as required). */ /* This struct will be moved to a private header in a future release */ typedef struct tagPyArrayObject_fields { @@ -685,8 +678,7 @@ typedef struct tagPyArrayObject_fields { * To hide the implementation details, we only expose * the Python struct HEAD. */ -#if !defined(NPY_NO_DEPRECATED_API) || \ - (NPY_NO_DEPRECATED_API < NPY_1_7_API_VERSION) +#if !(defined(NPY_NO_DEPRECATED_API) && (NPY_API_VERSION <= NPY_NO_DEPRECATED_API)) /* * Can't put this in npy_deprecated_api.h like the others. * PyArrayObject field access is deprecated as of NumPy 1.7. @@ -765,14 +757,7 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *); /* * Note: all 0-d arrays are C_CONTIGUOUS and F_CONTIGUOUS. If a - * 1-d array is C_CONTIGUOUS it is also F_CONTIGUOUS. Arrays with - * more then one dimension can be C_CONTIGUOUS and F_CONTIGUOUS - * at the same time if they have either zero or one element. - * If NPY_RELAXED_STRIDES_CHECKING is set, a higher dimensional - * array is always C_CONTIGUOUS and F_CONTIGUOUS if it has zero elements - * and the array is contiguous if ndarray.squeeze() is contiguous. - * I.e. dimensions for which `ndarray.shape[dimension] == 1` are - * ignored. + * 1-d array is C_CONTIGUOUS it is also F_CONTIGUOUS */ /* @@ -926,16 +911,12 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *); #define PyArray_IS_C_CONTIGUOUS(m) PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS) #define PyArray_IS_F_CONTIGUOUS(m) PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) -/* the variable is used in some places, so always define it */ -#define NPY_BEGIN_THREADS_DEF PyThreadState *_save=NULL; #if NPY_ALLOW_THREADS #define NPY_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS #define NPY_END_ALLOW_THREADS Py_END_ALLOW_THREADS +#define NPY_BEGIN_THREADS_DEF PyThreadState *_save=NULL; #define NPY_BEGIN_THREADS do {_save = PyEval_SaveThread();} while (0); -#define NPY_END_THREADS do { if (_save) \ - { PyEval_RestoreThread(_save); _save = NULL;} } while (0); -#define NPY_BEGIN_THREADS_THRESHOLDED(loop_size) do { if (loop_size > 500) \ - { _save = PyEval_SaveThread();} } while (0); +#define NPY_END_THREADS do {if (_save) PyEval_RestoreThread(_save);} while (0); #define NPY_BEGIN_THREADS_DESCR(dtype) \ do {if (!(PyDataType_FLAGCHK(dtype, NPY_NEEDS_PYAPI))) \ @@ -951,9 +932,9 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *); #else #define NPY_BEGIN_ALLOW_THREADS #define NPY_END_ALLOW_THREADS +#define NPY_BEGIN_THREADS_DEF #define NPY_BEGIN_THREADS #define NPY_END_THREADS -#define NPY_BEGIN_THREADS_THRESHOLDED(loop_size) #define NPY_BEGIN_THREADS_DESCR(dtype) #define NPY_END_THREADS_DESCR(dtype) #define NPY_ALLOW_C_API_DEF @@ -1099,6 +1080,27 @@ struct PyArrayIterObject_tag { } \ } while (0) +#define _PyArray_ITER_NEXT3(it) do { \ + if ((it)->coordinates[2] < (it)->dims_m1[2]) { \ + (it)->coordinates[2]++; \ + (it)->dataptr += (it)->strides[2]; \ + } \ + else { \ + (it)->coordinates[2] = 0; \ + (it)->dataptr -= (it)->backstrides[2]; \ + if ((it)->coordinates[1] < (it)->dims_m1[1]) { \ + (it)->coordinates[1]++; \ + (it)->dataptr += (it)->strides[1]; \ + } \ + else { \ + (it)->coordinates[1] = 0; \ + (it)->coordinates[0]++; \ + (it)->dataptr += (it)->strides[0] \ + (it)->backstrides[1]; \ + } \ + } \ +} while (0) + #define PyArray_ITER_NEXT(it) do { \ _PyAIT(it)->index++; \ if (_PyAIT(it)->nd_m1 == 0) { \ @@ -1233,12 +1235,8 @@ typedef struct { #define PyArray_MultiIter_NOTDONE(multi) \ (_PyMIT(multi)->index < _PyMIT(multi)->size) +/* Store the information needed for fancy-indexing over an array */ -/* - * Store the information needed for fancy-indexing over an array. The - * fields are slightly unordered to keep consec, dataptr and subspace - * where they were originally. - */ typedef struct { PyObject_HEAD /* @@ -1253,71 +1251,29 @@ typedef struct { npy_intp index; /* current index */ int nd; /* number of dims */ npy_intp dimensions[NPY_MAXDIMS]; /* dimensions */ - NpyIter *outer; /* index objects - iterator */ - void *unused[NPY_MAXDIMS - 2]; - PyArrayObject *array; - /* Flat iterator for the indexed array. For compatibility solely. */ - PyArrayIterObject *ait; + PyArrayIterObject *iters[NPY_MAXDIMS]; /* index object + iterators */ + PyArrayIterObject *ait; /* flat Iterator for + underlying array */ - /* - * Subspace array. For binary compatibility (was an iterator, - * but only the check for NULL should be used). - */ - PyArrayObject *subspace; + /* flat iterator for subspace (when numiter < nd) */ + PyArrayIterObject *subspace; /* * if subspace iteration, then this is the array of axes in * the underlying array represented by the index objects */ int iteraxes[NPY_MAXDIMS]; - npy_intp fancy_strides[NPY_MAXDIMS]; - - /* pointer when all fancy indices are 0 */ - char *baseoffset; - /* - * after binding consec denotes at which axis the fancy axes - * are inserted. + * if subspace iteration, the these are the coordinates to the + * start of the subspace. */ + npy_intp bscoord[NPY_MAXDIMS]; + + PyObject *indexobj; /* creating obj */ int consec; char *dataptr; - int nd_fancy; - npy_intp fancy_dims[NPY_MAXDIMS]; - - /* Whether the iterator (any of the iterators) requires API */ - int needs_api; - - /* - * Extra op information. - */ - PyArrayObject *extra_op; - PyArray_Descr *extra_op_dtype; /* desired dtype */ - npy_uint32 *extra_op_flags; /* Iterator flags */ - - NpyIter *extra_op_iter; - NpyIter_IterNextFunc *extra_op_next; - char **extra_op_ptrs; - - /* - * Information about the iteration state. - */ - NpyIter_IterNextFunc *outer_next; - char **outer_ptrs; - npy_intp *outer_strides; - - /* - * Information about the subspace iterator. - */ - NpyIter *subspace_iter; - NpyIter_IterNextFunc *subspace_next; - char **subspace_ptrs; - npy_intp *subspace_strides; - - /* Count for the external loop (which ever it is) for API iteration */ - npy_intp iter_count; - } PyArrayMapIterObject; enum { @@ -1414,12 +1370,12 @@ PyArrayNeighborhoodIter_Next2D(PyArrayNeighborhoodIterObject* iter); PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS)) #define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) && \ - (!PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS))) + (PyArray_NDIM(m) > 1)) #define PyArray_FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) ? \ NPY_ARRAY_F_CONTIGUOUS : 0)) -#if (defined(NPY_NO_DEPRECATED_API) && (NPY_1_7_API_VERSION <= NPY_NO_DEPRECATED_API)) +#if (defined(NPY_NO_DEPRECATED_API) && (NPY_API_VERSION <= NPY_NO_DEPRECATED_API)) /* * Changing access macros into functions, to allow for future hiding * of the internal memory layout. This later hiding will allow the 2.x series @@ -1469,13 +1425,13 @@ PyArray_STRIDE(const PyArrayObject *arr, int istride) return ((PyArrayObject_fields *)arr)->strides[istride]; } -static NPY_INLINE NPY_RETURNS_BORROWED_REF PyObject * +static NPY_INLINE PyObject * PyArray_BASE(PyArrayObject *arr) { return ((PyArrayObject_fields *)arr)->base; } -static NPY_INLINE NPY_RETURNS_BORROWED_REF PyArray_Descr * +static NPY_INLINE PyArray_Descr * PyArray_DESCR(PyArrayObject *arr) { return ((PyArrayObject_fields *)arr)->descr; @@ -1768,30 +1724,8 @@ typedef struct { typedef void (PyDataMem_EventHookFunc)(void *inp, void *outp, size_t size, void *user_data); -/* - * Use the keyword NPY_DEPRECATED_INCLUDES to ensure that the header files - * npy_*_*_deprecated_api.h are only included from here and nowhere else. - */ -#ifdef NPY_DEPRECATED_INCLUDES -#error "Do not use the reserved keyword NPY_DEPRECATED_INCLUDES." +#if !(defined(NPY_NO_DEPRECATED_API) && (NPY_API_VERSION <= NPY_NO_DEPRECATED_API)) +#include "npy_deprecated_api.h" #endif -#define NPY_DEPRECATED_INCLUDES -#if !defined(NPY_NO_DEPRECATED_API) || \ - (NPY_NO_DEPRECATED_API < NPY_1_7_API_VERSION) -#include "npy_1_7_deprecated_api.h" -#endif -/* - * There is no file npy_1_8_deprecated_api.h since there are no additional - * deprecated API features in NumPy 1.8. - * - * Note to maintainers: insert code like the following in future NumPy - * versions. - * - * #if !defined(NPY_NO_DEPRECATED_API) || \ - * (NPY_NO_DEPRECATED_API < NPY_1_9_API_VERSION) - * #include "npy_1_9_deprecated_api.h" - * #endif - */ -#undef NPY_DEPRECATED_INCLUDES #endif /* NPY_ARRAYTYPES_H */ diff --git a/include/numpy/noprefix.h b/include/numpy/noprefix.h index 830617087..b3e57480e 100644 --- a/include/numpy/noprefix.h +++ b/include/numpy/noprefix.h @@ -64,13 +64,10 @@ #define datetime npy_datetime #define timedelta npy_timedelta -#define SIZEOF_LONGLONG NPY_SIZEOF_LONGLONG -#define SIZEOF_INTP NPY_SIZEOF_INTP -#define SIZEOF_UINTP NPY_SIZEOF_UINTP -#define SIZEOF_HALF NPY_SIZEOF_HALF -#define SIZEOF_LONGDOUBLE NPY_SIZEOF_LONGDOUBLE -#define SIZEOF_DATETIME NPY_SIZEOF_DATETIME -#define SIZEOF_TIMEDELTA NPY_SIZEOF_TIMEDELTA +#define SIZEOF_INTP NPY_SIZEOF_INTP +#define SIZEOF_UINTP NPY_SIZEOF_UINTP +#define SIZEOF_DATETIME NPY_SIZEOF_DATETIME +#define SIZEOF_TIMEDELTA NPY_SIZEOF_TIMEDELTA #define LONGLONG_FMT NPY_LONGLONG_FMT #define ULONGLONG_FMT NPY_ULONGLONG_FMT @@ -116,6 +113,9 @@ #define MIN_TIMEDELTA NPY_MIN_TIMEDELTA #define MAX_TIMEDELTA NPY_MAX_TIMEDELTA +#define SIZEOF_LONGDOUBLE NPY_SIZEOF_LONGDOUBLE +#define SIZEOF_LONGLONG NPY_SIZEOF_LONGLONG +#define SIZEOF_HALF NPY_SIZEOF_HALF #define BITSOF_BOOL NPY_BITSOF_BOOL #define BITSOF_CHAR NPY_BITSOF_CHAR #define BITSOF_SHORT NPY_BITSOF_SHORT diff --git a/include/numpy/npy_3kcompat.h b/include/numpy/npy_3kcompat.h index cd9669798..d0cd9ac1a 100644 --- a/include/numpy/npy_3kcompat.h +++ b/include/numpy/npy_3kcompat.h @@ -141,17 +141,17 @@ PyUnicode_Concat2(PyObject **left, PyObject *right) * PyFile_* compatibility */ #if defined(NPY_PY3K) + /* * Get a FILE* handle to the file represented by the Python object */ static NPY_INLINE FILE* -npy_PyFile_Dup2(PyObject *file, char *mode, npy_off_t *orig_pos) +npy_PyFile_Dup(PyObject *file, char *mode) { int fd, fd2; PyObject *ret, *os; - npy_off_t pos; + Py_ssize_t pos; FILE *handle; - /* Flush first to ensure things end up in the file in the correct order */ ret = PyObject_CallMethod(file, "flush", ""); if (ret == NULL) { @@ -162,11 +162,6 @@ npy_PyFile_Dup2(PyObject *file, char *mode, npy_off_t *orig_pos) if (fd == -1) { return NULL; } - - /* - * The handle needs to be dup'd because we have to call fclose - * at the end - */ os = PyImport_ImportModule("os"); if (os == NULL) { return NULL; @@ -178,8 +173,6 @@ npy_PyFile_Dup2(PyObject *file, char *mode, npy_off_t *orig_pos) } fd2 = PyNumber_AsSsize_t(ret, NULL); Py_DECREF(ret); - - /* Convert to FILE* handle */ #ifdef _WIN32 handle = _fdopen(fd2, mode); #else @@ -189,32 +182,18 @@ npy_PyFile_Dup2(PyObject *file, char *mode, npy_off_t *orig_pos) PyErr_SetString(PyExc_IOError, "Getting a FILE* from a Python file object failed"); } - - /* Record the original raw file handle position */ - *orig_pos = npy_ftell(handle); - if (*orig_pos == -1) { - PyErr_SetString(PyExc_IOError, "obtaining file position failed"); - fclose(handle); - return NULL; - } - - /* Seek raw handle to the Python-side position */ ret = PyObject_CallMethod(file, "tell", ""); if (ret == NULL) { fclose(handle); return NULL; } - pos = PyLong_AsLongLong(ret); + pos = PyNumber_AsSsize_t(ret, PyExc_OverflowError); Py_DECREF(ret); if (PyErr_Occurred()) { fclose(handle); return NULL; } - if (npy_fseek(handle, pos, SEEK_SET) == -1) { - PyErr_SetString(PyExc_IOError, "seeking file failed"); - fclose(handle); - return NULL; - } + npy_fseek(handle, pos, SEEK_SET); return handle; } @@ -222,37 +201,14 @@ npy_PyFile_Dup2(PyObject *file, char *mode, npy_off_t *orig_pos) * Close the dup-ed file handle, and seek the Python one to the current position */ static NPY_INLINE int -npy_PyFile_DupClose2(PyObject *file, FILE* handle, npy_off_t orig_pos) +npy_PyFile_DupClose(PyObject *file, FILE* handle) { - int fd; PyObject *ret; - npy_off_t position; - + Py_ssize_t position; position = npy_ftell(handle); - - /* Close the FILE* handle */ fclose(handle); - /* - * Restore original file handle position, in order to not confuse - * Python-side data structures - */ - fd = PyObject_AsFileDescriptor(file); - if (fd == -1) { - return -1; - } - if (npy_lseek(fd, orig_pos, SEEK_SET) == -1) { - PyErr_SetString(PyExc_IOError, "seeking file failed"); - return -1; - } - - if (position == -1) { - PyErr_SetString(PyExc_IOError, "obtaining file position failed"); - return -1; - } - - /* Seek Python-side handle to the FILE* handle position */ - ret = PyObject_CallMethod(file, "seek", NPY_OFF_T_PYFMT "i", position, 0); + ret = PyObject_CallMethod(file, "seek", NPY_SSIZE_T_PYFMT "i", position, 0); if (ret == NULL) { return -1; } @@ -274,20 +230,8 @@ npy_PyFile_Check(PyObject *file) #else -static NPY_INLINE FILE * -npy_PyFile_Dup2(PyObject *file, - const char *NPY_UNUSED(mode), npy_off_t *NPY_UNUSED(orig_pos)) -{ - return PyFile_AsFile(file); -} - -static NPY_INLINE int -npy_PyFile_DupClose2(PyObject *NPY_UNUSED(file), FILE* NPY_UNUSED(handle), - npy_off_t NPY_UNUSED(orig_pos)) -{ - return 0; -} - +#define npy_PyFile_Dup(file, mode) PyFile_AsFile(file) +#define npy_PyFile_DupClose(file, handle) (0) #define npy_PyFile_Check PyFile_Check #endif @@ -325,7 +269,7 @@ PyObject_Cmp(PyObject *i1, PyObject *i2, int *cmp) { int v; v = PyObject_RichCompareBool(i1, i2, Py_LT); - if (v == 1) { + if (v == 0) { *cmp = -1; return 1; } @@ -334,7 +278,7 @@ PyObject_Cmp(PyObject *i1, PyObject *i2, int *cmp) } v = PyObject_RichCompareBool(i1, i2, Py_GT); - if (v == 1) { + if (v == 0) { *cmp = 1; return 1; } @@ -343,7 +287,7 @@ PyObject_Cmp(PyObject *i1, PyObject *i2, int *cmp) } v = PyObject_RichCompareBool(i1, i2, Py_EQ); - if (v == 1) { + if (v == 0) { *cmp = 0; return 1; } @@ -406,6 +350,12 @@ NpyCapsule_Check(PyObject *ptr) return PyCapsule_CheckExact(ptr); } +static NPY_INLINE void +simple_capsule_dtor(PyObject *cap) +{ + PyArray_free(PyCapsule_GetPointer(cap, NULL)); +} + #else static NPY_INLINE PyObject * @@ -439,6 +389,25 @@ NpyCapsule_Check(PyObject *ptr) return PyCObject_Check(ptr); } +static NPY_INLINE void +simple_capsule_dtor(void *ptr) +{ + PyArray_free(ptr); +} + +#endif + +/* + * Hash value compatibility. + * As of Python 3.2 hash values are of type Py_hash_t. + * Previous versions use C long. + */ +#if PY_VERSION_HEX < 0x03020000 +typedef long npy_hash_t; +#define NPY_SIZEOF_HASH_T NPY_SIZEOF_LONG +#else +typedef Py_hash_t npy_hash_t; +#define NPY_SIZEOF_HASH_T NPY_SIZEOF_INTP #endif #ifdef __cplusplus diff --git a/include/numpy/npy_common.h b/include/numpy/npy_common.h index eff5dd339..7fca7e220 100644 --- a/include/numpy/npy_common.h +++ b/include/numpy/npy_common.h @@ -3,63 +3,6 @@ /* numpconfig.h is auto-generated */ #include "numpyconfig.h" -#ifdef HAVE_NPY_CONFIG_H -#include -#endif - -/* - * gcc does not unroll even with -O3 - * use with care, unrolling on modern cpus rarely speeds things up - */ -#ifdef HAVE_ATTRIBUTE_OPTIMIZE_UNROLL_LOOPS -#define NPY_GCC_UNROLL_LOOPS \ - __attribute__((optimize("unroll-loops"))) -#else -#define NPY_GCC_UNROLL_LOOPS -#endif - -/* highest gcc optimization level, enabled autovectorizer */ -#ifdef HAVE_ATTRIBUTE_OPTIMIZE_OPT_3 -#define NPY_GCC_OPT_3 __attribute__((optimize("O3"))) -#else -#define NPY_GCC_OPT_3 -#endif - -/* - * mark an argument (starting from 1) that must not be NULL and is not checked - * DO NOT USE IF FUNCTION CHECKS FOR NULL!! the compiler will remove the check - */ -#ifdef HAVE_ATTRIBUTE_NONNULL -#define NPY_GCC_NONNULL(n) __attribute__((nonnull(n))) -#else -#define NPY_GCC_NONNULL(n) -#endif - -#if defined HAVE_XMMINTRIN_H && defined HAVE__MM_LOAD_PS -#define NPY_HAVE_SSE_INTRINSICS -#endif - -#if defined HAVE_EMMINTRIN_H && defined HAVE__MM_LOAD_PD -#define NPY_HAVE_SSE2_INTRINSICS -#endif - -/* - * give a hint to the compiler which branch is more likely or unlikely - * to occur, e.g. rare error cases: - * - * if (NPY_UNLIKELY(failure == 0)) - * return NULL; - * - * the double !! is to cast the expression (e.g. NULL) to a boolean required by - * the intrinsic - */ -#ifdef HAVE___BUILTIN_EXPECT -#define NPY_LIKELY(x) __builtin_expect(!!(x), 1) -#define NPY_UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -#define NPY_LIKELY(x) (x) -#define NPY_UNLIKELY(x) (x) -#endif #if defined(_MSC_VER) #define NPY_INLINE __inline @@ -73,82 +16,14 @@ #define NPY_INLINE #endif -#ifdef HAVE___THREAD - #define NPY_TLS __thread -#else - #ifdef HAVE___DECLSPEC_THREAD_ - #define NPY_TLS __declspec(thread) - #else - #define NPY_TLS - #endif -#endif - -#ifdef WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE - #define NPY_RETURNS_BORROWED_REF \ - __attribute__((cpychecker_returns_borrowed_ref)) -#else - #define NPY_RETURNS_BORROWED_REF -#endif - -#ifdef WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE - #define NPY_STEALS_REF_TO_ARG(n) \ - __attribute__((cpychecker_steals_reference_to_arg(n))) -#else - #define NPY_STEALS_REF_TO_ARG(n) -#endif - -/* 64 bit file position support, also on win-amd64. Ticket #1660 */ -#if defined(_MSC_VER) && defined(_WIN64) && (_MSC_VER > 1400) || \ - defined(__MINGW32__) || defined(__MINGW64__) - #include - -/* mingw based on 3.4.5 has lseek but not ftell/fseek */ -#if defined(__MINGW32__) || defined(__MINGW64__) -extern int __cdecl _fseeki64(FILE *, long long, int); -extern long long __cdecl _ftelli64(FILE *); -#endif - +/* Enable 64 bit file position support on win-amd64. Ticket #1660 */ +#if defined(_MSC_VER) && defined(_WIN64) && (_MSC_VER > 1400) #define npy_fseek _fseeki64 #define npy_ftell _ftelli64 - #define npy_lseek _lseeki64 - #define npy_off_t npy_int64 - - #if NPY_SIZEOF_INT == 8 - #define NPY_OFF_T_PYFMT "i" - #elif NPY_SIZEOF_LONG == 8 - #define NPY_OFF_T_PYFMT "l" - #elif NPY_SIZEOF_LONGLONG == 8 - #define NPY_OFF_T_PYFMT "L" - #else - #error Unsupported size for type off_t - #endif -#else -#ifdef HAVE_FSEEKO - #define npy_fseek fseeko #else #define npy_fseek fseek -#endif -#ifdef HAVE_FTELLO - #define npy_ftell ftello -#else #define npy_ftell ftell #endif - #include - #define npy_lseek lseek - #define npy_off_t off_t - - #if NPY_SIZEOF_OFF_T == NPY_SIZEOF_SHORT - #define NPY_OFF_T_PYFMT "h" - #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_INT - #define NPY_OFF_T_PYFMT "i" - #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_LONG - #define NPY_OFF_T_PYFMT "l" - #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_LONGLONG - #define NPY_OFF_T_PYFMT "L" - #else - #error Unsupported size for type off_t - #endif -#endif /* enums for detected endianness */ enum { @@ -158,22 +33,15 @@ enum { }; /* - * This is to typedef npy_intp to the appropriate pointer size for this - * platform. Py_intptr_t, Py_uintptr_t are defined in pyport.h. + * This is to typedef npy_intp to the appropriate pointer size for + * this platform. Py_intptr_t, Py_uintptr_t are defined in pyport.h. */ typedef Py_intptr_t npy_intp; typedef Py_uintptr_t npy_uintp; - -/* - * Define sizes that were not defined in numpyconfig.h. - */ #define NPY_SIZEOF_CHAR 1 #define NPY_SIZEOF_BYTE 1 -#define NPY_SIZEOF_DATETIME 8 -#define NPY_SIZEOF_TIMEDELTA 8 #define NPY_SIZEOF_INTP NPY_SIZEOF_PY_INTPTR_T #define NPY_SIZEOF_UINTP NPY_SIZEOF_PY_INTPTR_T -#define NPY_SIZEOF_HALF 2 #define NPY_SIZEOF_CFLOAT NPY_SIZEOF_COMPLEX_FLOAT #define NPY_SIZEOF_CDOUBLE NPY_SIZEOF_COMPLEX_DOUBLE #define NPY_SIZEOF_CLONGDOUBLE NPY_SIZEOF_COMPLEX_LONGDOUBLE @@ -182,8 +50,18 @@ typedef Py_uintptr_t npy_uintp; #undef constchar #endif +#if (PY_VERSION_HEX < 0x02050000) + #ifndef PY_SSIZE_T_MIN + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #endif +#define NPY_SSIZE_T_PYFMT "i" +#define constchar const char +#else #define NPY_SSIZE_T_PYFMT "n" #define constchar char +#endif /* NPY_INTP_FMT Note: * Unlike the other NPY_*_FMT macros which are used with @@ -265,9 +143,18 @@ typedef unsigned PY_LONG_LONG npy_ulonglong; # ifdef _MSC_VER # define NPY_LONGLONG_FMT "I64d" # define NPY_ULONGLONG_FMT "I64u" -# else +# elif defined(__APPLE__) || defined(__FreeBSD__) +/* "%Ld" only parses 4 bytes -- "L" is floating modifier on MacOS X/BSD */ # define NPY_LONGLONG_FMT "lld" # define NPY_ULONGLONG_FMT "llu" +/* + another possible variant -- *quad_t works on *BSD, but is deprecated: + #define LONGLONG_FMT "qd" + #define ULONGLONG_FMT "qu" +*/ +# else +# define NPY_LONGLONG_FMT "Ld" +# define NPY_ULONGLONG_FMT "Lu" # endif # ifdef _MSC_VER # define NPY_LONGLONG_SUFFIX(x) (x##i64) @@ -316,19 +203,6 @@ typedef long npy_long; typedef float npy_float; typedef double npy_double; -/* - * Hash value compatibility. - * As of Python 3.2 hash values are of type Py_hash_t. - * Previous versions use C long. - */ -#if PY_VERSION_HEX < 0x03020000 -typedef long npy_hash_t; -#define NPY_SIZEOF_HASH_T NPY_SIZEOF_LONG -#else -typedef Py_hash_t npy_hash_t; -#define NPY_SIZEOF_HASH_T NPY_SIZEOF_INTP -#endif - /* * Disabling C99 complex usage: a lot of C code in numpy/scipy rely on being * able to do .real/.imag. Will have to convert code first. @@ -431,6 +305,10 @@ typedef struct { npy_longdouble real, imag; } npy_clongdouble; #define NPY_MIN_LONG LONG_MIN #define NPY_MAX_ULONG ULONG_MAX +#define NPY_SIZEOF_HALF 2 +#define NPY_SIZEOF_DATETIME 8 +#define NPY_SIZEOF_TIMEDELTA 8 + #define NPY_BITSOF_BOOL (sizeof(npy_bool) * CHAR_BIT) #define NPY_BITSOF_CHAR CHAR_BIT #define NPY_BITSOF_BYTE (NPY_SIZEOF_BYTE * CHAR_BIT) @@ -1049,3 +927,4 @@ typedef npy_int64 npy_datetime; /* End of typedefs for numarray style bit-width names */ #endif + diff --git a/include/numpy/npy_cpu.h b/include/numpy/npy_cpu.h index 60abae4e0..9707a7adf 100644 --- a/include/numpy/npy_cpu.h +++ b/include/numpy/npy_cpu.h @@ -5,7 +5,6 @@ * NPY_CPU_AMD64 * NPY_CPU_PPC * NPY_CPU_PPC64 - * NPY_CPU_PPC64LE * NPY_CPU_SPARC * NPY_CPU_S390 * NPY_CPU_IA64 @@ -20,7 +19,6 @@ #define _NPY_CPUARCH_H_ #include "numpyconfig.h" -#include /* for memcpy */ #if defined( __i386__ ) || defined(i386) || defined(_M_IX86) /* @@ -43,8 +41,6 @@ * _ARCH_PPC is used by at least gcc on AIX */ #define NPY_CPU_PPC -#elif defined(__ppc64le__) - #define NPY_CPU_PPC64LE #elif defined(__ppc64__) #define NPY_CPU_PPC64 #elif defined(__sparc__) || defined(__sparc) @@ -70,23 +66,44 @@ #define NPY_CPU_MIPSEL #elif defined(__MIPSEB__) #define NPY_CPU_MIPSEB -#elif defined(__or1k__) - #define NPY_CPU_OR1K #elif defined(__aarch64__) #define NPY_CPU_AARCH64 -#elif defined(__mc68000__) - #define NPY_CPU_M68K #else #error Unknown CPU, please report this to numpy maintainers with \ information about your platform (OS, CPU and compiler) #endif -#define NPY_COPY_PYOBJECT_PTR(dst, src) memcpy(dst, src, sizeof(PyObject *)) +/* + This "white-lists" the architectures that we know don't require + pointer alignment. We white-list, since the memcpy version will + work everywhere, whereas assignment will only work where pointer + dereferencing doesn't require alignment. -#if (defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64)) -#define NPY_CPU_HAVE_UNALIGNED_ACCESS 1 + TODO: There may be more architectures we can white list. +*/ +#if defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64) + #define NPY_COPY_PYOBJECT_PTR(dst, src) (*((PyObject **)(dst)) = *((PyObject **)(src))) #else -#define NPY_CPU_HAVE_UNALIGNED_ACCESS 0 + #if NPY_SIZEOF_PY_INTPTR_T == 4 + #define NPY_COPY_PYOBJECT_PTR(dst, src) \ + ((char*)(dst))[0] = ((char*)(src))[0]; \ + ((char*)(dst))[1] = ((char*)(src))[1]; \ + ((char*)(dst))[2] = ((char*)(src))[2]; \ + ((char*)(dst))[3] = ((char*)(src))[3]; + #elif NPY_SIZEOF_PY_INTPTR_T == 8 + #define NPY_COPY_PYOBJECT_PTR(dst, src) \ + ((char*)(dst))[0] = ((char*)(src))[0]; \ + ((char*)(dst))[1] = ((char*)(src))[1]; \ + ((char*)(dst))[2] = ((char*)(src))[2]; \ + ((char*)(dst))[3] = ((char*)(src))[3]; \ + ((char*)(dst))[4] = ((char*)(src))[4]; \ + ((char*)(dst))[5] = ((char*)(src))[5]; \ + ((char*)(dst))[6] = ((char*)(src))[6]; \ + ((char*)(dst))[7] = ((char*)(src))[7]; + #else + #error Unknown architecture, please report this to numpy maintainers with \ + information about your platform (OS, CPU and compiler) + #endif #endif #endif diff --git a/include/numpy/npy_1_7_deprecated_api.h b/include/numpy/npy_deprecated_api.h similarity index 91% rename from include/numpy/npy_1_7_deprecated_api.h rename to include/numpy/npy_deprecated_api.h index 4c318bc47..c27b4a4c9 100644 --- a/include/numpy/npy_1_7_deprecated_api.h +++ b/include/numpy/npy_deprecated_api.h @@ -1,30 +1,28 @@ -#ifndef _NPY_1_7_DEPRECATED_API_H -#define _NPY_1_7_DEPRECATED_API_H - -#ifndef NPY_DEPRECATED_INCLUDES -#error "Should never include npy_*_*_deprecated_api directly." -#endif +#ifndef _NPY_DEPRECATED_API_H +#define _NPY_DEPRECATED_API_H #if defined(_WIN32) #define _WARN___STR2__(x) #x #define _WARN___STR1__(x) _WARN___STR2__(x) #define _WARN___LOC__ __FILE__ "(" _WARN___STR1__(__LINE__) ") : Warning Msg: " #pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it by " \ - "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION") + "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION") #elif defined(__GNUC__) -#warning "Using deprecated NumPy API, disable it by " \ - "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" +#warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" #endif /* TODO: How to do this warning message for other compilers? */ /* - * This header exists to collect all dangerous/deprecated NumPy API - * as of NumPy 1.7. + * This header exists to collect all dangerous/deprecated NumPy API. * * This is an attempt to remove bad API, the proliferation of macros, * and namespace pollution currently produced by the NumPy headers. */ +#if defined(NPY_NO_DEPRECATED_API) +#error Should never include npy_deprecated_api directly. +#endif + /* These array flags are deprecated as of NumPy 1.7 */ #define NPY_CONTIGUOUS NPY_ARRAY_C_CONTIGUOUS #define NPY_FORTRAN NPY_ARRAY_F_CONTIGUOUS @@ -127,4 +125,5 @@ */ #include "old_defines.h" + #endif diff --git a/include/numpy/npy_endian.h b/include/numpy/npy_endian.h index a8ec57245..4e3349ffe 100644 --- a/include/numpy/npy_endian.h +++ b/include/numpy/npy_endian.h @@ -10,22 +10,10 @@ /* Use endian.h if available */ #include - #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN) - #define NPY_BYTE_ORDER BYTE_ORDER - #define NPY_LITTLE_ENDIAN LITTLE_ENDIAN - #define NPY_BIG_ENDIAN BIG_ENDIAN - #elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) - #define NPY_BYTE_ORDER _BYTE_ORDER - #define NPY_LITTLE_ENDIAN _LITTLE_ENDIAN - #define NPY_BIG_ENDIAN _BIG_ENDIAN - #elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) - #define NPY_BYTE_ORDER __BYTE_ORDER - #define NPY_LITTLE_ENDIAN __LITTLE_ENDIAN - #define NPY_BIG_ENDIAN __BIG_ENDIAN - #endif -#endif - -#ifndef NPY_BYTE_ORDER + #define NPY_BYTE_ORDER __BYTE_ORDER + #define NPY_LITTLE_ENDIAN __LITTLE_ENDIAN + #define NPY_BIG_ENDIAN __BIG_ENDIAN +#else /* Set endianness info using target CPU */ #include "npy_cpu.h" @@ -39,8 +27,7 @@ || defined(NPY_CPU_ARMEL) \ || defined(NPY_CPU_AARCH64) \ || defined(NPY_CPU_SH_LE) \ - || defined(NPY_CPU_MIPSEL) \ - || defined(NPY_CPU_PPC64LE) + || defined(NPY_CPU_MIPSEL) #define NPY_BYTE_ORDER NPY_LITTLE_ENDIAN #elif defined(NPY_CPU_PPC) \ || defined(NPY_CPU_SPARC) \ @@ -49,9 +36,7 @@ || defined(NPY_CPU_PPC64) \ || defined(NPY_CPU_ARMEB) \ || defined(NPY_CPU_SH_BE) \ - || defined(NPY_CPU_MIPSEB) \ - || defined(NPY_CPU_OR1K) \ - || defined(NPY_CPU_M68K) + || defined(NPY_CPU_MIPSEB) #define NPY_BYTE_ORDER NPY_BIG_ENDIAN #else #error Unknown CPU: can not set endianness diff --git a/include/numpy/npy_math.h b/include/numpy/npy_math.h index 38f182ddb..7ae166e54 100644 --- a/include/numpy/npy_math.h +++ b/include/numpy/npy_math.h @@ -1,20 +1,12 @@ #ifndef __NPY_MATH_C99_H_ #define __NPY_MATH_C99_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include #ifdef __SUNPRO_CC #include #endif -#ifdef HAVE_NPY_CONFIG_H -#include -#endif #include - /* * NAN and INFINITY like macros (same behavior as glibc for NAN, same as C99 * for INFINITY) @@ -118,12 +110,15 @@ double npy_tanh(double x); double npy_asin(double x); double npy_acos(double x); double npy_atan(double x); +double npy_aexp(double x); +double npy_alog(double x); +double npy_asqrt(double x); +double npy_afabs(double x); double npy_log(double x); double npy_log10(double x); double npy_exp(double x); double npy_sqrt(double x); -double npy_cbrt(double x); double npy_fabs(double x); double npy_ceil(double x); @@ -144,8 +139,6 @@ double npy_log2(double x); double npy_atan2(double x, double y); double npy_pow(double x, double y); double npy_modf(double x, double* y); -double npy_frexp(double x, int* y); -double npy_ldexp(double n, int y); double npy_copysign(double x, double y); double npy_nextafter(double x, double y); @@ -154,51 +147,33 @@ double npy_spacing(double x); /* * IEEE 754 fpu handling. Those are guaranteed to be macros */ - -/* use builtins to avoid function calls in tight loops - * only available if npy_config.h is available (= numpys own build) */ -#if HAVE___BUILTIN_ISNAN - #define npy_isnan(x) __builtin_isnan(x) +#ifndef NPY_HAVE_DECL_ISNAN + #define npy_isnan(x) ((x) != (x)) #else - #ifndef NPY_HAVE_DECL_ISNAN - #define npy_isnan(x) ((x) != (x)) + #ifdef _MSC_VER + #define npy_isnan(x) _isnan((x)) #else - #if defined(_MSC_VER) && (_MSC_VER < 1900) - #define npy_isnan(x) _isnan((x)) - #else - #define npy_isnan(x) isnan(x) - #endif + #define npy_isnan(x) isnan((x)) #endif #endif - -/* only available if npy_config.h is available (= numpys own build) */ -#if HAVE___BUILTIN_ISFINITE - #define npy_isfinite(x) __builtin_isfinite(x) -#else - #ifndef NPY_HAVE_DECL_ISFINITE - #ifdef _MSC_VER - #define npy_isfinite(x) _finite((x)) - #else - #define npy_isfinite(x) !npy_isnan((x) + (-x)) - #endif +#ifndef NPY_HAVE_DECL_ISFINITE + #ifdef _MSC_VER + #define npy_isfinite(x) _finite((x)) #else - #define npy_isfinite(x) isfinite((x)) + #define npy_isfinite(x) !npy_isnan((x) + (-x)) #endif +#else + #define npy_isfinite(x) isfinite((x)) #endif -/* only available if npy_config.h is available (= numpys own build) */ -#if HAVE___BUILTIN_ISINF - #define npy_isinf(x) __builtin_isinf(x) +#ifndef NPY_HAVE_DECL_ISINF + #define npy_isinf(x) (!npy_isfinite(x) && !npy_isnan(x)) #else - #ifndef NPY_HAVE_DECL_ISINF - #define npy_isinf(x) (!npy_isfinite(x) && !npy_isnan(x)) + #ifdef _MSC_VER + #define npy_isinf(x) (!_finite((x)) && !_isnan((x))) #else - #if defined(_MSC_VER) && (_MSC_VER < 1900) - #define npy_isinf(x) (!_finite((x)) && !_isnan((x))) - #else - #define npy_isinf(x) isinf((x)) - #endif + #define npy_isinf(x) isinf((x)) #endif #endif @@ -230,7 +205,6 @@ float npy_ceilf(float x); float npy_rintf(float x); float npy_truncf(float x); float npy_sqrtf(float x); -float npy_cbrtf(float x); float npy_log10f(float x); float npy_logf(float x); float npy_expf(float x); @@ -251,15 +225,13 @@ float npy_powf(float x, float y); float npy_fmodf(float x, float y); float npy_modff(float x, float* y); -float npy_frexpf(float x, int* y); -float npy_ldexpf(float x, int y); float npy_copysignf(float x, float y); float npy_nextafterf(float x, float y); float npy_spacingf(float x); /* - * long double C99 math functions + * float C99 math functions */ npy_longdouble npy_sinl(npy_longdouble x); @@ -274,7 +246,6 @@ npy_longdouble npy_ceill(npy_longdouble x); npy_longdouble npy_rintl(npy_longdouble x); npy_longdouble npy_truncl(npy_longdouble x); npy_longdouble npy_sqrtl(npy_longdouble x); -npy_longdouble npy_cbrtl(npy_longdouble x); npy_longdouble npy_log10l(npy_longdouble x); npy_longdouble npy_logl(npy_longdouble x); npy_longdouble npy_expl(npy_longdouble x); @@ -295,8 +266,6 @@ npy_longdouble npy_powl(npy_longdouble x, npy_longdouble y); npy_longdouble npy_fmodl(npy_longdouble x, npy_longdouble y); npy_longdouble npy_modfl(npy_longdouble x, npy_longdouble* y); -npy_longdouble npy_frexpl(npy_longdouble x, int* y); -npy_longdouble npy_ldexpl(npy_longdouble x, int y); npy_longdouble npy_copysignl(npy_longdouble x, npy_longdouble y); npy_longdouble npy_nextafterl(npy_longdouble x, npy_longdouble y); @@ -425,19 +394,6 @@ npy_cdouble npy_csqrt(npy_cdouble z); npy_cdouble npy_ccos(npy_cdouble z); npy_cdouble npy_csin(npy_cdouble z); -npy_cdouble npy_ctan(npy_cdouble z); - -npy_cdouble npy_ccosh(npy_cdouble z); -npy_cdouble npy_csinh(npy_cdouble z); -npy_cdouble npy_ctanh(npy_cdouble z); - -npy_cdouble npy_cacos(npy_cdouble z); -npy_cdouble npy_casin(npy_cdouble z); -npy_cdouble npy_catan(npy_cdouble z); - -npy_cdouble npy_cacosh(npy_cdouble z); -npy_cdouble npy_casinh(npy_cdouble z); -npy_cdouble npy_catanh(npy_cdouble z); /* * Single precision complex functions @@ -453,20 +409,6 @@ npy_cfloat npy_csqrtf(npy_cfloat z); npy_cfloat npy_ccosf(npy_cfloat z); npy_cfloat npy_csinf(npy_cfloat z); -npy_cfloat npy_ctanf(npy_cfloat z); - -npy_cfloat npy_ccoshf(npy_cfloat z); -npy_cfloat npy_csinhf(npy_cfloat z); -npy_cfloat npy_ctanhf(npy_cfloat z); - -npy_cfloat npy_cacosf(npy_cfloat z); -npy_cfloat npy_casinf(npy_cfloat z); -npy_cfloat npy_catanf(npy_cfloat z); - -npy_cfloat npy_cacoshf(npy_cfloat z); -npy_cfloat npy_casinhf(npy_cfloat z); -npy_cfloat npy_catanhf(npy_cfloat z); - /* * Extended precision complex functions @@ -482,44 +424,15 @@ npy_clongdouble npy_csqrtl(npy_clongdouble z); npy_clongdouble npy_ccosl(npy_clongdouble z); npy_clongdouble npy_csinl(npy_clongdouble z); -npy_clongdouble npy_ctanl(npy_clongdouble z); - -npy_clongdouble npy_ccoshl(npy_clongdouble z); -npy_clongdouble npy_csinhl(npy_clongdouble z); -npy_clongdouble npy_ctanhl(npy_clongdouble z); - -npy_clongdouble npy_cacosl(npy_clongdouble z); -npy_clongdouble npy_casinl(npy_clongdouble z); -npy_clongdouble npy_catanl(npy_clongdouble z); - -npy_clongdouble npy_cacoshl(npy_clongdouble z); -npy_clongdouble npy_casinhl(npy_clongdouble z); -npy_clongdouble npy_catanhl(npy_clongdouble z); - /* * Functions that set the floating point error * status word. */ -/* - * platform-dependent code translates floating point - * status to an integer sum of these values - */ -#define NPY_FPE_DIVIDEBYZERO 1 -#define NPY_FPE_OVERFLOW 2 -#define NPY_FPE_UNDERFLOW 4 -#define NPY_FPE_INVALID 8 - -int npy_get_floatstatus(void); -int npy_clear_floatstatus(void); void npy_set_floatstatus_divbyzero(void); void npy_set_floatstatus_overflow(void); void npy_set_floatstatus_underflow(void); void npy_set_floatstatus_invalid(void); -#ifdef __cplusplus -} -#endif - #endif diff --git a/include/numpy/numpyconfig.h b/include/numpy/numpyconfig.h index 20e15d624..401d19fd7 100644 --- a/include/numpy/numpyconfig.h +++ b/include/numpy/numpyconfig.h @@ -9,16 +9,16 @@ * harcoded */ #ifdef __APPLE__ - #undef NPY_SIZEOF_LONG - #undef NPY_SIZEOF_PY_INTPTR_T + #undef NPY_SIZEOF_LONG + #undef NPY_SIZEOF_PY_INTPTR_T - #ifdef __LP64__ - #define NPY_SIZEOF_LONG 8 - #define NPY_SIZEOF_PY_INTPTR_T 8 - #else - #define NPY_SIZEOF_LONG 4 - #define NPY_SIZEOF_PY_INTPTR_T 4 - #endif + #ifdef __LP64__ + #define NPY_SIZEOF_LONG 8 + #define NPY_SIZEOF_PY_INTPTR_T 8 + #else + #define NPY_SIZEOF_LONG 4 + #define NPY_SIZEOF_PY_INTPTR_T 4 + #endif #endif /** @@ -29,8 +29,5 @@ * #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION */ #define NPY_1_7_API_VERSION 0x00000007 -#define NPY_1_8_API_VERSION 0x00000008 -#define NPY_1_9_API_VERSION 0x00000008 -#define NPY_1_10_API_VERSION 0x00000008 #endif diff --git a/include/numpy/ufunc_api.txt b/include/numpy/ufunc_api.txt index 606037f35..3365433cd 100644 --- a/include/numpy/ufunc_api.txt +++ b/include/numpy/ufunc_api.txt @@ -7,8 +7,8 @@ Numpy Ufunc C-API PyObject * PyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, char *types, int ntypes, int nin, int - nout, int identity, const char *name, const - char *doc, int check_return) + nout, int identity, char *name, char *doc, int + check_return) :: @@ -229,9 +229,9 @@ owns a new reference to errobj. PyUFunc_FromFuncAndDataAndSignature(PyUFuncGenericFunction *func, void **data, char *types, int ntypes, int nin, int nout, int - identity, const char *name, const - char *doc, int check_return, const - char *signature) + identity, char *name, char + *doc, int check_return, const char + *signature) :: @@ -310,12 +310,3 @@ the output operands where provided. Returns 0 on success, -1 (with exception raised) on validation failure. -:: - - int - PyUFunc_RegisterLoopForDescr(PyUFuncObject *ufunc, PyArray_Descr - *user_dtype, PyUFuncGenericFunction - function, PyArray_Descr - **arg_dtypes, void *data) - - diff --git a/include/numpy/ufuncobject.h b/include/numpy/ufuncobject.h index a24a0d837..076dd880c 100644 --- a/include/numpy/ufuncobject.h +++ b/include/numpy/ufuncobject.h @@ -2,7 +2,6 @@ #define Py_UFUNCOBJECT_H #include -#include #ifdef __cplusplus extern "C" { @@ -152,13 +151,13 @@ typedef struct _tagPyUFuncObject { int check_return; /* The name of the ufunc */ - const char *name; + char *name; /* Array of type numbers, of size ('nargs' * 'ntypes') */ char *types; /* Documentation string */ - const char *doc; + char *doc; void *ptr; PyObject *obj; @@ -213,20 +212,6 @@ typedef struct _tagPyUFuncObject { * A function which returns a masked inner loop for the ufunc. */ PyUFunc_MaskedInnerLoopSelectionFunc *masked_inner_loop_selector; - - /* - * List of flags for each operand when ufunc is called by nditer object. - * These flags will be used in addition to the default flags for each - * operand set by nditer object. - */ - npy_uint32 *op_flags; - - /* - * List of global flags used when ufunc is called by nditer object. - * These flags will be used in addition to the default global flags - * set by nditer object. - */ - npy_uint32 iter_flags; } PyUFuncObject; #include "arrayobject.h" @@ -251,11 +236,22 @@ typedef struct _tagPyUFuncObject { #define UFUNC_SHIFT_INVALID 9 +/* platform-dependent code translates floating point + status to an integer sum of these values +*/ +#define UFUNC_FPE_DIVIDEBYZERO 1 +#define UFUNC_FPE_OVERFLOW 2 +#define UFUNC_FPE_UNDERFLOW 4 +#define UFUNC_FPE_INVALID 8 + +/* Error mode that avoids look-up (no checking) */ +#define UFUNC_ERR_DEFAULT 0 + #define UFUNC_OBJ_ISOBJECT 1 #define UFUNC_OBJ_NEEDS_API 2 /* Default user error mode */ -#define UFUNC_ERR_DEFAULT \ +#define UFUNC_ERR_DEFAULT2 \ (UFUNC_ERR_WARN << UFUNC_SHIFT_DIVIDEBYZERO) + \ (UFUNC_ERR_WARN << UFUNC_SHIFT_OVERFLOW) + \ (UFUNC_ERR_WARN << UFUNC_SHIFT_INVALID) @@ -309,8 +305,6 @@ typedef struct _loop1d_info { void *data; int *arg_types; struct _loop1d_info *next; - int nargs; - PyArray_Descr **arg_dtypes; } PyUFunc_Loop1d; @@ -326,47 +320,126 @@ typedef struct _loop1d_info { &(arg)->first))) \ goto fail;} while (0) +/* This code checks the IEEE status flags in a platform-dependent way */ +/* Adapted from Numarray */ -/* keep in sync with ieee754.c.src */ -#if defined(sun) || defined(__BSD__) || defined(__OpenBSD__) || \ - (defined(__FreeBSD__) && (__FreeBSD_version < 502114)) || \ - defined(__NetBSD__) || \ - defined(__GLIBC__) || defined(__APPLE__) || \ - defined(__CYGWIN__) || defined(__MINGW32__) || \ - (defined(__FreeBSD__) && (__FreeBSD_version >= 502114)) || \ - defined(_AIX) || \ - defined(_MSC_VER) || \ - defined(__osf__) && defined(__alpha) -#else -#define NO_FLOATING_POINT_SUPPORT +#if (defined(__unix__) || defined(unix)) && !defined(USG) +#include #endif +/* OSF/Alpha (Tru64) ---------------------------------------------*/ +#if defined(__osf__) && defined(__alpha) + +#include + +#define UFUNC_CHECK_STATUS(ret) { \ + unsigned long fpstatus; \ + \ + fpstatus = ieee_get_fp_control(); \ + /* clear status bits as well as disable exception mode if on */ \ + ieee_set_fp_control( 0 ); \ + ret = ((IEEE_STATUS_DZE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((IEEE_STATUS_OVF & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((IEEE_STATUS_UNF & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((IEEE_STATUS_INV & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + } + +/* MS Windows -----------------------------------------------------*/ +#elif defined(_MSC_VER) + +#include + + /* Clear the floating point exception default of Borland C++ */ +#if defined(__BORLANDC__) +#define UFUNC_NOFPE _control87(MCW_EM, MCW_EM); +#endif + +#define UFUNC_CHECK_STATUS(ret) { \ + int fpstatus = (int) _clearfp(); \ + \ + ret = ((SW_ZERODIVIDE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((SW_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((SW_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((SW_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + } + +/* Solaris --------------------------------------------------------*/ +/* --------ignoring SunOS ieee_flags approach, someone else can +** deal with that! */ +#elif defined(sun) || defined(__BSD__) || defined(__OpenBSD__) || \ + (defined(__FreeBSD__) && (__FreeBSD_version < 502114)) || \ + defined(__NetBSD__) +#include + +#define UFUNC_CHECK_STATUS(ret) { \ + int fpstatus; \ + \ + fpstatus = (int) fpgetsticky(); \ + ret = ((FP_X_DZ & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((FP_X_OFL & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((FP_X_UFL & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((FP_X_INV & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + (void) fpsetsticky(0); \ + } + +#elif defined(__GLIBC__) || defined(__APPLE__) || \ + defined(__CYGWIN__) || defined(__MINGW32__) || \ + (defined(__FreeBSD__) && (__FreeBSD_version >= 502114)) + +#if defined(__GLIBC__) || defined(__APPLE__) || \ + defined(__MINGW32__) || defined(__FreeBSD__) +#include +#elif defined(__CYGWIN__) +#include "fenv/fenv.c" +#endif + +#define UFUNC_CHECK_STATUS(ret) { \ + int fpstatus = (int) fetestexcept(FE_DIVBYZERO | FE_OVERFLOW | \ + FE_UNDERFLOW | FE_INVALID); \ + ret = ((FE_DIVBYZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((FE_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((FE_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((FE_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + (void) feclearexcept(FE_DIVBYZERO | FE_OVERFLOW | \ + FE_UNDERFLOW | FE_INVALID); \ +} + +#elif defined(_AIX) + +#include +#include + +#define UFUNC_CHECK_STATUS(ret) { \ + fpflag_t fpstatus; \ + \ + fpstatus = fp_read_flag(); \ + ret = ((FP_DIV_BY_ZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((FP_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((FP_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((FP_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + fp_swap_flag(0); \ +} + +#else + +#define NO_FLOATING_POINT_SUPPORT +#define UFUNC_CHECK_STATUS(ret) { \ + ret = 0; \ + } + +#endif /* * THESE MACROS ARE DEPRECATED. * Use npy_set_floatstatus_* in the npymath library. */ -#define UFUNC_FPE_DIVIDEBYZERO NPY_FPE_DIVIDEBYZERO -#define UFUNC_FPE_OVERFLOW NPY_FPE_OVERFLOW -#define UFUNC_FPE_UNDERFLOW NPY_FPE_UNDERFLOW -#define UFUNC_FPE_INVALID NPY_FPE_INVALID - -#define UFUNC_CHECK_STATUS(ret) \ - { \ - ret = npy_clear_floatstatus(); \ - } #define generate_divbyzero_error() npy_set_floatstatus_divbyzero() #define generate_overflow_error() npy_set_floatstatus_overflow() /* Make sure it gets defined if it isn't already */ #ifndef UFUNC_NOFPE -/* Clear the floating point exception default of Borland C++ */ -#if defined(__BORLANDC__) -#define UFUNC_NOFPE _control87(MCW_EM, MCW_EM); -#else #define UFUNC_NOFPE #endif -#endif #ifdef __cplusplus diff --git a/requirements.txt b/requirements.txt index 33773a43b..6ef0fbb77 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -cython < 0.24 +cython<0.24 pathlib -numpy +numpy>=1.7 cymem>=1.30,<1.32 preshed>=0.46.1,<0.47.0 thinc>=5.0.0,<5.1.0 diff --git a/setup.py b/setup.py index 7be26c413..14b5a0b8e 100644 --- a/setup.py +++ b/setup.py @@ -68,9 +68,6 @@ MOD_NAMES = [ 'spacy.syntax.iterators'] -# By subclassing build_extensions we have the actual compiler that will be used -# which is really known only after finalize_options -# http://stackoverflow.com/questions/724664/python-distutils-how-to-get-a-compiler-that-is-going-to-be-used compile_options = { 'msvc': ['/Ox', '/EHsc'], 'mingw32' : ['-O3', '-Wno-strict-prototypes', '-Wno-unused-function'], @@ -94,6 +91,8 @@ if not sys.platform.startswith('darwin'): link_options['other'].append('-fopenmp') +# By subclassing build_extensions we have the actual compiler that will be used which is really known only after finalize_options +# http://stackoverflow.com/questions/724664/python-distutils-how-to-get-a-compiler-that-is-going-to-be-used class build_ext_options: def build_options(self): for e in self.extensions: @@ -186,9 +185,9 @@ def setup_package(): license=about['__license__'], ext_modules=ext_modules, install_requires=[ - 'numpy', + 'numpy>=1.7', 'murmurhash>=0.26,<0.27', - 'cymem>=1.30,<1.32.0', + 'cymem>=1.30,<1.32', 'preshed>=0.46.1,<0.47', 'thinc>=5.0.0,<5.1.0', 'plac',