diff --git a/Core/Tools/inc/IHistogram.h b/Core/Tools/inc/IHistogram.h index 9d050a731f285e0ac679d68d46e1a957177c124e..4f67677998741e303cfc2647134797a7fc3e904a 100644 --- a/Core/Tools/inc/IHistogram.h +++ b/Core/Tools/inc/IHistogram.h @@ -36,7 +36,7 @@ class Histogram2D; class BA_CORE_API_ IHistogram { public: - enum DataType {INTEGRAL, AVERAGE, ERROR, NENTRIES}; + enum class DataType {INTEGRAL, AVERAGE, ERROR, NENTRIES}; IHistogram(); IHistogram(const IHistogram &other); @@ -167,7 +167,7 @@ public: #ifdef BORNAGAIN_PYTHON //! Returns numpy array with bin content (accumulated values) - PyObject *getArray(DataType dataType = INTEGRAL) const; + PyObject *getArray(DataType dataType = DataType::INTEGRAL) const; #endif //! Reset histogram content (axes remains) @@ -179,7 +179,7 @@ public: static IHistogram *createFrom(const std::string &filename); //! creates new OutputData with histogram's shape and put there values corresponding to DataType - OutputData<double> *createOutputData(DataType dataType = INTEGRAL) const; + OutputData<double> *createOutputData(DataType dataType = DataType::INTEGRAL) const; //! Returns true if objects a) have same dimensions b) bin boundaries of axes coincide bool hasSameShape(const IHistogram& other) const; diff --git a/Core/Tools/src/Histogram1D.cpp b/Core/Tools/src/Histogram1D.cpp index c175ad08ebf3942f0bed7ec663444a2ce3e15046..54ebaf478c39e02f2d86eda85678b3061e17d692 100644 --- a/Core/Tools/src/Histogram1D.cpp +++ b/Core/Tools/src/Histogram1D.cpp @@ -65,12 +65,12 @@ std::vector<double> Histogram1D::getBinCenters() const std::vector<double> Histogram1D::getBinValues() const { - return IHistogram::getDataVector(IHistogram::INTEGRAL); + return IHistogram::getDataVector(IHistogram::DataType::INTEGRAL); } std::vector<double> Histogram1D::getBinErrors() const { - return IHistogram::getDataVector(IHistogram::ERROR); + return IHistogram::getDataVector(IHistogram::DataType::ERROR); } PyObject *Histogram1D::getBinCentersNumpy() const diff --git a/Core/Tools/src/IHistogram.cpp b/Core/Tools/src/IHistogram.cpp index 82a6b4136ee8b9ddc9fe88456877b85d816bf21f..a0bc8ab792d0e8c8ba86d8ff2f680adc71539f2f 100644 --- a/Core/Tools/src/IHistogram.cpp +++ b/Core/Tools/src/IHistogram.cpp @@ -299,17 +299,17 @@ void IHistogram::init_from_data(const OutputData<double> &source) //! returns data of requested type for globalbin number double IHistogram::getBinData(size_t globalbin, IHistogram::DataType dataType) const { - if(dataType == INTEGRAL) { + if(dataType == DataType::INTEGRAL) { return getBinContent(globalbin); - } else if(dataType == AVERAGE) { + } else if(dataType == DataType::AVERAGE) { return getBinAverage(globalbin); - } else if(dataType == ERROR) { + } else if(dataType == DataType::ERROR) { return getBinError(globalbin); - } else if(dataType == NENTRIES) { + } else if(dataType == DataType::NENTRIES) { return getBinNumberOfEntries(globalbin); } else { std::ostringstream message; - message << "IHistogram::getBinData() -> Error. Unknown data type " << dataType << "."; + message << "IHistogram::getBinData() -> Error. Unknown data type."; throw LogicErrorException(message.str()); } } diff --git a/Tests/UnitTests/TestCore/Histogram1DTest.h b/Tests/UnitTests/TestCore/Histogram1DTest.h index 985e3f90d363575a3f3d273d228a13ad7e026f45..cb18b62fdc6603674b8031ba167a4b78ea81830a 100644 --- a/Tests/UnitTests/TestCore/Histogram1DTest.h +++ b/Tests/UnitTests/TestCore/Histogram1DTest.h @@ -169,7 +169,7 @@ TEST_F(Histogram1DTest, CreateOutputData) hist.fill(hist.getXaxisValue(i), 3.0); } - boost::scoped_ptr<OutputData<double> > data(hist.createOutputData(IHistogram::INTEGRAL)); + boost::scoped_ptr<OutputData<double> > data(hist.createOutputData(IHistogram::DataType::INTEGRAL)); EXPECT_EQ(1, data->getRank()); EXPECT_EQ(data->getAllocatedSize(), hist.getNbinsX()); EXPECT_EQ(data->getAxis(0)->getMin(), hist.getXmin()); @@ -178,17 +178,17 @@ TEST_F(Histogram1DTest, CreateOutputData) EXPECT_EQ(4.0, (*data)[i]); } - data.reset(hist.createOutputData(IHistogram::AVERAGE)); + data.reset(hist.createOutputData(IHistogram::DataType::AVERAGE)); for(size_t i=0; i<data->getAllocatedSize(); ++i) { EXPECT_EQ(2.0, (*data)[i]); } - data.reset(hist.createOutputData(IHistogram::ERROR)); + data.reset(hist.createOutputData(IHistogram::DataType::ERROR)); for(size_t i=0; i<data->getAllocatedSize(); ++i) { EXPECT_EQ(1.0, (*data)[i]); } - data.reset(hist.createOutputData(IHistogram::NENTRIES)); + data.reset(hist.createOutputData(IHistogram::DataType::NENTRIES)); for(size_t i=0; i<data->getAllocatedSize(); ++i) { EXPECT_EQ(2.0, (*data)[i]); } diff --git a/Tests/UnitTests/TestCore/Histogram2DTest.h b/Tests/UnitTests/TestCore/Histogram2DTest.h index 78c5f8aa73bb971b8abda609b429b836469dab6d..66b606dc170122b3978fcd001a451459dda7f035 100644 --- a/Tests/UnitTests/TestCore/Histogram2DTest.h +++ b/Tests/UnitTests/TestCore/Histogram2DTest.h @@ -398,7 +398,7 @@ TEST_F(Histogram2DTest, CreateOutputData) } } - boost::scoped_ptr<OutputData<double> > data(hist.createOutputData(IHistogram::INTEGRAL)); + boost::scoped_ptr<OutputData<double> > data(hist.createOutputData(IHistogram::DataType::INTEGRAL)); EXPECT_EQ(2, data->getRank()); EXPECT_EQ(data->getAllocatedSize(), hist.getTotalNumberOfBins()); EXPECT_EQ(data->getAxis(0)->getMin(), hist.getXmin()); @@ -409,17 +409,17 @@ TEST_F(Histogram2DTest, CreateOutputData) EXPECT_EQ(double(i), (*data)[i]); } - data.reset(hist.createOutputData(IHistogram::AVERAGE)); + data.reset(hist.createOutputData(IHistogram::DataType::AVERAGE)); for(size_t i=0; i<data->getAllocatedSize(); ++i) { EXPECT_EQ(double(i), (*data)[i]); } - data.reset(hist.createOutputData(IHistogram::ERROR)); + data.reset(hist.createOutputData(IHistogram::DataType::ERROR)); for(size_t i=0; i<data->getAllocatedSize(); ++i) { EXPECT_EQ(0.0, (*data)[i]); } - data.reset(hist.createOutputData(IHistogram::NENTRIES)); + data.reset(hist.createOutputData(IHistogram::DataType::NENTRIES)); for(size_t i=0; i<data->getAllocatedSize(); ++i) { EXPECT_EQ(1.0, (*data)[i]); }