Skip to content

Commit f1d6bdb

Browse files
committed
update headers
1 parent dd6b8d2 commit f1d6bdb

File tree

12 files changed

+53
-244
lines changed

12 files changed

+53
-244
lines changed

stl_tools/numpy_include/numpy/__multiarray_api.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ extern NPY_NO_EXPORT PyTypeObject PyBigArray_Type;
1616

1717
extern NPY_NO_EXPORT PyTypeObject PyArray_Type;
1818

19-
extern NPY_NO_EXPORT PyArray_DTypeMeta PyArrayDescr_TypeFull;
20-
#define PyArrayDescr_Type (*(PyTypeObject *)(&PyArrayDescr_TypeFull))
19+
extern NPY_NO_EXPORT PyTypeObject PyArrayDescr_Type;
2120

2221
extern NPY_NO_EXPORT PyTypeObject PyArrayFlags_Type;
2322

@@ -568,7 +567,7 @@ NPY_NO_EXPORT PyArrayObject * PyArray_EinsteinSum \
568567
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) NPY_GCC_NONNULL(1) PyObject * PyArray_NewLikeArray \
569568
(PyArrayObject *, NPY_ORDER, PyArray_Descr *, int);
570569
NPY_NO_EXPORT int PyArray_GetArrayParamsFromObject \
571-
(PyObject *NPY_UNUSED(op), PyArray_Descr *NPY_UNUSED(requested_dtype), npy_bool NPY_UNUSED(writeable), PyArray_Descr **NPY_UNUSED(out_dtype), int *NPY_UNUSED(out_ndim), npy_intp *NPY_UNUSED(out_dims), PyArrayObject **NPY_UNUSED(out_arr), PyObject *NPY_UNUSED(context));
570+
(PyObject *, PyArray_Descr *, npy_bool, PyArray_Descr **, int *, npy_intp *, PyArrayObject **, PyObject *);
572571
NPY_NO_EXPORT int PyArray_ConvertClipmodeSequence \
573572
(PyObject *, NPY_CLIPMODE *, int);
574573
NPY_NO_EXPORT PyObject * PyArray_MatrixProduct2 \
@@ -1383,7 +1382,7 @@ static void **PyArray_API=NULL;
13831382
(*(PyObject * (*)(PyArrayObject *, NPY_ORDER, PyArray_Descr *, int)) \
13841383
PyArray_API[277])
13851384
#define PyArray_GetArrayParamsFromObject \
1386-
(*(int (*)(PyObject *NPY_UNUSED(op), PyArray_Descr *NPY_UNUSED(requested_dtype), npy_bool NPY_UNUSED(writeable), PyArray_Descr **NPY_UNUSED(out_dtype), int *NPY_UNUSED(out_ndim), npy_intp *NPY_UNUSED(out_dims), PyArrayObject **NPY_UNUSED(out_arr), PyObject *NPY_UNUSED(context))) \
1385+
(*(int (*)(PyObject *, PyArray_Descr *, npy_bool, PyArray_Descr **, int *, npy_intp *, PyArrayObject **, PyObject *)) \
13871386
PyArray_API[278])
13881387
#define PyArray_ConvertClipmodeSequence \
13891388
(*(int (*)(PyObject *, NPY_CLIPMODE *, int)) \

stl_tools/numpy_include/numpy/_numpyconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define NPY_USE_C99_FORMATS 1
2626
#define NPY_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
2727
#define NPY_ABI_VERSION 0x01000009
28-
#define NPY_API_VERSION 0x0000000E
28+
#define NPY_API_VERSION 0x0000000D
2929

3030
#ifndef __STDC_FORMAT_MACROS
3131
#define __STDC_FORMAT_MACROS 1

stl_tools/numpy_include/numpy/arrayscalars.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ typedef struct {
134134
char obval;
135135
} PyScalarObject;
136136

137-
#define PyStringScalarObject PyBytesObject
137+
#define PyStringScalarObject PyStringObject
138+
#define PyStringScalarObject PyStringObject
138139
typedef struct {
139140
/* note that the PyObject_HEAD macro lives right here */
140141
PyUnicodeObject base;
141142
Py_UCS4 *obval;
142-
char *buffer_fmt;
143143
} PyUnicodeScalarObject;
144144

145145

@@ -149,7 +149,6 @@ typedef struct {
149149
PyArray_Descr *descr;
150150
int flags;
151151
PyObject *base;
152-
void *_buffer_info; /* private buffer info, tagged to allow warning */
153152
} PyVoidScalarObject;
154153

155154
/* Macros

stl_tools/numpy_include/numpy/multiarray_api.txt

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,12 +1634,7 @@ Makes a copy of the iterator
16341634
int
16351635
NpyIter_Deallocate(NpyIter *iter)
16361636

1637-
Deallocate an iterator.
1638-
1639-
To correctly work when an error is in progress, we have to check
1640-
`PyErr_Occurred()`. This is necessary when buffers are not finalized
1641-
or WritebackIfCopy is used. We could avoid that check by exposing a new
1642-
function which is passed in whether or not a Python error is already set.
1637+
Deallocate an iterator
16431638

16441639
::
16451640

@@ -1687,14 +1682,10 @@ This function may be safely called without holding the Python GIL.
16871682

16881683
Resets the iterator to its initial state
16891684

1690-
The use of errmsg is discouraged, it cannot be guaranteed that the GIL
1691-
will not be grabbed on casting errors even when this is passed.
1692-
16931685
If errmsg is non-NULL, it should point to a variable which will
16941686
receive the error message, and no Python exception will be set.
16951687
This is so that the function can be called from code not holding
1696-
the GIL. Note that cast errors may still lead to the GIL being
1697-
grabbed temporarily.
1688+
the GIL.
16981689

16991690
::
17001691

@@ -1708,8 +1699,7 @@ This function requires great caution.
17081699
If errmsg is non-NULL, it should point to a variable which will
17091700
receive the error message, and no Python exception will be set.
17101701
This is so that the function can be called from code not holding
1711-
the GIL. Note that cast errors may still lead to the GIL being
1712-
grabbed temporarily.
1702+
the GIL.
17131703

17141704
::
17151705

@@ -1722,8 +1712,7 @@ Resets the iterator to a new iterator index range
17221712
If errmsg is non-NULL, it should point to a variable which will
17231713
receive the error message, and no Python exception will be set.
17241714
This is so that the function can be called from code not holding
1725-
the GIL. Note that cast errors may still lead to the GIL being
1726-
grabbed temporarily.
1715+
the GIL.
17271716

17281717
::
17291718

@@ -2180,16 +2169,12 @@ dtype->subarray is true, dtype will be decrefed.
21802169
::
21812170

21822171
int
2183-
PyArray_GetArrayParamsFromObject(PyObject *NPY_UNUSED(op)
2184-
, PyArray_Descr
2185-
*NPY_UNUSED(requested_dtype)
2186-
, npy_bool NPY_UNUSED(writeable)
2187-
, PyArray_Descr
2188-
**NPY_UNUSED(out_dtype) , int
2189-
*NPY_UNUSED(out_ndim) , npy_intp
2190-
*NPY_UNUSED(out_dims) , PyArrayObject
2191-
**NPY_UNUSED(out_arr) , PyObject
2192-
*NPY_UNUSED(context) )
2172+
PyArray_GetArrayParamsFromObject(PyObject *op, PyArray_Descr
2173+
*requested_dtype, npy_bool
2174+
writeable, PyArray_Descr
2175+
**out_dtype, int *out_ndim, npy_intp
2176+
*out_dims, PyArrayObject
2177+
**out_arr, PyObject *context)
21932178

21942179

21952180
::

stl_tools/numpy_include/numpy/ndarraytypes.h

Lines changed: 9 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ typedef enum {
210210

211211
/* For specifying allowed casting in operations which support it */
212212
typedef enum {
213-
_NPY_ERROR_OCCURRED_IN_CAST = -1,
214213
/* Only allow identical types */
215214
NPY_NO_CASTING=0,
216215
/* Allow identical and byte swapped types */
@@ -220,14 +219,7 @@ typedef enum {
220219
/* Allow safe casts or casts within the same kind */
221220
NPY_SAME_KIND_CASTING=3,
222221
/* Allow any casts */
223-
NPY_UNSAFE_CASTING=4,
224-
/*
225-
* Flag to allow signalling that a cast is a view, this flag is not
226-
* valid when requesting a cast of specific safety.
227-
* _NPY_CAST_IS_VIEW|NPY_EQUIV_CASTING means the same as NPY_NO_CASTING.
228-
*/
229-
// TODO-DTYPES: Needs to be documented.
230-
_NPY_CAST_IS_VIEW = 1 << 16,
222+
NPY_UNSAFE_CASTING=4
231223
} NPY_CASTING;
232224

233225
typedef enum {
@@ -349,6 +341,9 @@ struct NpyAuxData_tag {
349341
#define NPY_ERR(str) fprintf(stderr, #str); fflush(stderr);
350342
#define NPY_ERR2(str) fprintf(stderr, str); fflush(stderr);
351343

344+
#define NPY_STRINGIFY(x) #x
345+
#define NPY_TOSTRING(x) NPY_STRINGIFY(x)
346+
352347
/*
353348
* Macros to define how array, and dimension/strides data is
354349
* allocated.
@@ -709,7 +704,6 @@ typedef struct tagPyArrayObject_fields {
709704
int flags;
710705
/* For weak references */
711706
PyObject *weakreflist;
712-
void *_buffer_info; /* private buffer info, tagged to allow warning */
713707
} PyArrayObject_fields;
714708

715709
/*
@@ -729,18 +723,7 @@ typedef struct tagPyArrayObject {
729723
} PyArrayObject;
730724
#endif
731725

732-
/*
733-
* Removed 2020-Nov-25, NumPy 1.20
734-
* #define NPY_SIZEOF_PYARRAYOBJECT (sizeof(PyArrayObject_fields))
735-
*
736-
* The above macro was removed as it gave a false sense of a stable ABI
737-
* with respect to the structures size. If you require a runtime constant,
738-
* you can use `PyArray_Type.tp_basicsize` instead. Otherwise, please
739-
* see the PyArrayObject documentation or ask the NumPy developers for
740-
* information on how to correctly replace the macro in a way that is
741-
* compatible with multiple NumPy versions.
742-
*/
743-
726+
#define NPY_SIZEOF_PYARRAYOBJECT (sizeof(PyArrayObject_fields))
744727

745728
/* Array Flags Object */
746729
typedef struct PyArrayFlagsObject {
@@ -1567,15 +1550,11 @@ PyArray_GETITEM(const PyArrayObject *arr, const char *itemptr)
15671550
(void *)itemptr, (PyArrayObject *)arr);
15681551
}
15691552

1570-
/*
1571-
* SETITEM should only be used if it is known that the value is a scalar
1572-
* and of a type understood by the arrays dtype.
1573-
* Use `PyArray_Pack` if the value may be of a different dtype.
1574-
*/
15751553
static NPY_INLINE int
15761554
PyArray_SETITEM(PyArrayObject *arr, char *itemptr, PyObject *v)
15771555
{
1578-
return ((PyArrayObject_fields *)arr)->descr->f->setitem(v, itemptr, arr);
1556+
return ((PyArrayObject_fields *)arr)->descr->f->setitem(
1557+
v, itemptr, arr);
15791558
}
15801559

15811560
#else
@@ -1779,8 +1758,8 @@ typedef struct {
17791758
} npy_stride_sort_item;
17801759

17811760
/************************************************************
1782-
* This is the form of the struct that's stored in the
1783-
* PyCapsule returned by an array's __array_struct__ attribute. See
1761+
* This is the form of the struct that's returned pointed by the
1762+
* PyCObject attribute of an array __array_struct__. See
17841763
* https://docs.scipy.org/doc/numpy/reference/arrays.interface.html for the full
17851764
* documentation.
17861765
************************************************************/
@@ -1830,107 +1809,6 @@ typedef struct {
18301809
typedef void (PyDataMem_EventHookFunc)(void *inp, void *outp, size_t size,
18311810
void *user_data);
18321811

1833-
1834-
/*
1835-
* PyArray_DTypeMeta related definitions.
1836-
*
1837-
* As of now, this API is preliminary and will be extended as necessary.
1838-
*/
1839-
#if defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD
1840-
/*
1841-
* The Structures defined in this block are considered private API and
1842-
* may change without warning!
1843-
*/
1844-
/* TODO: Make this definition public in the API, as soon as its settled */
1845-
NPY_NO_EXPORT extern PyTypeObject PyArrayDTypeMeta_Type;
1846-
1847-
typedef struct PyArray_DTypeMeta_tag PyArray_DTypeMeta;
1848-
1849-
typedef PyArray_Descr *(discover_descr_from_pyobject_function)(
1850-
PyArray_DTypeMeta *cls, PyObject *obj);
1851-
1852-
/*
1853-
* Before making this public, we should decide whether it should pass
1854-
* the type, or allow looking at the object. A possible use-case:
1855-
* `np.array(np.array([0]), dtype=np.ndarray)`
1856-
* Could consider arrays that are not `dtype=ndarray` "scalars".
1857-
*/
1858-
typedef int (is_known_scalar_type_function)(
1859-
PyArray_DTypeMeta *cls, PyTypeObject *obj);
1860-
1861-
typedef PyArray_Descr *(default_descr_function)(PyArray_DTypeMeta *cls);
1862-
typedef PyArray_DTypeMeta *(common_dtype_function)(
1863-
PyArray_DTypeMeta *dtype1, PyArray_DTypeMeta *dtyep2);
1864-
typedef PyArray_Descr *(common_instance_function)(
1865-
PyArray_Descr *dtype1, PyArray_Descr *dtyep2);
1866-
1867-
/*
1868-
* While NumPy DTypes would not need to be heap types the plan is to
1869-
* make DTypes available in Python at which point they will be heap types.
1870-
* Since we also wish to add fields to the DType class, this looks like
1871-
* a typical instance definition, but with PyHeapTypeObject instead of
1872-
* only the PyObject_HEAD.
1873-
* This must only be exposed very extremely careful consideration, since
1874-
* it is a fairly complex construct which may be better to allow
1875-
* refactoring of.
1876-
*/
1877-
struct PyArray_DTypeMeta_tag {
1878-
PyHeapTypeObject super;
1879-
1880-
/*
1881-
* Most DTypes will have a singleton default instance, for the
1882-
* parametric legacy DTypes (bytes, string, void, datetime) this
1883-
* may be a pointer to the *prototype* instance?
1884-
*/
1885-
PyArray_Descr *singleton;
1886-
/*
1887-
* Is this DType created using the old API? This exists mainly to
1888-
* allow for assertions in paths specific to wrapping legacy types.
1889-
*/
1890-
npy_bool legacy;
1891-
/* The values stored by a parametric datatype depend on its instance */
1892-
npy_bool parametric;
1893-
/* whether the DType can be instantiated (i.e. np.dtype cannot) */
1894-
npy_bool abstract;
1895-
1896-
/*
1897-
* The following fields replicate the most important dtype information.
1898-
* In the legacy implementation most of these are stored in the
1899-
* PyArray_Descr struct.
1900-
*/
1901-
/* The type object of the scalar instances (may be NULL?) */
1902-
PyTypeObject *scalar_type;
1903-
/* kind for this type */
1904-
char kind;
1905-
/* unique-character representing this type */
1906-
char type;
1907-
/* flags describing data type */
1908-
char flags;
1909-
/* number representing this type */
1910-
int type_num;
1911-
/*
1912-
* Point to the original ArrFuncs.
1913-
* NOTE: We could make a copy to detect changes to `f`.
1914-
*/
1915-
PyArray_ArrFuncs *f;
1916-
1917-
/* DType methods, these could be moved into its own struct */
1918-
discover_descr_from_pyobject_function *discover_descr_from_pyobject;
1919-
is_known_scalar_type_function *is_known_scalar_type;
1920-
default_descr_function *default_descr;
1921-
common_dtype_function *common_dtype;
1922-
common_instance_function *common_instance;
1923-
/*
1924-
* Dictionary of ArrayMethods representing most possible casts
1925-
* (structured and object are exceptions).
1926-
* This should potentially become a weak mapping in the future.
1927-
*/
1928-
PyObject *castingimpls;
1929-
};
1930-
1931-
#endif /* NPY_INTERNAL_BUILD */
1932-
1933-
19341812
/*
19351813
* Use the keyword NPY_DEPRECATED_INCLUDES to ensure that the header files
19361814
* npy_*_*_deprecated_api.h are only included from here and nowhere else.

stl_tools/numpy_include/numpy/npy_1_7_deprecated_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
#define _WARN___LOC__ __FILE__ "(" _WARN___STR1__(__LINE__) ") : Warning Msg: "
1414
#pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it with " \
1515
"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION")
16-
#else
16+
#elif defined(__GNUC__)
1717
#warning "Using deprecated NumPy API, disable it with " \
1818
"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
1919
#endif
20+
/* TODO: How to do this warning message for other compilers? */
2021
#endif
2122

2223
/*

stl_tools/numpy_include/numpy/npy_3kcompat.h

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,6 @@ extern "C" {
2828
* PyInt -> PyLong
2929
*/
3030

31-
32-
/*
33-
* This is a renamed copy of the Python non-limited API function _PyLong_AsInt. It is
34-
* included here because it is missing from the PyPy API. It completes the PyLong_As*
35-
* group of functions and can be useful in replacing PyInt_Check.
36-
*/
37-
static NPY_INLINE int
38-
Npy__PyLong_AsInt(PyObject *obj)
39-
{
40-
int overflow;
41-
long result = PyLong_AsLongAndOverflow(obj, &overflow);
42-
43-
/* INT_MAX and INT_MIN are defined in Python.h */
44-
if (overflow || result > INT_MAX || result < INT_MIN) {
45-
/* XXX: could be cute and give a different
46-
message for overflow == -1 */
47-
PyErr_SetString(PyExc_OverflowError,
48-
"Python int too large to convert to C int");
49-
return -1;
50-
}
51-
return (int)result;
52-
}
53-
54-
5531
#if defined(NPY_PY3K)
5632
/* Return True only if the long fits in a C long */
5733
static NPY_INLINE int PyInt_Check(PyObject *op) {
@@ -63,7 +39,6 @@ static NPY_INLINE int PyInt_Check(PyObject *op) {
6339
return (overflow == 0);
6440
}
6541

66-
6742
#define PyInt_FromLong PyLong_FromLong
6843
#define PyInt_AsLong PyLong_AsLong
6944
#define PyInt_AS_LONG PyLong_AsLong
@@ -87,11 +62,9 @@ static NPY_INLINE int PyInt_Check(PyObject *op) {
8762

8863
#if PY_VERSION_HEX < 0x030900a4
8964
/* Introduced in https://github.com/python/cpython/commit/d2ec81a8c99796b51fb8c49b77a7fe369863226f */
90-
#define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
65+
#define Py_SET_TYPE(obj, typ) (Py_TYPE(obj) = typ)
9166
/* Introduced in https://github.com/python/cpython/commit/b10dc3e7a11fcdb97e285882eba6da92594f90f9 */
92-
#define Py_SET_SIZE(obj, size) ((Py_SIZE(obj) = (size)), (void)0)
93-
/* Introduced in https://github.com/python/cpython/commit/c86a11221df7e37da389f9c6ce6e47ea22dc44ff */
94-
#define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0)
67+
#define Py_SET_SIZE(obj, size) (Py_SIZE(obj) = size)
9568
#endif
9669

9770

0 commit comments

Comments
 (0)