Search code examples
c++pythonboostnumpyboost-python

Opposite of boost::python::extract<obj>


I am working with the boost Python and NumPy API. I know on the C++ side of things, in the boost python namespace, we have the following ability to extract elements from numpy.ndarray by using a command like

float value = bp::extract<float>(someArray[someIndex]);

Now my question is, does there exist some command that does the opposite?

e.g.

someArray[someIndex] = bp::put<float>(value);

Solution

  • http://www.boost.org/doc/libs/1_50_0/libs/python/doc/v2/to_python_converter.html only. and your example should be

    float value = bp::extract<float>(someArray[someindex]);