This class is the public interface to a DataSource object that the user sees as the DataArray object from Python. More...
#include <PyDataSource.h>
Classes | |
class | StopIteration |
Public Member Functions | |
int | addColumn (const std::string &label, const std::vector< double > &col) |
Add a column to an NTuple or ListTuple. | |
int | addColumn (const std::string &label, boost::python::numeric::array array) |
Add a column to a NumArrayTuple. | |
void | addRow (const std::vector< double > &array) |
Adds a row to the DataSource. | |
void | append (const DataSource *source) |
Adds all the rows of source to the DataArray. | |
void | append (const PyDataSource *source) |
Adds all the rows of source to the DataArray. | |
void | clear () |
Clear the data elements of the DataSource. | |
boost::python::numeric::array | columnAsNumArray (const std::string &label) const |
Return a column from the DataSource as a numarray object, indexing by column label. | |
boost::python::numeric::array | columnAsNumArray (unsigned int index) const |
Return a column from the DataSource as a numarray object, indexing by column number. | |
unsigned int | columns () const |
const DataSource & | dataSource () const |
Return a reference to the underlying DataSource. | |
const std::vector< double > & | getColumn (const std::string &name) const |
Get a column as a tuple of floats by column name. | |
const std::vector< double > & | getColumn (unsigned int index) const |
Get a column as a tuple of floats by column index. | |
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 () | |
Default constructor wraps an ordinary NTuple. | |
PyDataSource (const std::string &dataSource) | |
Constructor taking the kind of DataSource as an argument. | |
PyDataSource (const std::string &name, DataSource *source) | |
Constructor taking an existing DataSource and its name as an argument. | |
std::string | registerNTuple () |
Register this DataSource, returning a unique name. | |
void | registerNTuple (const std::string &name) |
Register this DataSource by a chosen name. | |
void | replaceColumn (const std::string &, const std::vector< double > &col) |
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 &, boost::python::numeric::array array) |
Replace a column by its label. | |
void | replaceColumn (unsigned int index, boost::python::numeric::array array) |
Replace a column by its index. | |
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 (const std::string &label, boost::python::numeric::array array) |
Replace or add a column from a numarray object, indexing by column label. | |
void | saveColumnFromNumArray (unsigned int index, 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 | |
template<typename T > | |
static void | copy_direct (boost::python::numeric::array array, std::vector< double > &col) |
Copies and converts to double, if needed, data of type T from array to fill the std::vector col. | |
static void | extractVector (boost::python::numeric::array array, std::vector< double > &col) |
Extracts a vector from the numarray object. | |
static PyDataSource * | getCurrentDataSource () |
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 | |
DataSource * | m_dataSource |
The actual DataSource object. | |
std::string | m_type |
The type of data source. |
This class is the public interface to a DataSource object that the user sees as the DataArray object from Python.
Definition at line 43 of file PyDataSource.h.
PyDataSource | ( | ) |
Default constructor wraps an ordinary NTuple.
Definition at line 404 of file PyDataSource.cxx.
Referenced by PyDataSource::getCurrentDataSource().
PyDataSource | ( | const std::string & | dataSource | ) |
Constructor taking the kind of DataSource as an argument.
Definition at line 420 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 410 of file PyDataSource.cxx.
~PyDataSource | ( | ) | [virtual] |
Definition at line 440 of file PyDataSource.cxx.
References PyDataSource::m_dataSource.
int addColumn | ( | const std::string & | label, |
const std::vector< double > & | col | ||
) |
Add a column to an NTuple or ListTuple.
Definition at line 675 of file PyDataSource.cxx.
References ListTuple::addColumn(), NTuple::addColumn(), DataSource::columns(), PyDataSource::m_dataSource, and PyDataSource::m_type.
Referenced by PyDataSource::saveColumn(), PyDataSource::saveColumnFrom(), and PyDataSource::saveColumnFromNumArray().
int addColumn | ( | const std::string & | label, |
boost::python::numeric::array | array | ||
) |
Add a column to a NumArrayTuple.
Definition at line 691 of file PyDataSource.cxx.
References NumArrayTuple::addColumn(), PyDataSource::m_dataSource, and PyDataSource::m_type.
void addRow | ( | const std::vector< double > & | array | ) |
Adds a row to the DataSource.
Definition at line 963 of file PyDataSource.cxx.
References PyApp::lock(), PyDataSource::m_dataSource, and PyApp::unlock().
void append | ( | const DataSource * | source | ) |
Adds all the rows of source to the DataArray.
Definition at line 978 of file PyDataSource.cxx.
References PyApp::lock(), PyDataSource::m_dataSource, and PyApp::unlock().
Referenced by PyDataSource::append().
void append | ( | const PyDataSource * | source | ) |
Adds all the rows of source to the DataArray.
Definition at line 986 of file PyDataSource.cxx.
References PyDataSource::append(), PyDataSource::dataSource(), and PyDataSource::m_dataSource.
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 785 of file PyDataSource.cxx.
References hippodraw::Axes::convert(), PyDataSource::m_type, and num_util::rank().
Referenced by PyDataSource::saveColumnFromNumArray().
void clear | ( | ) |
Clear the data elements of the DataSource.
Definition at line 706 of file PyDataSource.cxx.
References DataSource::clear(), and PyDataSource::m_dataSource.
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 728 of file PyDataSource.cxx.
References DataSource::getColumn(), NumArrayTuple::getNumArray(), PyDataSource::m_dataSource, PyDataSource::m_type, num_util::makeNum(), and num_util::shape().
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 760 of file PyDataSource.cxx.
References PyDataSource::columns(), DataSource::getColumn(), NumArrayTuple::getNumArray(), PyDataSource::m_dataSource, PyDataSource::m_type, num_util::makeNum(), and num_util::shape().
unsigned int columns | ( | ) | const |
Definition at line 571 of file PyDataSource.cxx.
References DataSource::columns(), and PyDataSource::m_dataSource.
Referenced by PyDataSource::columnAsNumArray(), and PyDataSource::saveColumnFromNumArray().
void copy_direct | ( | boost::python::numeric::array | array, |
std::vector< double > & | col | ||
) | [static] |
Copies and converts to double, if needed, data of type T from array to fill the std::vector col.
Definition at line 448 of file PyDataSource.cxx.
References num_util::data(), num_util::size(), and hippodraw::Axes::T.
const DataSource& dataSource | ( | ) | const [inline] |
Return a reference to the underlying DataSource.
Definition at line 89 of file PyDataSource.h.
References PyDataSource::m_dataSource.
Referenced by PyDataSource::append(), PyDataRep::PyDataRep(), QtCut::QtCut(), and QtDisplay::QtDisplay().
void extractVector | ( | boost::python::numeric::array | array, |
std::vector< double > & | col | ||
) | [static] |
Extracts a vector from the numarray object.
Extracts a vector from the numarray object array and fills the vector col. If array is contiguous, copies the data directly, otherwise copies the data element by element.
Definition at line 458 of file PyDataSource.cxx.
References num_util::iscontiguous(), num_util::rank(), num_util::size(), num_util::type(), and num_util::type2string().
Referenced by PyDataSource::saveColumnFromNumArray().
const std::vector< double > & getColumn | ( | const std::string & | name | ) | const |
Get a column as a tuple of floats by column name.
Definition at line 596 of file PyDataSource.cxx.
References DataSource::getColumn(), and PyDataSource::m_dataSource.
const std::vector< double > & getColumn | ( | unsigned int | index | ) | const |
Get a column as a tuple of floats by column index.
Definition at line 601 of file PyDataSource.cxx.
References DataSource::getColumn(), and PyDataSource::m_dataSource.
PyDataSource * getCurrentDataSource | ( | ) | [static] |
Returns a new PyDataSource that wraps the current DataSource in the DataSourceController.
Definition at line 527 of file PyDataSource.cxx.
References DataSourceController::instance(), and PyDataSource::PyDataSource().
const std::vector< std::string > & getLabels | ( | ) | const |
Get the column names.
Definition at line 591 of file PyDataSource.cxx.
References DataSource::getLabels(), and PyDataSource::m_dataSource.
Referenced by PyDataSource::hasColumn().
const std::string & getTitle | ( | ) | const |
The title of the DataSource.
Definition at line 579 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, and DataSource::title().
bool hasColumn | ( | const std::string & | name | ) | const |
Return true if column with label name exists in DataSource.
Definition at line 710 of file PyDataSource.cxx.
References PyDataSource::getLabels().
Referenced by PyDataSource::saveColumn(), PyDataSource::saveColumnFrom(), and PyDataSource::saveColumnFromNumArray().
std::string registerNTuple | ( | ) |
Register this DataSource, returning a unique name.
Definition at line 721 of file PyDataSource.cxx.
References DataSourceController::instance(), PyDataSource::m_dataSource, and DataSourceController::registerNTuple().
void registerNTuple | ( | const std::string & | name | ) |
Register this DataSource by a chosen name.
Definition at line 715 of file PyDataSource.cxx.
References DataSourceController::instance(), PyDataSource::m_dataSource, DataSourceController::registerNTuple(), and DataSource::setName().
void replaceColumn | ( | const std::string & | label, |
const std::vector< double > & | col | ||
) |
Replace a column by its label.
Definition at line 607 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, PyDataSource::m_type, and ListTuple::replaceColumn().
Referenced by PyDataSource::replaceColumn(), PyDataSource::saveColumn(), PyDataSource::saveColumnFrom(), and PyDataSource::saveColumnFromNumArray().
void replaceColumn | ( | unsigned int | index, |
const std::vector< double > & | col | ||
) |
Replace a column by its index.
Definition at line 626 of file PyDataSource.cxx.
References hippodraw::Axes::convert(), DataSource::getLabels(), PyDataSource::m_dataSource, and PyDataSource::replaceColumn().
void replaceColumn | ( | const std::string & | label, |
boost::python::numeric::array | array | ||
) |
Replace a column by its label.
Definition at line 641 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, PyDataSource::m_type, and NumArrayTuple::replaceColumn().
void replaceColumn | ( | unsigned int | index, |
boost::python::numeric::array | array | ||
) |
Replace a column by its index.
Definition at line 659 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, PyDataSource::m_type, and NumArrayTuple::replaceColumn().
unsigned int rows | ( | ) | const |
Definition at line 575 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, and DataSource::rows().
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 801 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 950 of file PyDataSource.cxx.
References PyDataSource::addColumn(), PyDataSource::hasColumn(), PyDataSource::m_dataSource, and PyDataSource::replaceColumn().
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 814 of file PyDataSource.cxx.
References ListTuple::addColumn(), PyDataSource::addColumn(), NTuple::addColumn(), PyDataSource::checkRank(), PyDataSource::extractVector(), PyDataSource::hasColumn(), PyApp::lock(), PyDataSource::m_dataSource, PyDataSource::m_type, ListTuple::replaceColumn(), PyDataSource::replaceColumn(), DataSource::replaceColumn(), PyDataSource::saveColumn(), num_util::shape(), and PyApp::unlock().
Referenced by QtCut::QtCut().
void saveColumnFromNumArray | ( | unsigned int | index, |
boost::python::numeric::array | array | ||
) |
Replace or add a column from a numarray object, indexing by column label.
Definition at line 895 of file PyDataSource.cxx.
References PyDataSource::checkRank(), PyDataSource::columns(), hippodraw::Axes::convert(), PyDataSource::extractVector(), PyDataSource::m_dataSource, PyDataSource::m_type, ListTuple::replaceColumn(), PyDataSource::replaceColumn(), NTuple::replaceColumn(), and num_util::shape().
void setName | ( | const std::string & | name | ) |
Set the name of the DataSource.
Definition at line 587 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, and DataSource::setName().
void setTitle | ( | const std::string & | title | ) |
Definition at line 583 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, and DataSource::setTitle().
DataSource* m_dataSource [private] |
The actual DataSource object.
Definition at line 224 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 221 of file PyDataSource.h.
Referenced by PyDataSource::addColumn(), PyDataSource::checkRank(), PyDataSource::columnAsNumArray(), PyDataSource::replaceColumn(), and PyDataSource::saveColumnFromNumArray().