Skip to content
Snippets Groups Projects
Commit c537b618 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Access to AxisDouble vector and changes in intensitydata unittest

parent 1bb8425c
No related branches found
No related tags found
No related merge requests found
......@@ -222,6 +222,15 @@ void register_AxisBin_class(){
, getSize_function_type(&::AxisBin::getSize)
, default_getSize_function_type(&AxisBin_wrapper::default_getSize) );
}
{ //::AxisBin::getVector
typedef ::std::vector< double > ( ::AxisBin::*getVector_function_type )( ) const;
AxisBin_exposer.def(
"getVector"
, getVector_function_type( &::AxisBin::getVector ) );
}
{ //::AxisBin::initBins
......
......@@ -202,6 +202,15 @@ void register_AxisDouble_class(){
, getUpperBoundIndex_function_type( &::AxisDouble::getUpperBoundIndex )
, ( bp::arg("value") ) );
}
{ //::AxisDouble::getVector
typedef ::std::vector< double > ( ::AxisDouble::*getVector_function_type )( ) const;
AxisDouble_exposer.def(
"getVector"
, getVector_function_type( &::AxisDouble::getVector ) );
}
{ //::AxisDouble::initElements
......
......@@ -57,6 +57,10 @@ public:
// //! find the bin that contains the given value
// Bin1D findMatchingBin(double value) const;
//! returns vector containing the bin limits
std::vector<double> getVector() const { return m_value_vector; }
protected:
virtual bool equals(const IAxis& other) const;
private:
......
......@@ -69,6 +69,9 @@ public:
//! find the index that corresponds to the given upper bound (index is inclusive)
size_t getUpperBoundIndex(double value) const;
//! returns vector containing the axis points
std::vector<double> getVector() const { return m_sample_vector; }
protected:
virtual bool equals(const IAxis& other) const;
......
......@@ -3,6 +3,7 @@
import sys
import os
import unittest
import numpy
sys.path.append(os.path.abspath(
os.path.join(os.path.split(__file__)[0],
......@@ -59,6 +60,17 @@ class IntensityDataTest(unittest.TestCase):
self.assertEqual(0.0, data.getAxis(1).getMin())
self.assertEqual(2.0, data.getAxis(1).getMax())
self.assertEqual(11, len(data.getAxis(0).getVector()))
def test_numpy_array(self):
data = IntensityData()
data.addAxis("axis0", 10, 0.0, 10.0)
data.addAxis("axis1", 20, 0.0, 20.0)
data.setAllTo(1)
arr = data.getArray()
self.assertEqual( (10,20), data.getArray().shape)
self.assertEqual( (data.totalSum()), numpy.sum(data.getArray()) )
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment