|
PLearn 0.1
|
***///*** More...
#include <PythonObjectWrapper.h>
Static Public Member Functions | |
| static Vec | convert (PyObject *, bool print_traceback) |
| static void | convert (PyObject *pyobj, Vec &result, bool print_traceback) |
***///***
Definition at line 367 of file PythonObjectWrapper.h.
| Vec PLearn::ConvertFromPyObject< Vec >::convert | ( | PyObject * | pyobj, |
| bool | print_traceback | ||
| ) | [static] |
Definition at line 254 of file PythonObjectWrapper.cc.
| void PLearn::ConvertFromPyObject< Vec >::convert | ( | PyObject * | pyobj, |
| Vec & | result, | ||
| bool | print_traceback | ||
| ) | [static] |
Definition at line 227 of file PythonObjectWrapper.cc.
References PLearn::TVec< T >::copyFrom(), PL_NPY_REAL, PLASSERT, PLearn::PLPythonConversionError(), and PLearn::TVec< T >::resize().
{
PLASSERT( pyobj );
PyObject* pyarr0= PyArray_CheckFromAny(pyobj, NULL,
1, 1, NPY_CARRAY_RO, Py_None);
if(!pyarr0)
{
Py_XDECREF(pyarr0);
PLPythonConversionError("ConvertFromPyObject<Vec>", pyobj,
print_traceback);
}
PyObject* pyarr=
PyArray_CastToType(reinterpret_cast<PyArrayObject*>(pyarr0),
PyArray_DescrFromType(PL_NPY_REAL), 0);
Py_XDECREF(pyarr0);
if(!pyarr)
{
Py_XDECREF(pyarr);
PLPythonConversionError("ConvertFromPyObject<Vec>", pyobj,
print_traceback);
}
v.resize(PyArray_DIM(pyarr,0));
v.copyFrom((real*)(PyArray_DATA(pyarr)), PyArray_DIM(pyarr,0));
Py_XDECREF(pyarr);
}

1.7.4