PLearn 0.1
Static Public Member Functions
PLearn::ConvertFromPyObject< Vec > Struct Template Reference

***///*** More...

#include <PythonObjectWrapper.h>

List of all members.

Static Public Member Functions

static Vec convert (PyObject *, bool print_traceback)
static void convert (PyObject *pyobj, Vec &result, bool print_traceback)

Detailed Description

template<>
struct PLearn::ConvertFromPyObject< Vec >

***///***

Definition at line 367 of file PythonObjectWrapper.h.


Member Function Documentation

Vec PLearn::ConvertFromPyObject< Vec >::convert ( PyObject *  pyobj,
bool  print_traceback 
) [static]

Definition at line 254 of file PythonObjectWrapper.cc.

{
    Vec v;
    convert(pyobj, v, print_traceback);
    return v;
}
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);
}

Here is the call graph for this function:


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines