PyDataSource Class Reference

#include <PyDataSource.h>

Collaboration diagram for PyDataSource:

Collaboration graph
DataSourceObservable
[legend]
List of all members.

Detailed Description

This class is the public interface to a DataSource object that the user sees as the DataArray object from Python.

Author:
J. Chiang <jchiang@slac.stanford.edu>

Definition at line 43 of file PyDataSource.h.

Public Member Functions

int addColumn (const std::string &label, boost::python::numeric::array array)
 Add a column to a NumArrayTuple.
int addColumn (const std::string &label, const std::vector< double > &col)
 Add a column to an NTuple or ListTuple.
void addRow (const std::vector< double > &array)
 Adds a row to the DataSource.
void append (const PyDataSource *source)
 Adds all the rows of source to the DataArray.
void append (const DataSource *source)
 Adds all the rows of source to the DataArray.
void clear ()
 Clear the data elements of the DataSource.
boost::python::numeric::array columnAsNumArray (unsigned int index) const
 Return a column from the DataSource as a numarray object, indexing by column number.
boost::python::numeric::array columnAsNumArray (const std::string &label) const
 Return a column from the DataSource as a numarray object, indexing by column label.
unsigned int columns () const
const DataSourcedataSource () const
 Return a reference to the underlying DataSource.
const std::vector< double > & getColumn (unsigned int index) const
 Get a column as a tuple of floats by column index.
const std::vector< double > & getColumn (const std::string &name) const
 Get a column as a tuple of floats by column name.
const std::vector< std::string > & getLabels () const
 Get the column names.
const std::string & getTitle () const
 The title of the DataSource.
bool hasColumn (const std::string &name) const
 Return true if column with label name exists in DataSource.
 PyDataSource (const std::string &name, DataSource *source)
 Constructor taking an existing DataSource and its name as an argument.
 PyDataSource (const std::string &dataSource)
 Constructor taking the kind of DataSource as an argument.
 PyDataSource ()
 Default constructor wraps an ordinary NTuple.
void registerNTuple (const std::string &name)
 Register this DataSource by a chosen name.
std::string registerNTuple ()
 Register this DataSource, returning a unique name.
void replaceColumn (unsigned int index, boost::python::numeric::array array)
 Replace a column by its index.
void replaceColumn (const std::string &, boost::python::numeric::array array)
 Replace a column by its label.
void replaceColumn (unsigned int index, const std::vector< double > &col)
 Replace a column by its index.
void replaceColumn (const std::string &, const std::vector< double > &col)
 Replace a column by its label.
unsigned int rows () const
void saveColumn (const std::string &label, const std::vector< double > &v, const std::vector< intptr_t > &shape)
 Replaces or add column vector.
void saveColumnFrom (const std::string &label, const std::vector< double > &array)
 Replace or add a column from vector.
void saveColumnFromNumArray (unsigned int index, boost::python::numeric::array array)
 Replace or add a column from a numarray object, indexing by column label.
void saveColumnFromNumArray (const std::string &label, boost::python::numeric::array array)
 Replace or add a column from a numarray object, indexing by column label.
void setName (const std::string &name)
 Set the name of the DataSource.
void setTitle (const std::string &title)
virtual ~PyDataSource ()

Static Public Member Functions

static PyDataSourcegetCurrentDataSource ()
 Returns a new PyDataSource that wraps the current DataSource in the DataSourceController.

Private Member Functions

void checkRank (boost::python::numeric::array array)
 Checks the rank of the array.

Private Attributes

DataSourcem_dataSource
 The actual DataSource object.
std::string m_type
 The type of data source.

Classes

class  StopIteration


Constructor & Destructor Documentation

PyDataSource (  ) 

Default constructor wraps an ordinary NTuple.

Definition at line 398 of file PyDataSource.cxx.

References PyDataSource::m_dataSource, and PyDataSource::m_type.

Referenced by PyDataSource::getCurrentDataSource().

PyDataSource ( const std::string &  dataSource  ) 

Constructor taking the kind of DataSource as an argument.

