PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Private Types | Private Member Functions
PLearn::PythonTableVMatrix Class Reference

#include <PythonTableVMatrix.h>

Inheritance diagram for PLearn::PythonTableVMatrix:
Inheritance graph
[legend]
Collaboration diagram for PLearn::PythonTableVMatrix:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PythonTableVMatrix (PyObject *table=0)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual PythonTableVMatrixdeepCopy (CopiesMap &copies) const
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.

Static Public Member Functions

static string _classname_ ()
 RowBufferedVMatrix.
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Public Attributes

PyObject * the_table

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

virtual void getNewRow (int i, const Vec &v) const
 Fill the vector 'v' with the content of the i-th row.

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declare this class' options.

Private Types

typedef RowBufferedVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 47 of file PythonTableVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 49 of file PythonTableVMatrix.h.


Constructor & Destructor Documentation

PLearn::PythonTableVMatrix::PythonTableVMatrix ( PyObject *  table = 0)

Definition at line 53 of file PythonTableVMatrix.cc.

    :the_table(table)
{
}

Member Function Documentation

string PLearn::PythonTableVMatrix::_classname_ ( ) [static]

RowBufferedVMatrix.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 51 of file PythonTableVMatrix.cc.

OptionList & PLearn::PythonTableVMatrix::_getOptionList_ ( ) [static]

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 51 of file PythonTableVMatrix.cc.

RemoteMethodMap & PLearn::PythonTableVMatrix::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 51 of file PythonTableVMatrix.cc.

bool PLearn::PythonTableVMatrix::_isa_ ( const Object o) [static]

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 51 of file PythonTableVMatrix.cc.

Object * PLearn::PythonTableVMatrix::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 51 of file PythonTableVMatrix.cc.

StaticInitializer PythonTableVMatrix::_static_initializer_ & PLearn::PythonTableVMatrix::_static_initialize_ ( ) [static]

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 51 of file PythonTableVMatrix.cc.

void PLearn::PythonTableVMatrix::build ( ) [virtual]

Simply calls inherited::build() then build_().

Reimplemented from PLearn::VMatrix.

Definition at line 155 of file PythonTableVMatrix.cc.

References PLearn::VMatrix::build(), and build_().

Here is the call graph for this function:

void PLearn::PythonTableVMatrix::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::VMatrix.

Definition at line 85 of file PythonTableVMatrix.cc.

References PLearn::PythonObjectWrapper::as(), PLearn::VMatrix::declareFieldNames(), PLearn::VMatrix::inputsize_, PLearn::VMatrix::length_, PLERROR, PLearn::VMatrix::targetsize_, the_table, PLearn::VMatrix::weightsize_, and PLearn::VMatrix::width_.

Referenced by build().

