I'm trying to create a 2x2 numpy array of python objects:
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
int main()
{
Py_Initialize();
boost::python::numpy::initialize();
boost::python::tuple shape = boost::python::make_tuple(2, 2);
boost::python::object obj;
boost::python::numpy::dtype dt = boost::python::numpy::dtype(obj);
boost::python::numpy::ndarray array = boost::python::numpy::empty(shape, dt);
std::cout << "Datatype is: " << boost::python::extract<char const *> boost::python::str(array.get_dtype())) << std::endl;
}
But the output is "Datatype is: float64" rather than a python object type.
What am I doing wrong?
I suspect I'm misusing the dtype constructor.