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

#include <PythonObjectWrapper.h>

List of all members.

Static Public Member Functions

static double convert (PyObject *, bool print_traceback)

Detailed Description

template<>
struct PLearn::ConvertFromPyObject< double >

Definition at line 302 of file PythonObjectWrapper.h.


Member Function Documentation

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

Definition at line 110 of file PythonObjectWrapper.cc.

References PLASSERT, and PLearn::PLPythonConversionError().

{
    PLASSERT( pyobj );
    if(PyFloat_Check(pyobj))
        return PyFloat_AS_DOUBLE(pyobj);
    if(PyLong_Check(pyobj))
        return PyLong_AsDouble(pyobj);
    if(PyInt_Check(pyobj))
        return (double)PyInt_AS_LONG(pyobj);
    if(PyArray_CheckScalar(pyobj))
    {
        double ret= 0.;
        PyArray_CastScalarToCtype(pyobj, &ret, PyArray_DescrFromType(NPY_DOUBLE));
        return ret;
    }
    PLPythonConversionError("ConvertFromPyObject<double>", pyobj,
                            print_traceback);
    return 0;//shut up compiler
}

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