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. More... | |
| int | addColumn (const std::string &label, boost::python::numeric::array array) |
| Add a column to a NumArrayTuple. More... | |
| void | addRow (const std::vector< double > &array) |
| Adds a row to the DataSource. More... | |
| void | append (const DataSource *source) |
| Adds all the rows of source to the DataArray. More... | |
| void | append (const PyDataSource *source) |
| Adds all the rows of source to the DataArray. More... | |
| void | clear () |
| Clear the data elements of the DataSource. More... | |
| boost::python::numeric::array | columnAsNumArray (const std::string &label) const |
| Return a column from the DataSource as a numarray object, indexing by column label. More... | |
| boost::python::numeric::array | columnAsNumArray (unsigned int index) const |
| Return a column from the DataSource as a numarray object, indexing by column number. More... | |
| unsigned int | columns () const |
| const DataSource & | dataSource () const |
| Return a reference to the underlying DataSource. More... | |
| const std::vector< double > & | getColumn (const std::string &name) const |
| Get a column as a tuple of floats by column name. More... | |
| const std::vector< double > & | getColumn (unsigned int index) const |
| Get a column as a tuple of floats by column index. More... | |
| const std::vector< std::string > & | getLabels () const |
| Get the column names. More... | |
| const std::string & | getTitle () const |
| The title of the DataSource. More... | |
| bool | hasColumn (const std::string &name) const |
| Return true if column with label name exists in DataSource. More... | |
| PyDataSource () | |
| Default constructor wraps an ordinary NTuple. More... | |
| PyDataSource (const std::string &dataSource) | |
| Constructor taking the kind of DataSource as an argument. More... | |
| PyDataSource (const std::string &name, DataSource *source) | |
| Constructor taking an existing DataSource and its name as an argument. More... | |
| std::string | registerNTuple () |
| Register this DataSource, returning a unique name. More... | |
| void | registerNTuple (const std::string &name) |
| Register this DataSource by a chosen name. More... | |
| void | replaceColumn (const std::string &, const std::vector< double > &col) |
| Replace a column by its label. More... | |
| void | replaceColumn (unsigned int index, const std::vector< double > &col) |
| Replace a column by its index. More... | |
| void | replaceColumn (const std::string &, boost::python::numeric::array array) |
| Replace a column by its label. More... | |
| void | replaceColumn (unsigned int index, boost::python::numeric::array array) |
| Replace a column by its index. More... | |
| 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. More... | |
| void | saveColumnFrom (const std::string &label, const std::vector< double > &array) |
| Replace or add a column from vector. More... | |
| void | saveColumnFromNumArray (const std::string &label, boost::python::numeric::array array) |
| Replace or add a column from a numarray object, indexing by column label. More... | |
| void | saveColumnFromNumArray (unsigned int index, boost::python::numeric::array array) |
| Replace or add a column from a numarray object, indexing by column label. More... | |
| void | setName (const std::string &name) |
| Set the name of the DataSource. More... | |
| 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. More... | |
| static void | extractVector (boost::python::numeric::array array, std::vector< double > &col) |
| Extracts a vector from the numarray object. More... | |
| static PyDataSource * | getCurrentDataSource () |
| Returns a new PyDataSource that wraps the current DataSource in the DataSourceController. More... | |
Private Member Functions | |
| void | checkRank (boost::python::numeric::array array) |
| Checks the rank of the array. More... | |
Private Attributes | |
| DataSource * | m_dataSource |
| The actual DataSource object. More... | |
| std::string | m_type |
| The type of data source. More... | |
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 397 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 413 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 403 of file PyDataSource.cxx.
|
virtual |
Definition at line 433 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 678 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 694 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 966 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 981 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 989 of file PyDataSource.cxx.
References PyDataSource::append(), PyDataSource::dataSource(), and PyDataSource::m_dataSource.
|
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 788 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 709 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 731 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 763 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 574 of file PyDataSource.cxx.
References DataSource::columns(), and PyDataSource::m_dataSource.
Referenced by PyDataSource::columnAsNumArray(), and PyDataSource::saveColumnFromNumArray().
|
static |
Copies and converts to double, if needed, data of type T from array to fill the std::vector col.
Definition at line 441 of file PyDataSource.cxx.
References num_util::data(), num_util::size(), and hippodraw::Axes::T.
|
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().
|
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 456 of file PyDataSource.cxx.
References i, 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 599 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 604 of file PyDataSource.cxx.
References DataSource::getColumn(), and PyDataSource::m_dataSource.
|
static |
Returns a new PyDataSource that wraps the current DataSource in the DataSourceController.
Definition at line 530 of file PyDataSource.cxx.
References DataSourceController::instance(), and PyDataSource::PyDataSource().
| const std::vector< std::string > & getLabels | ( | ) | const |
Get the column names.
Definition at line 594 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 582 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 713 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 724 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 718 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 610 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 629 of file PyDataSource.cxx.
References hippodraw::String::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 644 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 662 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, PyDataSource::m_type, and NumArrayTuple::replaceColumn().
| unsigned int rows | ( | ) | const |
Definition at line 578 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 804 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 953 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 817 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 898 of file PyDataSource.cxx.
References PyDataSource::checkRank(), PyDataSource::columns(), hippodraw::String::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 590 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, and DataSource::setName().
| void setTitle | ( | const std::string & | title | ) |
Definition at line 586 of file PyDataSource.cxx.
References PyDataSource::m_dataSource, and DataSource::setTitle().
|
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().
|
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().