numpy.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020-2022 INRIA
3  */
4 
5 #include "eigenpy/numpy.hpp"
6 
7 namespace eigenpy {
8 void import_numpy() {
9  if (_import_array() < 0) {
10  PyErr_Print();
11  PyErr_SetString(PyExc_ImportError,
12  "numpy.core.multiarray failed to import");
13  }
14 }
15 
16 int PyArray_TypeNum(PyTypeObject* type) {
17  PyArray_Descr* descr =
18  PyArray_DescrFromTypeObject(reinterpret_cast<PyObject*>(type));
19  if (descr == NULL) {
20  return NPY_NOTYPE;
21  }
22  return descr->type_num;
23 }
24 
25 #if defined _WIN32 || defined __CYGWIN__
26 
27 bool call_PyArray_Check(PyObject* py_obj) { return PyArray_Check(py_obj); }
28 
29 PyObject* call_PyArray_SimpleNew(int nd, npy_intp* shape, int np_type) {
30  return PyArray_SimpleNew(nd, shape, np_type);
31 }
32 
33 PyObject* call_PyArray_New(PyTypeObject* py_type_ptr, int nd, npy_intp* shape,
34  int np_type, void* data_ptr, int options) {
35  return PyArray_New(py_type_ptr, nd, shape, np_type, NULL, data_ptr, 0,
36  options, NULL);
37 }
38 
39 PyObject* call_PyArray_New(PyTypeObject* py_type_ptr, int nd, npy_intp* shape,
40  int np_type, npy_intp* strides, void* data_ptr,
41  int options) {
42  return PyArray_New(py_type_ptr, nd, shape, np_type, strides, data_ptr, 0,
43  options, NULL);
44 }
45 
46 int call_PyArray_ObjectType(PyObject* obj, int val) {
47  return PyArray_ObjectType(obj, val);
48 }
49 
50 PyTypeObject* getPyArrayType() { return &PyArray_Type; }
51 
52 PyArray_Descr* call_PyArray_DescrFromType(int typenum) {
53  return PyArray_DescrFromType(typenum);
54 }
55 
56 void call_PyArray_InitArrFuncs(PyArray_ArrFuncs* funcs) {
57  PyArray_InitArrFuncs(funcs);
58 }
59 
60 int call_PyArray_RegisterDataType(PyArray_Descr* dtype) {
61  return PyArray_RegisterDataType(dtype);
62 }
63 
64 PyArray_Descr* call_PyArray_MinScalarType(PyArrayObject* arr) {
65  return PyArray_MinScalarType(arr);
66 }
67 
68 int call_PyArray_RegisterCanCast(PyArray_Descr* descr, int totype,
69  NPY_SCALARKIND scalar) {
70  return PyArray_RegisterCanCast(descr, totype, scalar);
71 }
72 
73 int call_PyArray_RegisterCastFunc(PyArray_Descr* descr, int totype,
74  PyArray_VectorUnaryFunc* castfunc) {
75  return PyArray_RegisterCastFunc(descr, totype, castfunc);
76 }
77 
78 #endif
79 } // namespace eigenpy
eigenpy::getPyArrayType
PyTypeObject * getPyArrayType()
Definition: numpy.hpp:249
eigenpy::PyArray_TypeNum
int EIGENPY_DLLAPI PyArray_TypeNum(PyTypeObject *type)
Definition: numpy.cpp:16
eigenpy::call_PyArray_InitArrFuncs
void call_PyArray_InitArrFuncs(PyArray_ArrFuncs *funcs)
Definition: numpy.hpp:255
eigenpy::call_PyArray_DescrFromType
PyArray_Descr * call_PyArray_DescrFromType(int typenum)
Definition: numpy.hpp:251
eigenpy::call_PyArray_RegisterDataType
int call_PyArray_RegisterDataType(PyArray_DescrProto *dtype)
Definition: numpy.hpp:259
eigenpy::import_numpy
void EIGENPY_DLLAPI import_numpy()
Definition: numpy.cpp:8
eigenpy::call_PyArray_Check
bool call_PyArray_Check(PyObject *py_obj)
Definition: numpy.hpp:222
eigenpy
Definition: alignment.hpp:14
eigenpy::call_PyArray_SimpleNew
PyObject * call_PyArray_SimpleNew(int nd, npy_intp *shape, int np_type)
Definition: numpy.hpp:226
eigenpy::call_PyArray_ObjectType
int call_PyArray_ObjectType(PyObject *obj, int val)
Definition: numpy.hpp:245
eigenpy::call_PyArray_RegisterCanCast
int call_PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, NPY_SCALARKIND scalar)
Definition: numpy.hpp:267
numpy.hpp
eigenpy::call_PyArray_MinScalarType
PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject *arr)
Definition: numpy.hpp:263
eigenpy::call_PyArray_New
PyObject * call_PyArray_New(PyTypeObject *py_type_ptr, int nd, npy_intp *shape, int np_type, void *data_ptr, int options)
Definition: numpy.hpp:230
eigenpy::call_PyArray_RegisterCastFunc
int call_PyArray_RegisterCastFunc(PyArray_Descr *descr, int totype, PyArray_VectorUnaryFunc *castfunc)
Definition: numpy.hpp:272


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Apr 26 2024 02:17:35