numpy.cpp 822 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * Copyright 2020 INRIA
 */

#include "eigenpy/numpy.hpp"

namespace eigenpy
{
  void import_numpy()
  {
    if(_import_array() < 0)
    {
      PyErr_Print();
      PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
    }
  }
Justin Carpentier's avatar
Justin Carpentier committed
17
18
19

#if defined _WIN32 || defined __CYGWIN__

Justin Carpentier's avatar
Justin Carpentier committed
20
  PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type)
Justin Carpentier's avatar
Justin Carpentier committed
21
  {
Justin Carpentier's avatar
Justin Carpentier committed
22
    return PyArray_SimpleNew(nd,shape,np_type);
Justin Carpentier's avatar
Justin Carpentier committed
23
24
  }

25
  PyObject* call_PyArray_New(PyTypeObject * py_type_ptr, int nd, npy_intp * shape, int np_type, void * data_ptr, int options)
Justin Carpentier's avatar
Justin Carpentier committed
26
  {
27
    return PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL);
Justin Carpentier's avatar
Justin Carpentier committed
28
29
30
31
32
33
34
  }
  
  int call_PyArray_ObjectType(PyObject * obj, int val)
  {
    return PyArray_ObjectType(obj,val);
  }

35
36
  PyTypeObject getPyArrayType() { return PyArray_Type; }

Justin Carpentier's avatar
Justin Carpentier committed
37
#endif
38
}