{
    if(!the_table) return;
    // Casting away const is okay, PyObject_CallMethod does not modify its
    // arguments.
    PyObject* pywidth= PyObject_CallMethod(the_table, const_cast<char*>("width"), NULL);
    if(!pywidth)
    {
        if (PyErr_Occurred()) PyErr_Print();
        PLERROR("in PythonTableVMatrix::build_ : "
                "call to underlying table's 'width' failed.");
    }
    width_= PythonObjectWrapper(pywidth);
    Py_DECREF(pywidth);
    PyObject* pylength= PyObject_CallMethod(the_table, const_cast<char*>("length"), NULL);
    if(!pylength)
    {
        if (PyErr_Occurred()) PyErr_Print();
        PLERROR("in PythonTableVMatrix::build_ : "
                "call to underlying table's 'length' failed.");
    }
    length_= PythonObjectWrapper(pylength);
    Py_DECREF(pylength);
    PyObject* pyfieldnames= PyObject_GetAttrString(the_table, "fieldnames");
    if(!pyfieldnames)
    {
        if (PyErr_Occurred()) PyErr_Print();
        PLERROR("in PythonTableVMatrix::build_ : "
                "access to underlying table's 'fieldnames' failed.");
    }
    declareFieldNames(PythonObjectWrapper(pyfieldnames));
    Py_DECREF(pyfieldnames);

    if(PyObject_HasAttrString(the_table, "inputsize"))
    {
        PyObject* inpsz= PyObject_GetAttrString(the_table, "inputsize");
        if(!inpsz)
        {
            if (PyErr_Occurred()) PyErr_Print();
            PLERROR("in PythonTableVMatrix::build_ : "
                    "access to underlying table's 'inputsize' failed.");
        }
        inputsize_= PythonObjectWrapper(inpsz).as<int>();
    }
    if(PyObject_HasAttrString(the_table, "targetsize"))
    {
        PyObject* targsz= PyObject_GetAttrString(the_table, "targetsize");
        if(!targsz)
        {
            if (PyErr_Occurred()) PyErr_Print();
            PLERROR("in PythonTableVMatrix::build_ : "
                    "access to underlying table's 'targetsize' failed.");
        }
        targetsize_= PythonObjectWrapper(targsz).as<int>();
    }
    if(PyObject_HasAttrString(the_table, "weightsize"))
    {
        PyObject* wgtsz= PyObject_GetAttrString(the_table, "weightsize");
        if(!wgtsz)
        {
            if (PyErr_Occurred()) PyErr_Print();
            PLERROR("in PythonTableVMatrix::build_ : "
                    "access to underlying table's 'weightsize' failed.");
        }
        weightsize_= PythonObjectWrapper(wgtsz).as<int>();
    }


}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::PythonTableVMatrix::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 51 of file PythonTableVMatrix.cc.

void PLearn::PythonTableVMatrix::declareOptions ( OptionList ol) [static, protected]

Declare this class' options.

Reimplemented from PLearn::VMatrix.

Definition at line 75 of file PythonTableVMatrix.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), and the_table.

Here is the call graph for this function:

static const PPath& PLearn::PythonTableVMatrix::declaringFile ( ) [inline, static]

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 63 of file PythonTableVMatrix.h.

:
    //#####  Protected Options  ###############################################
PythonTableVMatrix * PLearn::PythonTableVMatrix::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 51 of file PythonTableVMatrix.cc.

void PLearn::PythonTableVMatrix::getNewRow ( int  i,
const Vec v 
) const [protected, virtual]

Fill the vector 'v' with the content of the i-th row.

'v' is assumed to be the right size.

Implements PLearn::RowBufferedVMatrix.

Definition at line 58 of file PythonTableVMatrix.cc.

References PLearn::PythonObjectWrapper::as(), PLASSERT, PLERROR, and the_table.

{
    PLASSERT(the_table);
    // Casting away const is okay here, PyObject_CallMethod does not
    // modify its arguments. XXX
    PyObject* row= PyObject_CallMethod(the_table, const_cast<char*>("getRow"),
                                       const_cast<char*>("i"), i);
    if(!row)
    {
        if (PyErr_Occurred()) PyErr_Print();
        PLERROR("in PythonTableVMatrix::getNewRow : "
                "call to underlying table's 'getRow' failed.");
    }
    v << PythonObjectWrapper(row).as<Vec>();
    Py_DECREF(row);
}

Here is the call graph for this function:

OptionList & PLearn::PythonTableVMatrix::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 51 of file PythonTableVMatrix.cc.

OptionMap & PLearn::PythonTableVMatrix::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 51 of file PythonTableVMatrix.cc.

RemoteMethodMap & PLearn::PythonTableVMatrix::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 51 of file PythonTableVMatrix.cc.

void PLearn::PythonTableVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 161 of file PythonTableVMatrix.cc.

References PLearn::RowBufferedVMatrix::makeDeepCopyFromShallowCopy(), and PLERROR.

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // deepCopyField(trainvec, copies);

    PLERROR("PythonTableVMatrix::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 63 of file PythonTableVMatrix.h.

Definition at line 54 of file PythonTableVMatrix.h.

Referenced by build_(), declareOptions(), and getNewRow().


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