From 3e58b8db5d2ff4b850f63373e1b1d1c812454264 Mon Sep 17 00:00:00 2001 From: Mark Wiebe Date: Tue, 25 Jan 2011 23:23:30 -0800 Subject: [PATCH] ENH: core: Make NumPy trunk ABI-compatible with 1.5 --- numpy/add_newdocs.py | 13 +- numpy/core/code_generators/numpy_api.py | 546 +++++++++--------- numpy/core/include/numpy/ndarraytypes.h | 3 +- numpy/core/setup_common.py | 2 +- numpy/core/src/multiarray/arraytypes.c.src | 2 - .../multiarray/lowlevel_strided_loops.c.src | 6 + numpy/core/src/multiarray/multiarraymodule.c | 12 +- 7 files changed, 305 insertions(+), 279 deletions(-) diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 854338a9c538..9bd714a8ad46 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1514,11 +1514,22 @@ If provided, the calculation is done into this array. dtype : None or data type If provided, forces the calculation to use the data type specified. + Note that you may have to also give a more liberal ``casting`` + parameter to allow the conversions. order : 'C', 'F', 'A', or 'K' - Controls the memory layout of the output. + Controls the memory layout of the output. 'C' means it should + be Fortran contiguous. 'F' means it should be Fortran contiguous, + 'A' means it should be 'F' if the inputs are all 'F', 'C' otherwise. + 'K' means it should be as close to the layout as the inputs as + is possible, including arbitrarily permuted axes. casting : 'no', 'equiv', 'safe', 'same_kind', 'unsafe' Controls what kind of data casting may occur. Setting this to 'unsafe' is not recommended, as it can adversely affect accumulations. + 'no' means the data types should not be cast at all. 'equiv' means + only byte-order changes are allowed. 'safe' means only casts + which can preserve values are allowed. 'same_kind' means only + safe casts or casts within a kind, like float64 to float32, are + allowed. 'unsafe' means any data conversions may be done. Returns ------- diff --git a/numpy/core/code_generators/numpy_api.py b/numpy/core/code_generators/numpy_api.py index 767a428ff651..65bdf90c6963 100644 --- a/numpy/core/code_generators/numpy_api.py +++ b/numpy/core/code_generators/numpy_api.py @@ -13,7 +13,7 @@ """ multiarray_global_vars = { - 'NPY_NUMUSERTYPES': 6, + 'NPY_NUMUSERTYPES': 7, } multiarray_global_vars_types = { @@ -21,51 +21,53 @@ } multiarray_scalar_bool_values = { - '_PyArrayScalar_BoolValues': 8 + '_PyArrayScalar_BoolValues': 9 } multiarray_types_api = { - 'PyArray_Type': 1, - 'PyArrayDescr_Type': 2, - 'PyArrayFlags_Type': 3, - 'PyArrayIter_Type': 4, - 'PyArrayMultiIter_Type': 5, - 'PyBoolArrType_Type': 7, - 'PyGenericArrType_Type': 9, - 'PyNumberArrType_Type': 10, - 'PyIntegerArrType_Type': 11, - 'PySignedIntegerArrType_Type': 12, - 'PyUnsignedIntegerArrType_Type': 13, - 'PyInexactArrType_Type': 14, - 'PyFloatingArrType_Type': 15, - 'PyComplexFloatingArrType_Type': 16, - 'PyFlexibleArrType_Type': 17, - 'PyCharacterArrType_Type': 18, - 'PyByteArrType_Type': 19, - 'PyShortArrType_Type': 20, - 'PyIntArrType_Type': 21, - 'PyLongArrType_Type': 22, - 'PyLongLongArrType_Type': 23, - 'PyUByteArrType_Type': 24, - 'PyUShortArrType_Type': 25, - 'PyUIntArrType_Type': 26, - 'PyULongArrType_Type': 27, - 'PyULongLongArrType_Type': 28, - 'PyFloatArrType_Type': 29, - 'PyDoubleArrType_Type': 30, - 'PyLongDoubleArrType_Type': 31, - 'PyCFloatArrType_Type': 32, - 'PyCDoubleArrType_Type': 33, - 'PyCLongDoubleArrType_Type': 34, - 'PyObjectArrType_Type': 35, - 'PyStringArrType_Type': 36, - 'PyUnicodeArrType_Type': 37, - 'PyVoidArrType_Type': 38, - 'PyTimeIntegerArrType_Type': 39, - 'PyDatetimeArrType_Type': 40, - 'PyTimedeltaArrType_Type': 41, - 'PyHalfArrType_Type': 221, - 'NpyIter_Type': 222, + 'PyBigArray_Type': 1, + 'PyArray_Type': 2, + 'PyArrayDescr_Type': 3, + 'PyArrayFlags_Type': 4, + 'PyArrayIter_Type': 5, + 'PyArrayMultiIter_Type': 6, + 'PyBoolArrType_Type': 8, + 'PyGenericArrType_Type': 10, + 'PyNumberArrType_Type': 11, + 'PyIntegerArrType_Type': 12, + 'PySignedIntegerArrType_Type': 13, + 'PyUnsignedIntegerArrType_Type': 14, + 'PyInexactArrType_Type': 15, + 'PyFloatingArrType_Type': 16, + 'PyComplexFloatingArrType_Type': 17, + 'PyFlexibleArrType_Type': 18, + 'PyCharacterArrType_Type': 19, + 'PyByteArrType_Type': 20, + 'PyShortArrType_Type': 21, + 'PyIntArrType_Type': 22, + 'PyLongArrType_Type': 23, + 'PyLongLongArrType_Type': 24, + 'PyUByteArrType_Type': 25, + 'PyUShortArrType_Type': 26, + 'PyUIntArrType_Type': 27, + 'PyULongArrType_Type': 28, + 'PyULongLongArrType_Type': 29, + 'PyFloatArrType_Type': 30, + 'PyDoubleArrType_Type': 31, + 'PyLongDoubleArrType_Type': 32, + 'PyCFloatArrType_Type': 33, + 'PyCDoubleArrType_Type': 34, + 'PyCLongDoubleArrType_Type': 35, + 'PyObjectArrType_Type': 36, + 'PyStringArrType_Type': 37, + 'PyUnicodeArrType_Type': 38, + 'PyVoidArrType_Type': 39, + # End 1.5 API + 'PyTimeIntegerArrType_Type': 214, + 'PyDatetimeArrType_Type': 215, + 'PyTimedeltaArrType_Type': 216, + 'PyHalfArrType_Type': 217, + 'NpyIter_Type': 218, } #define NPY_NUMUSERTYPES (*(int *)PyArray_API[6]) @@ -74,236 +76,237 @@ multiarray_funcs_api = { 'PyArray_GetNDArrayCVersion': 0, - 'PyArray_SetNumericOps': 42, - 'PyArray_GetNumericOps': 43, - 'PyArray_INCREF': 44, - 'PyArray_XDECREF': 45, - 'PyArray_SetStringFunction': 46, - 'PyArray_DescrFromType': 47, - 'PyArray_TypeObjectFromType': 48, - 'PyArray_Zero': 49, - 'PyArray_One': 50, - 'PyArray_CastToType': 51, - 'PyArray_CastTo': 52, - 'PyArray_CastAnyTo': 53, - 'PyArray_CanCastSafely': 54, - 'PyArray_CanCastTo': 55, - 'PyArray_ObjectType': 56, - 'PyArray_DescrFromObject': 57, - 'PyArray_ConvertToCommonType': 58, - 'PyArray_DescrFromScalar': 59, - 'PyArray_DescrFromTypeObject': 60, - 'PyArray_Size': 61, - 'PyArray_Scalar': 62, - 'PyArray_FromScalar': 63, - 'PyArray_ScalarAsCtype': 64, - 'PyArray_CastScalarToCtype': 65, - 'PyArray_CastScalarDirect': 66, - 'PyArray_ScalarFromObject': 67, - 'PyArray_GetCastFunc': 68, - 'PyArray_FromDims': 69, - 'PyArray_FromDimsAndDataAndDescr': 70, - 'PyArray_FromAny': 71, - 'PyArray_EnsureArray': 72, - 'PyArray_EnsureAnyArray': 73, - 'PyArray_FromFile': 74, - 'PyArray_FromString': 75, - 'PyArray_FromBuffer': 76, - 'PyArray_FromIter': 77, - 'PyArray_Return': 78, - 'PyArray_GetField': 79, - 'PyArray_SetField': 80, - 'PyArray_Byteswap': 81, - 'PyArray_Resize': 82, - 'PyArray_MoveInto': 83, - 'PyArray_CopyInto': 84, - 'PyArray_CopyAnyInto': 85, - 'PyArray_CopyObject': 86, - 'PyArray_NewCopy': 87, - 'PyArray_ToList': 88, - 'PyArray_ToString': 89, - 'PyArray_ToFile': 90, - 'PyArray_Dump': 91, - 'PyArray_Dumps': 92, - 'PyArray_ValidType': 93, - 'PyArray_UpdateFlags': 94, - 'PyArray_New': 95, - 'PyArray_NewFromDescr': 96, - 'PyArray_DescrNew': 97, - 'PyArray_DescrNewFromType': 98, - 'PyArray_GetPriority': 99, - 'PyArray_IterNew': 100, - 'PyArray_MultiIterNew': 101, - 'PyArray_PyIntAsInt': 102, - 'PyArray_PyIntAsIntp': 103, - 'PyArray_Broadcast': 104, - 'PyArray_FillObjectArray': 105, - 'PyArray_FillWithScalar': 106, - 'PyArray_CheckStrides': 107, - 'PyArray_DescrNewByteorder': 108, - 'PyArray_IterAllButAxis': 109, - 'PyArray_CheckFromAny': 110, - 'PyArray_FromArray': 111, - 'PyArray_FromInterface': 112, - 'PyArray_FromStructInterface': 113, - 'PyArray_FromArrayAttr': 114, - 'PyArray_ScalarKind': 115, - 'PyArray_CanCoerceScalar': 116, - 'PyArray_NewFlagsObject': 117, - 'PyArray_CanCastScalar': 118, - 'PyArray_CompareUCS4': 119, - 'PyArray_RemoveSmallest': 120, - 'PyArray_ElementStrides': 121, - 'PyArray_Item_INCREF': 122, - 'PyArray_Item_XDECREF': 123, - 'PyArray_FieldNames': 124, - 'PyArray_Transpose': 125, - 'PyArray_TakeFrom': 126, - 'PyArray_PutTo': 127, - 'PyArray_PutMask': 128, - 'PyArray_Repeat': 129, - 'PyArray_Choose': 130, - 'PyArray_Sort': 131, - 'PyArray_ArgSort': 132, - 'PyArray_SearchSorted': 133, - 'PyArray_ArgMax': 134, - 'PyArray_ArgMin': 135, - 'PyArray_Reshape': 136, - 'PyArray_Newshape': 137, - 'PyArray_Squeeze': 138, - 'PyArray_View': 139, - 'PyArray_SwapAxes': 140, - 'PyArray_Max': 141, - 'PyArray_Min': 142, - 'PyArray_Ptp': 143, - 'PyArray_Mean': 144, - 'PyArray_Trace': 145, - 'PyArray_Diagonal': 146, - 'PyArray_Clip': 147, - 'PyArray_Conjugate': 148, - 'PyArray_Nonzero': 149, - 'PyArray_Std': 150, - 'PyArray_Sum': 151, - 'PyArray_CumSum': 152, - 'PyArray_Prod': 153, - 'PyArray_CumProd': 154, - 'PyArray_All': 155, - 'PyArray_Any': 156, - 'PyArray_Compress': 157, - 'PyArray_Flatten': 158, - 'PyArray_Ravel': 159, - 'PyArray_MultiplyList': 160, - 'PyArray_MultiplyIntList': 161, - 'PyArray_GetPtr': 162, - 'PyArray_CompareLists': 163, - 'PyArray_AsCArray': 164, - 'PyArray_As1D': 165, - 'PyArray_As2D': 166, - 'PyArray_Free': 167, - 'PyArray_Converter': 168, - 'PyArray_IntpFromSequence': 169, - 'PyArray_Concatenate': 170, - 'PyArray_InnerProduct': 171, - 'PyArray_MatrixProduct': 172, - 'PyArray_CopyAndTranspose': 173, - 'PyArray_Correlate': 174, - 'PyArray_TypestrConvert': 175, - 'PyArray_DescrConverter': 176, - 'PyArray_DescrConverter2': 177, - 'PyArray_IntpConverter': 178, - 'PyArray_BufferConverter': 179, - 'PyArray_AxisConverter': 180, - 'PyArray_BoolConverter': 181, - 'PyArray_ByteorderConverter': 182, - 'PyArray_OrderConverter': 183, - 'PyArray_EquivTypes': 184, - 'PyArray_Zeros': 185, - 'PyArray_Empty': 186, - 'PyArray_Where': 187, - 'PyArray_Arange': 188, - 'PyArray_ArangeObj': 189, - 'PyArray_SortkindConverter': 190, - 'PyArray_LexSort': 191, - 'PyArray_Round': 192, - 'PyArray_EquivTypenums': 193, - 'PyArray_RegisterDataType': 194, - 'PyArray_RegisterCastFunc': 195, - 'PyArray_RegisterCanCast': 196, - 'PyArray_InitArrFuncs': 197, - 'PyArray_IntTupleFromIntp': 198, - 'PyArray_TypeNumFromName': 199, - 'PyArray_ClipmodeConverter': 200, - 'PyArray_OutputConverter': 201, - 'PyArray_BroadcastToShape': 202, - '_PyArray_SigintHandler': 203, - '_PyArray_GetSigintBuf': 204, - 'PyArray_DescrAlignConverter': 205, - 'PyArray_DescrAlignConverter2': 206, - 'PyArray_SearchsideConverter': 207, - 'PyArray_CheckAxis': 208, - 'PyArray_OverflowMultiplyList': 209, - 'PyArray_CompareString': 210, - 'PyArray_MultiIterFromObjects': 211, - 'PyArray_GetEndianness': 212, - 'PyArray_GetNDArrayCFeatureVersion': 213, - 'PyArray_Correlate2': 214, - 'PyArray_NeighborhoodIterNew': 215, - 'PyArray_SetDatetimeParseFunction': 216, - 'PyArray_DatetimeToDatetimeStruct': 217, - 'PyArray_TimedeltaToTimedeltaStruct': 218, - 'PyArray_DatetimeStructToDatetime': 219, - 'PyArray_TimedeltaStructToTimedelta': 220, + 'PyArray_SetNumericOps': 40, + 'PyArray_GetNumericOps': 41, + 'PyArray_INCREF': 42, + 'PyArray_XDECREF': 43, + 'PyArray_SetStringFunction': 44, + 'PyArray_DescrFromType': 45, + 'PyArray_TypeObjectFromType': 46, + 'PyArray_Zero': 47, + 'PyArray_One': 48, + 'PyArray_CastToType': 49, + 'PyArray_CastTo': 50, + 'PyArray_CastAnyTo': 51, + 'PyArray_CanCastSafely': 52, + 'PyArray_CanCastTo': 53, + 'PyArray_ObjectType': 54, + 'PyArray_DescrFromObject': 55, + 'PyArray_ConvertToCommonType': 56, + 'PyArray_DescrFromScalar': 57, + 'PyArray_DescrFromTypeObject': 58, + 'PyArray_Size': 59, + 'PyArray_Scalar': 60, + 'PyArray_FromScalar': 61, + 'PyArray_ScalarAsCtype': 62, + 'PyArray_CastScalarToCtype': 63, + 'PyArray_CastScalarDirect': 64, + 'PyArray_ScalarFromObject': 65, + 'PyArray_GetCastFunc': 66, + 'PyArray_FromDims': 67, + 'PyArray_FromDimsAndDataAndDescr': 68, + 'PyArray_FromAny': 69, + 'PyArray_EnsureArray': 70, + 'PyArray_EnsureAnyArray': 71, + 'PyArray_FromFile': 72, + 'PyArray_FromString': 73, + 'PyArray_FromBuffer': 74, + 'PyArray_FromIter': 75, + 'PyArray_Return': 76, + 'PyArray_GetField': 77, + 'PyArray_SetField': 78, + 'PyArray_Byteswap': 79, + 'PyArray_Resize': 80, + 'PyArray_MoveInto': 81, + 'PyArray_CopyInto': 82, + 'PyArray_CopyAnyInto': 83, + 'PyArray_CopyObject': 84, + 'PyArray_NewCopy': 85, + 'PyArray_ToList': 86, + 'PyArray_ToString': 87, + 'PyArray_ToFile': 88, + 'PyArray_Dump': 89, + 'PyArray_Dumps': 90, + 'PyArray_ValidType': 91, + 'PyArray_UpdateFlags': 92, + 'PyArray_New': 93, + 'PyArray_NewFromDescr': 94, + 'PyArray_DescrNew': 95, + 'PyArray_DescrNewFromType': 96, + 'PyArray_GetPriority': 97, + 'PyArray_IterNew': 98, + 'PyArray_MultiIterNew': 99, + 'PyArray_PyIntAsInt': 100, + 'PyArray_PyIntAsIntp': 101, + 'PyArray_Broadcast': 102, + 'PyArray_FillObjectArray': 103, + 'PyArray_FillWithScalar': 104, + 'PyArray_CheckStrides': 105, + 'PyArray_DescrNewByteorder': 106, + 'PyArray_IterAllButAxis': 107, + 'PyArray_CheckFromAny': 108, + 'PyArray_FromArray': 109, + 'PyArray_FromInterface': 110, + 'PyArray_FromStructInterface': 111, + 'PyArray_FromArrayAttr': 112, + 'PyArray_ScalarKind': 113, + 'PyArray_CanCoerceScalar': 114, + 'PyArray_NewFlagsObject': 115, + 'PyArray_CanCastScalar': 116, + 'PyArray_CompareUCS4': 117, + 'PyArray_RemoveSmallest': 118, + 'PyArray_ElementStrides': 119, + 'PyArray_Item_INCREF': 120, + 'PyArray_Item_XDECREF': 121, + 'PyArray_FieldNames': 122, + 'PyArray_Transpose': 123, + 'PyArray_TakeFrom': 124, + 'PyArray_PutTo': 125, + 'PyArray_PutMask': 126, + 'PyArray_Repeat': 127, + 'PyArray_Choose': 128, + 'PyArray_Sort': 129, + 'PyArray_ArgSort': 130, + 'PyArray_SearchSorted': 131, + 'PyArray_ArgMax': 132, + 'PyArray_ArgMin': 133, + 'PyArray_Reshape': 134, + 'PyArray_Newshape': 135, + 'PyArray_Squeeze': 136, + 'PyArray_View': 137, + 'PyArray_SwapAxes': 138, + 'PyArray_Max': 139, + 'PyArray_Min': 140, + 'PyArray_Ptp': 141, + 'PyArray_Mean': 142, + 'PyArray_Trace': 143, + 'PyArray_Diagonal': 144, + 'PyArray_Clip': 145, + 'PyArray_Conjugate': 146, + 'PyArray_Nonzero': 147, + 'PyArray_Std': 148, + 'PyArray_Sum': 149, + 'PyArray_CumSum': 150, + 'PyArray_Prod': 151, + 'PyArray_CumProd': 152, + 'PyArray_All': 153, + 'PyArray_Any': 154, + 'PyArray_Compress': 155, + 'PyArray_Flatten': 156, + 'PyArray_Ravel': 157, + 'PyArray_MultiplyList': 158, + 'PyArray_MultiplyIntList': 159, + 'PyArray_GetPtr': 160, + 'PyArray_CompareLists': 161, + 'PyArray_AsCArray': 162, + 'PyArray_As1D': 163, + 'PyArray_As2D': 164, + 'PyArray_Free': 165, + 'PyArray_Converter': 166, + 'PyArray_IntpFromSequence': 167, + 'PyArray_Concatenate': 168, + 'PyArray_InnerProduct': 169, + 'PyArray_MatrixProduct': 170, + 'PyArray_CopyAndTranspose': 171, + 'PyArray_Correlate': 172, + 'PyArray_TypestrConvert': 173, + 'PyArray_DescrConverter': 174, + 'PyArray_DescrConverter2': 175, + 'PyArray_IntpConverter': 176, + 'PyArray_BufferConverter': 177, + 'PyArray_AxisConverter': 178, + 'PyArray_BoolConverter': 179, + 'PyArray_ByteorderConverter': 180, + 'PyArray_OrderConverter': 181, + 'PyArray_EquivTypes': 182, + 'PyArray_Zeros': 183, + 'PyArray_Empty': 184, + 'PyArray_Where': 185, + 'PyArray_Arange': 186, + 'PyArray_ArangeObj': 187, + 'PyArray_SortkindConverter': 188, + 'PyArray_LexSort': 189, + 'PyArray_Round': 190, + 'PyArray_EquivTypenums': 191, + 'PyArray_RegisterDataType': 192, + 'PyArray_RegisterCastFunc': 193, + 'PyArray_RegisterCanCast': 194, + 'PyArray_InitArrFuncs': 195, + 'PyArray_IntTupleFromIntp': 196, + 'PyArray_TypeNumFromName': 197, + 'PyArray_ClipmodeConverter': 198, + 'PyArray_OutputConverter': 199, + 'PyArray_BroadcastToShape': 200, + '_PyArray_SigintHandler': 201, + '_PyArray_GetSigintBuf': 202, + 'PyArray_DescrAlignConverter': 203, + 'PyArray_DescrAlignConverter2': 204, + 'PyArray_SearchsideConverter': 205, + 'PyArray_CheckAxis': 206, + 'PyArray_OverflowMultiplyList': 207, + 'PyArray_CompareString': 208, + 'PyArray_MultiIterFromObjects': 209, + 'PyArray_GetEndianness': 210, + 'PyArray_GetNDArrayCFeatureVersion': 211, + 'PyArray_Correlate2': 212, + 'PyArray_NeighborhoodIterNew': 213, + # End 1.5 API + 'PyArray_SetDatetimeParseFunction': 219, + 'PyArray_DatetimeToDatetimeStruct': 220, + 'PyArray_TimedeltaToTimedeltaStruct': 221, + 'PyArray_DatetimeStructToDatetime': 222, + 'PyArray_TimedeltaStructToTimedelta': 223, # New Iterator API - 'NpyIter_New': 223, - 'NpyIter_MultiNew': 224, - 'NpyIter_Copy': 225, - 'NpyIter_Deallocate': 226, - 'NpyIter_HasDelayedBufAlloc': 227, - 'NpyIter_HasInnerLoop': 228, - 'NpyIter_RemoveInnerLoop': 229, - 'NpyIter_GetInnerStrideArray': 230, - 'NpyIter_GetInnerLoopSizePtr': 231, - 'NpyIter_Reset': 232, - 'NpyIter_ResetBasePointers': 233, - 'NpyIter_ResetToIterIndexRange': 234, - 'NpyIter_GetNDim': 235, - 'NpyIter_GetNIter': 236, - 'NpyIter_GetIterNext': 237, - 'NpyIter_GetIterSize': 238, - 'NpyIter_GetIterIndexRange': 239, - 'NpyIter_GetIterIndex': 240, - 'NpyIter_GotoIterIndex': 241, - 'NpyIter_HasCoords': 242, - 'NpyIter_GetShape': 243, - 'NpyIter_GetGetCoords': 244, - 'NpyIter_GotoCoords': 245, - 'NpyIter_RemoveCoords': 246, - 'NpyIter_HasIndex': 247, - 'NpyIter_IsBuffered': 248, - 'NpyIter_IsGrowInner': 249, - 'NpyIter_GetBufferSize': 250, - 'NpyIter_GetIndexPtr': 251, - 'NpyIter_GotoIndex': 252, - 'NpyIter_GetDataPtrArray': 253, - 'NpyIter_GetDescrArray': 254, - 'NpyIter_GetOperandArray': 255, - 'NpyIter_GetIterView': 256, - 'NpyIter_GetReadFlags': 257, - 'NpyIter_GetWriteFlags': 258, - 'NpyIter_DebugPrint': 259, - 'NpyIter_IterationNeedsAPI': 260, - 'NpyIter_GetInnerFixedStrideArray': 261, - 'NpyIter_RemoveAxis': 262, + 'NpyIter_New': 224, + 'NpyIter_MultiNew': 225, + 'NpyIter_Copy': 226, + 'NpyIter_Deallocate': 227, + 'NpyIter_HasDelayedBufAlloc': 228, + 'NpyIter_HasInnerLoop': 229, + 'NpyIter_RemoveInnerLoop': 230, + 'NpyIter_GetInnerStrideArray': 231, + 'NpyIter_GetInnerLoopSizePtr': 232, + 'NpyIter_Reset': 233, + 'NpyIter_ResetBasePointers': 234, + 'NpyIter_ResetToIterIndexRange': 235, + 'NpyIter_GetNDim': 236, + 'NpyIter_GetNIter': 237, + 'NpyIter_GetIterNext': 238, + 'NpyIter_GetIterSize': 239, + 'NpyIter_GetIterIndexRange': 240, + 'NpyIter_GetIterIndex': 241, + 'NpyIter_GotoIterIndex': 242, + 'NpyIter_HasCoords': 243, + 'NpyIter_GetShape': 244, + 'NpyIter_GetGetCoords': 245, + 'NpyIter_GotoCoords': 246, + 'NpyIter_RemoveCoords': 247, + 'NpyIter_HasIndex': 248, + 'NpyIter_IsBuffered': 249, + 'NpyIter_IsGrowInner': 250, + 'NpyIter_GetBufferSize': 251, + 'NpyIter_GetIndexPtr': 252, + 'NpyIter_GotoIndex': 253, + 'NpyIter_GetDataPtrArray': 254, + 'NpyIter_GetDescrArray': 255, + 'NpyIter_GetOperandArray': 256, + 'NpyIter_GetIterView': 257, + 'NpyIter_GetReadFlags': 258, + 'NpyIter_GetWriteFlags': 259, + 'NpyIter_DebugPrint': 260, + 'NpyIter_IterationNeedsAPI': 261, + 'NpyIter_GetInnerFixedStrideArray': 262, + 'NpyIter_RemoveAxis': 263, # - 'PyArray_CastingConverter': 263, - 'PyArray_CountNonzero': 264, - 'PyArray_PromoteTypes': 265, - 'PyArray_MinScalarType': 266, - 'PyArray_ResultType': 267, - 'PyArray_CanCastArrayTo': 268, - 'PyArray_CanCastTypeTo': 269, - 'PyArray_EinsteinSum': 270, - 'PyArray_FillWithZero': 271, + 'PyArray_CastingConverter': 264, + 'PyArray_CountNonzero': 265, + 'PyArray_PromoteTypes': 266, + 'PyArray_MinScalarType': 267, + 'PyArray_ResultType': 268, + 'PyArray_CanCastArrayTo': 269, + 'PyArray_CanCastTypeTo': 270, + 'PyArray_EinsteinSum': 271, + 'PyArray_FillWithZero': 272, } ufunc_types_api = { @@ -343,6 +346,7 @@ 'PyUFunc_ReplaceLoopBySignature': 30, 'PyUFunc_FromFuncAndDataAndSignature': 31, 'PyUFunc_SetUsesArraysAsData': 32, + # End 1.5 API 'PyUFunc_e_e': 33, 'PyUFunc_e_e_As_f_f': 34, 'PyUFunc_e_e_As_d_d': 35, diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h index 08612668eaf8..51b87c5eb2db 100644 --- a/numpy/core/include/numpy/ndarraytypes.h +++ b/numpy/core/include/numpy/ndarraytypes.h @@ -572,8 +572,7 @@ typedef struct _PyArray_Descr { * '>' (big), '<' (little), '|' * (not-applicable), or '=' (native). */ - char unused; - int flags; /* flag describing data type */ + char flags; /* flags describing data type */ int type_num; /* number representing this type */ int elsize; /* element size for this type */ int alignment; /* alignment needed for this type */ diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py index 2423ab0ef493..0a4f070f3512 100644 --- a/numpy/core/setup_common.py +++ b/numpy/core/setup_common.py @@ -21,7 +21,7 @@ # Binary compatibility version number. This number is increased whenever the # C-API is changed such that binary compatibility is broken, i.e. whenever a # recompile of extension modules is needed. -C_ABI_VERSION = 0x02000000 +C_ABI_VERSION = 0x01000009 # Minor API version. This number is increased whenever a change is made to the # C-API -- whether it breaks binary compatibility or not. Some changes, such diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index 11760241e8e9..6d1385b76b54 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -3661,7 +3661,6 @@ static PyArray_Descr @from@_Descr = { PyArray_@from@LTR, '@endian@', 0, - 0, PyArray_@from@, 0, _ALIGN(@align@), @@ -3752,7 +3751,6 @@ NPY_NO_EXPORT PyArray_Descr @from@_Descr = { PyArray_@kind@LTR, PyArray_@from@LTR, '@endian@', - 0, @isobject@, PyArray_@from@, @num@*sizeof(@fromtyp@), diff --git a/numpy/core/src/multiarray/lowlevel_strided_loops.c.src b/numpy/core/src/multiarray/lowlevel_strided_loops.c.src index 70dd3437b034..bc0912aa53d0 100644 --- a/numpy/core/src/multiarray/lowlevel_strided_loops.c.src +++ b/numpy/core/src/multiarray/lowlevel_strided_loops.c.src @@ -681,6 +681,7 @@ NPY_NO_EXPORT PyArray_StridedTransferFn * * byte, short, int, long, longlong, * half, float, double, longdouble, * float, double, longdouble# + * #is_bool1 = 1, 0*17# * #is_half1 = 0*11, 1, 0*6# * #is_float1 = 0*12, 1, 0, 0, 1, 0, 0# * #is_double1 = 0*13, 1, 0, 0, 1, 0# @@ -704,6 +705,7 @@ NPY_NO_EXPORT PyArray_StridedTransferFn * * byte, short, int, long, longlong, * half, float, double, longdouble, * float, double, longdouble# + * #is_bool2 = 1, 0*17# * #is_half2 = 0*11, 1, 0*6# * #is_float2 = 0*12, 1, 0, 0, 1, 0, 0# * #is_double2 = 0*13, 1, 0, 0, 1, 0# @@ -771,7 +773,11 @@ NPY_NO_EXPORT PyArray_StridedTransferFn * #else +# if @is_bool2@ +# define _CONVERT_FN(x) ((npy_bool)(x != 0)) +# else # define _CONVERT_FN(x) ((_TYPE2)x) +# endif #endif diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 718012bc4464..9ab3cc470ec3 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -45,6 +45,9 @@ NPY_NO_EXPORT int NPY_NUMUSERTYPES = 0; #include "convert_datatype.h" #include "new_iterator_pywrap.h" +/* Only here for API compatibility */ +NPY_NO_EXPORT PyTypeObject PyBigArray_Type; + /*NUMPY_API * Get Priority from object */ @@ -734,9 +737,14 @@ PyArray_MatrixProduct(PyObject *op1, PyObject *op2) PyArray_Descr *typec; NPY_BEGIN_THREADS_DEF; + PyArrayObject *ops_array[2]; + + ops_array[0] = op1; + ops_array[1] = op2; typenum = PyArray_ObjectType(op1, 0); typenum = PyArray_ObjectType(op2, typenum); typec = PyArray_DescrFromType(typenum); + Py_INCREF(typec); ap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0, ALIGNED, NULL); if (ap1 == NULL) { @@ -2073,7 +2081,7 @@ array_arange(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws) { NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCVersion(void) { - return (unsigned int)NPY_VERSION; + return (unsigned int)NPY_ABI_VERSION; } /*NUMPY_API @@ -2082,7 +2090,7 @@ PyArray_GetNDArrayCVersion(void) NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCFeatureVersion(void) { - return (unsigned int)NPY_FEATURE_VERSION; + return (unsigned int)NPY_API_VERSION; } static PyObject *