Small fixes in numpy.h (#2293)

- `PyArray_NewFromDescr_` should have been using `Py_intptr_t const *`
  - 18a6e3e505/numpy/core/src/multiarray/ctors.h (L5-L8)
- `PyArray_GetArrayParamsFromObject_` should be using `NPY_BOOL`
  - 18a6e3e505/numpy/core/src/multiarray/ctors.c (L1350-L1355)
  - https://docs.scipy.org/doc/numpy-1.13.0/reference/c-api.dtype.html#c.npy_bool
- `PyArray_DescrNewFromType` is at offset 96
  - 36e017194c/numpy/core/code_generators/numpy_api.py (L141)
- `array_t` constructor that takes a size and a pointer should take `ssize_t`.
  - Fixes #1599
This commit is contained in:
Boris Staletic 2020-07-12 16:45:13 +02:00 committed by GitHub
parent fe1392d089
commit aa982e131d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,8 +181,9 @@ struct npy_api {
unsigned int (*PyArray_GetNDArrayCFeatureVersion_)(); unsigned int (*PyArray_GetNDArrayCFeatureVersion_)();
PyObject *(*PyArray_DescrFromType_)(int); PyObject *(*PyArray_DescrFromType_)(int);
PyObject *(*PyArray_NewFromDescr_) PyObject *(*PyArray_NewFromDescr_)
(PyTypeObject *, PyObject *, int, Py_intptr_t *, (PyTypeObject *, PyObject *, int, Py_intptr_t const *,
Py_intptr_t *, void *, int, PyObject *); Py_intptr_t const *, void *, int, PyObject *);
// Unused. Not removed because that affects ABI of the class.
PyObject *(*PyArray_DescrNewFromType_)(int); PyObject *(*PyArray_DescrNewFromType_)(int);
int (*PyArray_CopyInto_)(PyObject *, PyObject *); int (*PyArray_CopyInto_)(PyObject *, PyObject *);
PyObject *(*PyArray_NewCopy_)(PyObject *, int); PyObject *(*PyArray_NewCopy_)(PyObject *, int);
@ -193,9 +194,10 @@ struct npy_api {
PyObject *(*PyArray_FromAny_) (PyObject *, PyObject *, int, int, int, PyObject *); PyObject *(*PyArray_FromAny_) (PyObject *, PyObject *, int, int, int, PyObject *);
int (*PyArray_DescrConverter_) (PyObject *, PyObject **); int (*PyArray_DescrConverter_) (PyObject *, PyObject **);
bool (*PyArray_EquivTypes_) (PyObject *, PyObject *); bool (*PyArray_EquivTypes_) (PyObject *, PyObject *);
int (*PyArray_GetArrayParamsFromObject_)(PyObject *, PyObject *, char, PyObject **, int *, int (*PyArray_GetArrayParamsFromObject_)(PyObject *, PyObject *, unsigned char, PyObject **, int *,
Py_ssize_t *, PyObject **, PyObject *); Py_intptr_t *, PyObject **, PyObject *);
PyObject *(*PyArray_Squeeze_)(PyObject *); PyObject *(*PyArray_Squeeze_)(PyObject *);
// Unused. Not removed because that affects ABI of the class.
int (*PyArray_SetBaseObject_)(PyObject *, PyObject *); int (*PyArray_SetBaseObject_)(PyObject *, PyObject *);
PyObject* (*PyArray_Resize_)(PyObject*, PyArray_Dims*, int, int); PyObject* (*PyArray_Resize_)(PyObject*, PyArray_Dims*, int, int);
private: private:
@ -211,7 +213,7 @@ private:
API_PyArray_CopyInto = 82, API_PyArray_CopyInto = 82,
API_PyArray_NewCopy = 85, API_PyArray_NewCopy = 85,
API_PyArray_NewFromDescr = 94, API_PyArray_NewFromDescr = 94,
API_PyArray_DescrNewFromType = 9, API_PyArray_DescrNewFromType = 96,
API_PyArray_DescrConverter = 174, API_PyArray_DescrConverter = 174,
API_PyArray_EquivTypes = 182, API_PyArray_EquivTypes = 182,
API_PyArray_GetArrayParamsFromObject = 278, API_PyArray_GetArrayParamsFromObject = 278,
@ -866,7 +868,7 @@ public:
ExtraFlags & f_style ? f_strides(*shape, itemsize()) : c_strides(*shape, itemsize()), ExtraFlags & f_style ? f_strides(*shape, itemsize()) : c_strides(*shape, itemsize()),
ptr, base) { } ptr, base) { }
explicit array_t(size_t count, const T *ptr = nullptr, handle base = handle()) explicit array_t(ssize_t count, const T *ptr = nullptr, handle base = handle())
: array({count}, {}, ptr, base) { } : array({count}, {}, ptr, base) { }
constexpr ssize_t itemsize() const { constexpr ssize_t itemsize() const {