numpy  2.0.0
include/numpy/npy_1_7_deprecated_api.h
Go to the documentation of this file.
00001 #ifndef _NPY_1_7_DEPRECATED_API_H
00002 #define _NPY_1_7_DEPRECATED_API_H
00003 
00004 #ifndef NPY_DEPRECATED_INCLUDES
00005 #error "Should never include npy_*_*_deprecated_api directly."
00006 #endif
00007 
00008 #if defined(_WIN32)
00009 #define _WARN___STR2__(x) #x
00010 #define _WARN___STR1__(x) _WARN___STR2__(x)
00011 #define _WARN___LOC__ __FILE__ "(" _WARN___STR1__(__LINE__) ") : Warning Msg: "
00012 #pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it by " \
00013                          "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION")
00014 #elif defined(__GNUC__)
00015 #warning "Using deprecated NumPy API, disable it by " \
00016          "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
00017 #endif
00018 /* TODO: How to do this warning message for other compilers? */
00019 
00020 /*
00021  * This header exists to collect all dangerous/deprecated NumPy API
00022  * as of NumPy 1.7.
00023  *
00024  * This is an attempt to remove bad API, the proliferation of macros,
00025  * and namespace pollution currently produced by the NumPy headers.
00026  */
00027 
00028 /* These array flags are deprecated as of NumPy 1.7 */
00029 #define NPY_CONTIGUOUS NPY_ARRAY_C_CONTIGUOUS
00030 #define NPY_FORTRAN NPY_ARRAY_F_CONTIGUOUS
00031 
00032 /*
00033  * The consistent NPY_ARRAY_* names which don't pollute the NPY_*
00034  * namespace were added in NumPy 1.7.
00035  *
00036  * These versions of the carray flags are deprecated, but
00037  * probably should only be removed after two releases instead of one.
00038  */
00039 #define NPY_C_CONTIGUOUS   NPY_ARRAY_C_CONTIGUOUS
00040 #define NPY_F_CONTIGUOUS   NPY_ARRAY_F_CONTIGUOUS
00041 #define NPY_OWNDATA        NPY_ARRAY_OWNDATA
00042 #define NPY_FORCECAST      NPY_ARRAY_FORCECAST
00043 #define NPY_ENSURECOPY     NPY_ARRAY_ENSURECOPY
00044 #define NPY_ENSUREARRAY    NPY_ARRAY_ENSUREARRAY
00045 #define NPY_ELEMENTSTRIDES NPY_ARRAY_ELEMENTSTRIDES
00046 #define NPY_ALIGNED        NPY_ARRAY_ALIGNED
00047 #define NPY_NOTSWAPPED     NPY_ARRAY_NOTSWAPPED
00048 #define NPY_WRITEABLE      NPY_ARRAY_WRITEABLE
00049 #define NPY_UPDATEIFCOPY   NPY_ARRAY_UPDATEIFCOPY
00050 #define NPY_BEHAVED        NPY_ARRAY_BEHAVED
00051 #define NPY_BEHAVED_NS     NPY_ARRAY_BEHAVED_NS
00052 #define NPY_CARRAY         NPY_ARRAY_CARRAY
00053 #define NPY_CARRAY_RO      NPY_ARRAY_CARRAY_RO
00054 #define NPY_FARRAY         NPY_ARRAY_FARRAY
00055 #define NPY_FARRAY_RO      NPY_ARRAY_FARRAY_RO
00056 #define NPY_DEFAULT        NPY_ARRAY_DEFAULT
00057 #define NPY_IN_ARRAY       NPY_ARRAY_IN_ARRAY
00058 #define NPY_OUT_ARRAY      NPY_ARRAY_OUT_ARRAY
00059 #define NPY_INOUT_ARRAY    NPY_ARRAY_INOUT_ARRAY
00060 #define NPY_IN_FARRAY      NPY_ARRAY_IN_FARRAY
00061 #define NPY_OUT_FARRAY     NPY_ARRAY_OUT_FARRAY
00062 #define NPY_INOUT_FARRAY   NPY_ARRAY_INOUT_FARRAY
00063 #define NPY_UPDATE_ALL     NPY_ARRAY_UPDATE_ALL
00064 
00065 /* This way of accessing the default type is deprecated as of NumPy 1.7 */
00066 #define PyArray_DEFAULT NPY_DEFAULT_TYPE
00067 
00068 /* These DATETIME bits aren't used internally */
00069 #if PY_VERSION_HEX >= 0x03000000
00070 #define PyDataType_GetDatetimeMetaData(descr)                                 \
00071     ((descr->metadata == NULL) ? NULL :                                       \
00072         ((PyArray_DatetimeMetaData *)(PyCapsule_GetPointer(                   \
00073                 PyDict_GetItemString(                                         \
00074                     descr->metadata, NPY_METADATA_DTSTR), NULL))))
00075 #else
00076 #define PyDataType_GetDatetimeMetaData(descr)                                 \
00077     ((descr->metadata == NULL) ? NULL :                                       \
00078         ((PyArray_DatetimeMetaData *)(PyCObject_AsVoidPtr(                    \
00079                 PyDict_GetItemString(descr->metadata, NPY_METADATA_DTSTR)))))
00080 #endif
00081 
00082 /*
00083  * Deprecated as of NumPy 1.7, this kind of shortcut doesn't
00084  * belong in the public API.
00085  */
00086 #define NPY_AO PyArrayObject
00087 
00088 /*
00089  * Deprecated as of NumPy 1.7, an all-lowercase macro doesn't
00090  * belong in the public API.
00091  */
00092 #define fortran fortran_
00093 
00094 /*
00095  * Deprecated as of NumPy 1.7, as it is a namespace-polluting
00096  * macro.
00097  */
00098 #define FORTRAN_IF PyArray_FORTRAN_IF
00099 
00100 /* Deprecated as of NumPy 1.7, datetime64 uses c_metadata instead */
00101 #define NPY_METADATA_DTSTR "__timeunit__"
00102 
00103 /*
00104  * Deprecated as of NumPy 1.7.
00105  * The reasoning:
00106  *  - These are for datetime, but there's no datetime "namespace".
00107  *  - They just turn NPY_STR_<x> into "<x>", which is just
00108  *    making something simple be indirected.
00109  */
00110 #define NPY_STR_Y "Y"
00111 #define NPY_STR_M "M"
00112 #define NPY_STR_W "W"
00113 #define NPY_STR_D "D"
00114 #define NPY_STR_h "h"
00115 #define NPY_STR_m "m"
00116 #define NPY_STR_s "s"
00117 #define NPY_STR_ms "ms"
00118 #define NPY_STR_us "us"
00119 #define NPY_STR_ns "ns"
00120 #define NPY_STR_ps "ps"
00121 #define NPY_STR_fs "fs"
00122 #define NPY_STR_as "as"
00123 
00124 /*
00125  * The macros in old_defines.h are Deprecated as of NumPy 1.7 and will be
00126  * removed in the next major release.
00127  */
00128 #include "old_defines.h"
00129 
00130 #endif