|
PLearn 0.1
|
#include <PythonTableVMatrix.h>


Public Member Functions | |
| PythonTableVMatrix (PyObject *table=0) | |
| virtual string | classname () const |
| virtual OptionList & | getOptionList () const |
| virtual OptionMap & | getOptionMap () const |
| virtual RemoteMethodMap & | getRemoteMethodMap () const |
| virtual PythonTableVMatrix * | deepCopy (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 PPath & | declaringFile () |
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. | |
Definition at line 47 of file PythonTableVMatrix.h.
typedef RowBufferedVMatrix PLearn::PythonTableVMatrix::inherited [private] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 49 of file PythonTableVMatrix.h.
| PLearn::PythonTableVMatrix::PythonTableVMatrix | ( | PyObject * | table = 0 | ) |
Definition at line 53 of file PythonTableVMatrix.cc.
:the_table(table) { }
| string PLearn::PythonTableVMatrix::_classname_ | ( | ) | [static] |
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.
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_().
{
inherited::build();
build_();
}

| 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>();
}
}


| 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.
{
declareOption(ol, "table", &PythonTableVMatrix::the_table,
OptionBase::buildoption,
"underlying table");
inherited::declareOptions(ol);
}

| 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.
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);
}

| 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!");
}

Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 63 of file PythonTableVMatrix.h.
| PyObject* PLearn::PythonTableVMatrix::the_table |
Definition at line 54 of file PythonTableVMatrix.h.
Referenced by build_(), declareOptions(), and getNewRow().
1.7.4