Definition at line 414 of file PyDataSource.cxx.

References PyDataSource::m_dataSource.

PyDataSource ( const std::string &  name,
DataSource source 
)

Constructor taking an existing DataSource and its name as an argument.

Definition at line 404 of file PyDataSource.cxx.

~PyDataSource (  )  [virtual]

Definition at line 434 of file PyDataSource.cxx.

References PyDataSource::m_dataSource.


Member Function Documentation

int addColumn ( const std::string &  label,
boost::python::numeric::array  array 
)

Add a column to a NumArrayTuple.

Requests:
@@ This method only works if contained DataSource is NumArrayTuple. It could accept more like saveColumnFromNumArray does.

Definition at line 605 of file PyDataSource.cxx.

References NumArrayTuple::addColumn(), PyDataSource::m_dataSource, and PyDataSource::m_type.

int addColumn ( const std::string &  label,
const std::vector< double > &  col 
)

Add a column to an NTuple or ListTuple.

Definition at line 589 of file PyDataSource.cxx.

References ListTuple::addColumn(), NTuple::addColumn(), DataSource::columns(), PyDataSource::m_dataSource, and PyDataSource::m_type.

Referenced by hippodraw::Python::export_DataArray(), PyDataSource::saveColumn(), PyDataSource::saveColumnFrom(), and PyDataSource::saveColumnFromNumArray().

void addRow ( const std::vector< double > &  array  ) 

Adds a row to the DataSource.

Definition at line 877 of file PyDataSource.cxx.

References PyApp::lock(), PyDataSource::m_dataSource, and PyApp::unlock().

Referenced by hippodraw::Python::export_DataArray().

void append ( const PyDataSource source  ) 

Adds all the rows of source to the DataArray.

Definition at line 900 of file PyDataSource.cxx.

References PyDataSource::append(), PyDataSource::dataSource(), and PyDataSource::m_dataSource.

void append ( const DataSource source  ) 

Adds all the rows of source to the DataArray.

Definition at line 892 of file PyDataSource.cxx.

References PyApp::lock(), PyDataSource::m_dataSource, and PyApp::unlock().

Referenced by PyDataSource::append(), and hippodraw::Python::export_DataArray().

void checkRank ( boost::python::numeric::array  array  )  [private]

Checks the rank of the array.

Check of the array and if the rank is greater than 1, throws a std::runtime_error.

Definition at line 699 of file PyDataSource.cxx.

References hippodraw::String::convert(), PyDataSource::m_type, and num_util::rank().

Referenced by PyDataSource::saveColumnFromNumArray().

void clear (  ) 

Clear the data elements of the DataSource.

Definition at line 620 of file PyDataSource.cxx.

References DataSource::clear(), and PyDataSource::m_dataSource.

boost::python::numeric::array columnAsNumArray ( unsigned int  index  )  const

Return a column from the DataSource as a numarray object, indexing by column number.

Definition at line 674 of file PyDataSource.cxx.

References PyDataSource::columns(), DataSource::getColumn(), NumArrayTuple::getNumArray(), PyDataSource::m_dataSource, PyDataSource::m_type, num_util::makeNum(), and num_util::shape().

boost::python::numeric::array columnAsNumArray ( const std::string &  label  )  const

Return a column from the DataSource as a numarray object, indexing by column label.

Definition at line 642 of file PyDataSource.cxx.

References DataSource::getColumn(), NumArrayTuple::getNumArray(), PyDataSource::m_dataSource, PyDataSource::m_type, num_util::makeNum(), and num_util::shape().

Referenced by hippodraw::Python::export_DataArray().

unsigned int columns (  )  const

Definition at line 485 of file PyDataSource.cxx.

References DataSource::columns(), and PyDataSource::m_dataSource.

Referenced by PyDataSource::columnAsNumArray(), hippodraw::Python::export_DataArray(), and PyDataSource::saveColumnFromNumArray().

const DataSource& dataSource (  )  const [inline]

Return a reference to the underlying DataSource.

