14 #ifndef _PyDataSource_H
15 #define _PyDataSource_H
51 void checkRank ( boost::python::numeric::array array );
73 void static extractVector ( boost::python::numeric::array array,
74 std::vector<double> & col );
79 template <
typename T >
80 void static copy_direct ( boost::python::numeric::array array,
81 std::vector<double > & col );
93 unsigned int rows()
const;
96 const std::string &
getTitle ()
const;
98 void setTitle(
const std::string & title);
102 void setName(
const std::string & name);
105 const std::vector<std::string> &
getLabels()
const;
108 const std::vector<double> &
getColumn(
const std::string & name)
const;
114 const std::vector<double> & col);
118 const std::vector<double> & col);
123 boost::python::numeric::array array );
128 boost::python::numeric::array array);
131 int addColumn(
const std::string & label,
132 const std::vector<double> & col );
140 int addColumn(
const std::string & label,
141 boost::python::numeric::array array );
148 bool hasColumn(
const std::string & name)
const;
161 boost::python::numeric::array
167 boost::python::numeric::array
173 const std::vector < double > &
v,
174 const std::vector < intptr_t > &
shape );
180 boost::python::numeric::array array );
186 boost::python::numeric::array array );
192 const std::vector < double > & array );
196 void addRow (
const std::vector < double > & array );
210 const char *
what()
const throw() {
230 #endif // _PyDataSource_H
unsigned int columns() const
void replaceColumn(const std::string &, const std::vector< double > &col)
Replace a column by its label.
void setTitle(const std::string &title)
const std::vector< std::string > & getLabels() const
Get the column names.
std::string registerNTuple()
Register this DataSource, returning a unique name.
void clear()
Clear the data elements of the DataSource.
PyDataSource()
Default constructor wraps an ordinary NTuple.
void addRow(const std::vector< double > &array)
Adds a row to the DataSource.
static PyDataSource * getCurrentDataSource()
Returns a new PyDataSource that wraps the current DataSource in the DataSourceController.
unsigned int rows() const
std::vector< intptr_t > shape(numeric::array arr)
const std::string & getTitle() const
The title of the DataSource.
static void extractVector(boost::python::numeric::array array, std::vector< double > &col)
Extracts a vector from the numarray object.
boost::python::numeric::array columnAsNumArray(const std::string &label) const
Return a column from the DataSource as a numarray object, indexing by column label.
void append(const DataSource *source)
Adds all the rows of source to the DataArray.
DataSource * m_dataSource
The actual DataSource object.
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.
const std::vector< double > & getColumn(const std::string &name) const
Get a column as a tuple of floats by column name.
void checkRank(boost::python::numeric::array array)
Checks the rank of the array.
This class is the public interface to a DataSource object that the user sees as the DataArray object ...
void setName(const std::string &name)
Set the name of the DataSource.
void saveColumn(const std::string &label, const std::vector< double > &v, const std::vector< intptr_t > &shape)
Replaces or add column vector.
const char * what() const
const DataSource & dataSource() const
Return a reference to the underlying DataSource.
StopIteration(const std::string &what)
bool hasColumn(const std::string &name) const
Return true if column with label name exists in DataSource.
std::string m_type
The type of data source.
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...
int addColumn(const std::string &label, const std::vector< double > &col)
Add a column to an NTuple or ListTuple.
Base class for DataSource.