Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 15, 2024
1 parent 8a9f0e7 commit d83ff6b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
6 changes: 4 additions & 2 deletions include/eigenpy/numpy-allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ struct numpy_allocator_impl_matrix<Eigen::Ref<MatType, Options, Stride> > {
#if NPY_ABI_VERSION < 0x02000000
const int elsize = call_PyArray_DescrFromType(Scalar_type_code)->elsize;
#else
const int elsize = PyDataType_ELSIZE(call_PyArray_DescrFromType(Scalar_type_code));
const int elsize =
PyDataType_ELSIZE(call_PyArray_DescrFromType(Scalar_type_code));
#endif
npy_intp strides[2] = {elsize * inner_stride, elsize * outer_stride};

Expand Down Expand Up @@ -211,7 +212,8 @@ struct numpy_allocator_impl_matrix<
#if NPY_ABI_VERSION < 0x02000000
const int elsize = call_PyArray_DescrFromType(Scalar_type_code)->elsize;
#else
const int elsize = PyDataType_ELSIZE(call_PyArray_DescrFromType(Scalar_type_code));
const int elsize =
PyDataType_ELSIZE(call_PyArray_DescrFromType(Scalar_type_code));
#endif
npy_intp strides[2] = {elsize * inner_stride, elsize * outer_stride};

Expand Down
3 changes: 2 additions & 1 deletion include/eigenpy/numpy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#endif

/* Allow compiling against NumPy 1.x and 2.x
see: https://github.com/numpy/numpy/blob/afea8fd66f6bdbde855f5aff0b4e73eb0213c646/doc/source/reference/c-api/array.rst#L1224
see:
https://github.com/numpy/numpy/blob/afea8fd66f6bdbde855f5aff0b4e73eb0213c646/doc/source/reference/c-api/array.rst#L1224
*/
#if NPY_ABI_VERSION < 0x02000000
#define PyArray_DescrProto PyArray_Descr
Expand Down
7 changes: 4 additions & 3 deletions include/eigenpy/user-type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ struct SpecialMethods<T, NPY_USERDEF> {
char* srcptr = static_cast<char*>(src);

PyArrayObject* py_array = static_cast<PyArrayObject*>(array);
PyArray_CopySwapFunc* copyswap = PyDataType_GetArrFuncs(PyArray_DESCR(py_array))->copyswap;
PyArray_CopySwapFunc* copyswap =
PyDataType_GetArrFuncs(PyArray_DESCR(py_array))->copyswap;

for (npy_intp i = 0; i < n; i++) {
copyswap(dstptr, srcptr, swap, array);
Expand All @@ -189,8 +190,8 @@ struct SpecialMethods<T, NPY_USERDEF> {
return (npy_bool)(value != ZeroValue);
} else {
T tmp_value;
PyDataType_GetArrFuncs(PyArray_DESCR(py_array))->copyswap(
&tmp_value, ip, PyArray_ISBYTESWAPPED(py_array), array);
PyDataType_GetArrFuncs(PyArray_DESCR(py_array))
->copyswap(&tmp_value, ip, PyArray_ISBYTESWAPPED(py_array), array);
return (npy_bool)(tmp_value != ZeroValue);
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/numpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ void import_numpy() {
}

int PyArray_TypeNum(PyTypeObject* type) {
PyArray_Descr * descr = PyArray_DescrFromTypeObject(reinterpret_cast<PyObject*>(type));
PyArray_Descr* descr =
PyArray_DescrFromTypeObject(reinterpret_cast<PyObject*>(type));
if (descr == NULL) {
return NPY_NOTYPE;
return NPY_NOTYPE;
}
return descr->type_num;
}
Expand All @@ -25,18 +26,16 @@ int PyArray_TypeNum(PyTypeObject* type) {
see : https://peps.python.org/pep-0674/
*/
#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
static inline void _Py_SET_TYPE(PyObject *o, PyTypeObject *type) {
static inline void _Py_SET_TYPE(PyObject* o, PyTypeObject* type) {
Py_TYPE(o) = type;
}
#define Py_SET_TYPE(o, type) _Py_SET_TYPE((PyObject*)(o), type)
#endif

#if NPY_ABI_VERSION < 0x02000000
static inline PyArray_ArrFuncs *
PyDataType_GetArrFuncs(PyArray_Descr *descr)
{
return descr->f;
}
static inline PyArray_ArrFuncs* PyDataType_GetArrFuncs(PyArray_Descr* descr) {
return descr->f;
}
#endif

#if defined _WIN32 || defined __CYGWIN__
Expand Down

0 comments on commit d83ff6b

Please sign in to comment.