Definition at line 74 of file PyDataSource.h.

References PyDataSource::m_dataSource.

Referenced by PyDataSource::append(), hippodraw::Python::export_DataArray(), PyDataRep::PyDataRep(), QtCut::QtCut(), and QtDisplay::QtDisplay().

const std::vector< double > & getColumn ( unsigned int  index  )  const

Get a column as a tuple of floats by column index.

Definition at line 515 of file PyDataSource.cxx.

References DataSource::getColumn(), and PyDataSource::m_dataSource.

const std::vector< double > & getColumn ( const std::string &  name  )  const

Get a column as a tuple of floats by column name.

Definition at line 510 of file PyDataSource.cxx.

References DataSource::getColumn(), and PyDataSource::m_dataSource.

Referenced by hippodraw::Python::export_DataArray().

PyDataSource * getCurrentDataSource (  )  [static]

Returns a new PyDataSource that wraps the current DataSource in the DataSourceController.

Definition at line 441 of file PyDataSource.cxx.

References DataSourceController::instance(), and PyDataSource::PyDataSource().

Referenced by hippodraw::Python::export_DataArray().

const std::vector< std::string > & getLabels (  )  const

Get the column names.

Definition at line 505 of file PyDataSource.cxx.

References DataSource::getLabels(), and PyDataSource::m_dataSource.

Referenced by hippodraw::Python::export_DataArray(), and PyDataSource::hasColumn().

const std::string & getTitle (  )  const

The title of the DataSource.

Definition at line 493 of file PyDataSource.cxx.

References PyDataSource::m_dataSource, and DataSource::title().

Referenced by hippodraw::Python::export_DataArray().

bool hasColumn ( const std::string &  name  )  const

Return true if column with label name exists in DataSource.

Definition at line 624 of file PyDataSource.cxx.

References PyDataSource::getLabels().

Referenced by hippodraw::Python::export_DataArray(), PyDataSource::saveColumn(), PyDataSource::saveColumnFrom(), and PyDataSource::saveColumnFromNumArray().

void registerNTuple ( const std::string &  name  ) 

Register this DataSource by a chosen name.

Definition at line 629 of file PyDataSource.cxx.

References DataSourceController::instance(), PyDataSource::m_dataSource, DataSourceController::registerNTuple(), and DataSource::setName().

std::string registerNTuple (  ) 

Register this DataSource, returning a unique name.

Definition at line 635 of file PyDataSource.cxx.

References DataSourceController::instance(), PyDataSource::m_dataSource, and DataSourceController::registerNTuple().

Referenced by hippodraw::Python::export_DataArray().

void replaceColumn ( unsigned int  index,
boost::python::numeric::array  array 
)

Replace a column by its index.

Definition at line 573 of file PyDataSource.cxx.

References PyDataSource::m_dataSource, PyDataSource::m_type, and NumArrayTuple::replaceColumn().

void replaceColumn ( const std::string &  ,
boost::python::numeric::array  array 
)

Replace a column by its label.

Definition at line 555 of file PyDataSource.cxx.

References PyDataSource::m_dataSource, PyDataSource::m_type, and NumArrayTuple::replaceColumn().

void replaceColumn ( unsigned int  index,
const std::vector< double > &  col 
)

Replace a column by its index.

Definition at line 540 of file PyDataSource.cxx.

References hippodraw::String::convert(), DataSource::getLabels(), PyDataSource::m_dataSource, and PyDataSource::replaceColumn().

void replaceColumn ( const std::string &  ,
const std::vector< double > &  col 
)

Replace a column by its label.

Definition at line 521 of file PyDataSource.cxx.

References PyDataSource::m_dataSource, PyDataSource::m_type, and ListTuple::replaceColumn().

Referenced by hippodraw::Python::export_DataArray(), PyDataSource::replaceColumn(), PyDataSource::saveColumn(), PyDataSource::saveColumnFrom(), and PyDataSource::saveColumnFromNumArray().

unsigned int rows (  )  const

Definition at line 489 of file PyDataSource.cxx.

References PyDataSource::m_dataSource, and DataSource::rows().

Referenced by hippodraw::Python::export_DataArray().

void saveColumn ( const std::string &  label,
const std::vector< double > &  v,
const std::vector< intptr_t > &  shape 
)

Replaces or add column vector.

Definition at line 715 of file PyDataSource.cxx.

References PyDataSource::addColumn(), PyDataSource::hasColumn(), PyDataSource::m_dataSource, and PyDataSource::replaceColumn().

Referenced by PyDataSource::saveColumnFromNumArray().

void saveColumnFrom ( const std::string &  label,
const std::vector< double > &  array 
)

Replace or add a column from vector.

Definition at line 864 of file PyDataSource.cxx.

References PyDataSource::addColumn(), PyDataSource::hasColumn(), PyDataSource::m_dataSource, and PyDataSource::replaceColumn().

Referenced by hippodraw::Python::export_DataArray().

void saveColumnFromNumArray ( unsigned int  index,
boost::python::numeric::array  array 
)

Replace or add a column from a numarray object, indexing by column label.

Bug:
@@@ Should allow any type of DataSource if rank is acceptable.

Definition at line 809 of file PyDataSource.cxx.

References PyDataSource::checkRank(), PyDataSource::columns(), hippodraw::String::convert(), extractVector(), PyDataSource::m_dataSource, PyDataSource::m_type, ListTuple::replaceColumn(), NTuple::replaceColumn(), PyDataSource::replaceColumn(), and num_util::shape().

void saveColumnFromNumArray ( const std::string &  label,
boost::python::numeric::array  array 
)

Replace or add a column from a numarray object, indexing by column label.

Definition at line 728 of file PyDataSource.cxx.

References NTuple::addColumn(), ListTuple::addColumn(), PyDataSource::addColumn(), PyDataSource::checkRank(), extractVector(), PyDataSource::hasColumn(), PyApp::lock(), PyDataSource::m_dataSource, PyDataSource::m_type, DataSource::replaceColumn(), ListTuple::replaceColumn(), PyDataSource::replaceColumn(), PyDataSource::saveColumn(), num_util::shape(), and PyApp::unlock().

Referenced by hippodraw::Python::export_DataArray(), and QtCut::QtCut().

void setName ( const std::string &  name  ) 

Set the name of the DataSource.

Definition at line 501 of file PyDataSource.cxx.

References PyDataSource::m_dataSource, and DataSource::setName().

Referenced by hippodraw::Python::export_DataArray().

void setTitle ( const std::string &  title  ) 

Definition at line 497 of file PyDataSource.cxx.

References PyDataSource::m_dataSource, and DataSource::setTitle().

Referenced by hippodraw::Python::export_DataArray().


Member Data Documentation

DataSource* m_dataSource [private]

The actual DataSource object.

Definition at line 209 of file PyDataSource.h.

Referenced by PyDataSource::addColumn(), PyDataSource::addRow(), PyDataSource::append(), PyDataSource::clear(), PyDataSource::columnAsNumArray(), PyDataSource::columns(), PyDataSource::dataSource(), PyDataSource::getColumn(), PyDataSource::getLabels(), PyDataSource::getTitle(), PyDataSource::PyDataSource(), PyDataSource::registerNTuple(), PyDataSource::replaceColumn(), PyDataSource::rows(), PyDataSource::saveColumn(), PyDataSource::saveColumnFrom(), PyDataSource::saveColumnFromNumArray(), PyDataSource::setName(), PyDataSource::setTitle(), and PyDataSource::~PyDataSource().

std::string m_type [private]

The type of data source.

Definition at line 206 of file PyDataSource.h.

Referenced by PyDataSource::addColumn(), PyDataSource::checkRank(), PyDataSource::columnAsNumArray(), PyDataSource::PyDataSource(), PyDataSource::replaceColumn(), and PyDataSource::saveColumnFromNumArray().


The documentation for this class was generated from the following files:
Generated for HippoDraw Class Library by doxygen