From a9fe33e6e583a7118c0d1c54eed3d23f5ca297b9 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (l)" <j.wuttke@fz-juelich.de> Date: Sat, 19 Nov 2016 16:06:42 +0100 Subject: [PATCH] NumpyUtil -> ArrayUtils, Util -> SysUtil, hand-correct includes --- Core/Export/ExportToPython.cpp | 4 +-- Core/Export/PythonFormatting.cpp | 4 +-- Core/Fitting/FitSuitePrintObserver.cpp | 4 +-- Core/InputOutput/OutputDataIOHelper.cpp | 8 ++--- Core/InputOutput/TiffHandler.cpp | 7 ++-- .../{NumpyUtils.cpp => ArrayUtils.cpp} | 20 ++++++++--- .../Instrument/{NumpyUtils.h => ArrayUtils.h} | 16 ++++++--- Core/Instrument/Histogram1D.cpp | 8 ++--- Core/Instrument/Histogram2D.cpp | 6 ++-- Core/Parametrization/ParameterPool.cpp | 4 +-- Core/Simulation/Simulation.cpp | 4 +-- Core/Tools/{Utils.cpp => SysUtils.cpp} | 22 +++--------- Core/Tools/{Utils.h => SysUtils.h} | 8 ++--- Fit/Kernel/FitKernelImpl.cpp | 2 +- Fit/Kernel/MinimizerCatalogue.cpp | 2 +- Fit/Kernel/MinimizerOptions.cpp | 4 +-- Fit/Kernel/MinimizerResultsHelper.cpp | 12 +++---- Fit/Kernel/MinimizerUtils.cpp | 14 ++++---- Fit/Kernel/MinimizerUtils.h | 4 +-- Fit/Parameters/FitParameterSet.cpp | 2 +- .../GSLLevenbergMarquardtMinimizer.cpp | 2 +- Fit/RootAdapter/GSLMultiMinimizer.cpp | 2 +- Fit/Utils/StringUtils.cpp | 12 +++---- Fit/Utils/StringUtils.h | 2 +- .../Views/InfoWidgets/GroupInfoBox.cpp | 2 +- GUI/coregui/Views/WelcomeView.cpp | 4 +-- GUI/coregui/mainwindow/actionmanager.cpp | 6 ++-- GUI/coregui/mainwindow/mainwindow.cpp | 2 +- GUI/coregui/utils/hostosinfo.h | 2 +- GUI/coregui/utils/qstringutils.cpp | 6 ++-- GUI/coregui/utils/qstringutils.h | 2 +- Tests/Functional/Core/CoreTest.cpp | 1 - Tests/Functional/GUI/GUITest.cpp | 1 - .../GUITranslationTest/GUITranslationTest.cpp | 2 +- .../Functional/PyCore/export/PyExportTest.cpp | 1 - .../PyCore/persistence/PyPersistenceTest.cpp | 6 ++-- .../StandardSimulationsRegistry.cpp | 4 +-- Tests/UnitTests/Core/0/FixedBinAxisTest.h | 8 ++--- Tests/UnitTests/Core/0/Histogram1DTest.h | 2 +- Tests/UnitTests/Core/0/VariableBinAxisTest.h | 14 ++++---- .../UnitTests/Core/2/SpecularSimulationTest.h | 34 +++++++++---------- Tests/UnitTests/Core/3/RegionOfInterestTest.h | 4 +-- .../UnitTests/Core/3/SphericalDetectorTest.h | 4 +-- Tests/UnitTests/Core/4/ChiSquaredModuleTest.h | 8 ++--- Tests/UnitTests/Core/5/DistributionsTest.h | 2 +- .../Core/5/ParameterDistributionTest.h | 4 +-- Tests/UnitTests/Core/5/ParameterPoolTest.h | 12 +++---- Tests/UnitTests/Core/6/LLDataTest.h | 8 ++--- Tests/UnitTests/Fit/0/StringUtilsTest.h | 2 +- 49 files changed, 155 insertions(+), 159 deletions(-) rename Core/Instrument/{NumpyUtils.cpp => ArrayUtils.cpp} (73%) rename Core/Instrument/{NumpyUtils.h => ArrayUtils.h} (80%) rename Core/Tools/{Utils.cpp => SysUtils.cpp} (66%) rename Core/Tools/{Utils.h => SysUtils.h} (81%) diff --git a/Core/Export/ExportToPython.cpp b/Core/Export/ExportToPython.cpp index c5cecb513dc..38b04d05baf 100644 --- a/Core/Export/ExportToPython.cpp +++ b/Core/Export/ExportToPython.cpp @@ -38,7 +38,7 @@ #include "ResolutionFunction2DGaussian.h" #include "SampleLabelHandler.h" #include "SphericalDetector.h" -#include "Utils.h" +#include "StringUtils.h" #include "RegionOfInterest.h" #include <iomanip> #include <set> @@ -799,7 +799,7 @@ std::string ExportToPython::definePlot(const GISASSimulation* simulation) const for (size_t i=0; i<instrument.getDetectorDimension(); ++ i) entries.push_back( printDegrees(instrument.getDetectorAxis(i).getMin()) + ", " + printDegrees(instrument.getDetectorAxis(i).getMax()) ); - result << StringUtil::join( entries, ", " ) << "]) \n"; + result << StringUtils::join( entries, ", " ) << "]) \n"; result << " plt.colorbar(im)\n" " plt.show()\n\n\n"; diff --git a/Core/Export/PythonFormatting.cpp b/Core/Export/PythonFormatting.cpp index 23d4547b6e4..cecb9f1bc85 100644 --- a/Core/Export/PythonFormatting.cpp +++ b/Core/Export/PythonFormatting.cpp @@ -31,7 +31,7 @@ #include "RealParameter.h" #include "Rectangle.h" #include "MathConstants.h" -#include "Utils.h" +#include "StringUtils.h" #include "Units.h" #include "IDetector2D.h" #include <iomanip> @@ -226,7 +226,7 @@ std::string argumentList(const IParameterized* ip) std::vector<std::string> args; for(const auto* par: ip->getParameterPool()->getParameters()) args.push_back( valueTimesUnit(par) ); - return StringUtil::join( args, ", " ); + return StringUtils::join( args, ", " ); } } // namespace PythonFormatting diff --git a/Core/Fitting/FitSuitePrintObserver.cpp b/Core/Fitting/FitSuitePrintObserver.cpp index 78ec3843125..b2d4956f034 100644 --- a/Core/Fitting/FitSuitePrintObserver.cpp +++ b/Core/Fitting/FitSuitePrintObserver.cpp @@ -37,9 +37,9 @@ void FitSuitePrintObserver::update(FitSuite* fit_suite) } if(m_strategy_has_changed) { - std::cout << MinimizerUtil::sectionString() << "\n"; + std::cout << MinimizerUtils::sectionString() << "\n"; std::cout << (*m_fit_suite->fitStrategies()->currentStrategy()) << std::endl; - std::cout << MinimizerUtil::sectionString() << "\n"; + std::cout << MinimizerUtils::sectionString() << "\n"; } printIterationHeader(); diff --git a/Core/InputOutput/OutputDataIOHelper.cpp b/Core/InputOutput/OutputDataIOHelper.cpp index 235b99129a5..366d5fe191e 100644 --- a/Core/InputOutput/OutputDataIOHelper.cpp +++ b/Core/InputOutput/OutputDataIOHelper.cpp @@ -18,7 +18,7 @@ #include "CustomBinAxis.h" #include "FileUtils.h" #include "OutputData.h" -#include "Utils.h" +#include "StringUtils.h" #include <iterator> #include <iostream> @@ -123,7 +123,7 @@ IAxis *OutputDataIOHelper::createAxis(std::istream& input_stream) IAxis *OutputDataIOHelper::createFixedBinAxis(std::string line) { std::vector<std::string> to_replace = {",", "\"", "(", ")"}; - StringUtil::replaceItemsFromString(line, to_replace, " "); + StringUtils::replaceItemsFromString(line, to_replace, " "); std::string type, name; size_t nbins(0); @@ -161,7 +161,7 @@ IAxis *OutputDataIOHelper::createFixedBinAxis(std::string line) IAxis *OutputDataIOHelper::createVariableBinAxis(std::string line) { std::vector<std::string> to_replace = {",", "\"", "(", ")", "[", "]"}; - StringUtil::replaceItemsFromString(line, to_replace, " "); + StringUtils::replaceItemsFromString(line, to_replace, " "); std::string type, name; size_t nbins(0); @@ -208,7 +208,7 @@ std::vector<double> OutputDataIOHelper::parse_doubles(const std::string& str) std::istringstream iss(str); OutputDataIOHelper::readLineOfDoubles(result, iss); if( result.empty() ) { - std::cout << "StringUtil::parse_doubles -> " + std::cout << "StringUtils::parse_doubles -> " "Warning! No parsed values in 1d vector of doubles." << std::endl; std::cout << "Line '" << str << "'" << std::endl; } diff --git a/Core/InputOutput/TiffHandler.cpp b/Core/InputOutput/TiffHandler.cpp index 8d55a78b547..8083c9a5c86 100644 --- a/Core/InputOutput/TiffHandler.cpp +++ b/Core/InputOutput/TiffHandler.cpp @@ -17,7 +17,7 @@ #include "TiffHandler.h" #include "BornAgainNamespace.h" -#include "Utils.h" +#include "SysUtils.h" namespace { size_t supported_bitPerSample = 32; @@ -29,8 +29,7 @@ TiffHandler::TiffHandler() : m_tiff(0) , m_width(0) , m_height(0) -{ -} +{} TiffHandler::~TiffHandler() { @@ -143,7 +142,7 @@ void TiffHandler::write_header() { assert(m_tiff); TIFFSetField(m_tiff, TIFFTAG_ARTIST, "BornAgain.IOFactory"); - TIFFSetField(m_tiff, TIFFTAG_DATETIME, Util::getCurrentDateAndTime().c_str()); + TIFFSetField(m_tiff, TIFFTAG_DATETIME, SysUtils::getCurrentDateAndTime().c_str()); TIFFSetField(m_tiff, TIFFTAG_IMAGEDESCRIPTION, "Image converted from BornAgain intensity file."); TIFFSetField(m_tiff, TIFFTAG_SOFTWARE, "BornAgain"); diff --git a/Core/Instrument/NumpyUtils.cpp b/Core/Instrument/ArrayUtils.cpp similarity index 73% rename from Core/Instrument/NumpyUtils.cpp rename to Core/Instrument/ArrayUtils.cpp index 8d2eb5744ec..efe9c77106b 100644 --- a/Core/Instrument/NumpyUtils.cpp +++ b/Core/Instrument/ArrayUtils.cpp @@ -13,17 +13,27 @@ // // ************************************************************************** // -#ifdef BORNAGAIN_PYTHON - -#include "NumpyUtils.h" #include "Exceptions.h" +#include "ArrayUtils.h" + +std::pair<size_t, size_t> ArrayUtils::getShape(const std::vector<std::vector<double>>& data) +{ + size_t nrows = data.size(); + size_t ncols(0); + if(nrows) ncols = data[0].size(); + for(size_t row=0; row<nrows; row++) + if(data[row].size() != ncols) + throw std::runtime_error("Util::getShape() -> Error. " + "Number of elements is different from row to row."); + return std::make_pair(nrows, ncols); +} -#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#ifdef BORNAGAIN_PYTHON #define PY_ARRAY_UNIQUE_SYMBOL BORNAGAIN_PYTHONAPI_ARRAY #define NO_IMPORT_ARRAY #include <numpy/arrayobject.h> -PyObject* Util::createNumpyArray(const std::vector<double>& data) +PyObject* ArrayUtils::createNumpyArray(const std::vector<double>& data) { const size_t ndim(1); npy_int ndim_numpy = ndim; diff --git a/Core/Instrument/NumpyUtils.h b/Core/Instrument/ArrayUtils.h similarity index 80% rename from Core/Instrument/NumpyUtils.h rename to Core/Instrument/ArrayUtils.h index d05778d5b3e..6a99eb706b6 100644 --- a/Core/Instrument/NumpyUtils.h +++ b/Core/Instrument/ArrayUtils.h @@ -16,17 +16,23 @@ #ifndef NUMPYUTILS_H #define NUMPYUTILS_H -#ifdef BORNAGAIN_PYTHON +#include <vector> +#ifdef BORNAGAIN_PYTHON #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include <Python.h> -#include <vector> +#endif // BORNAGAIN_PYTHON -namespace Util +namespace ArrayUtils { - PyObject* createNumpyArray(const std::vector<double>& data); -} + //! Returns shape nrows, ncols of 2D array. + BA_CORE_API_ std::pair<size_t, size_t> getShape(const std::vector<std::vector<double>>& data); + +#ifdef BORNAGAIN_PYTHON + PyObject* createNumpyArray(const std::vector<double>& data); #endif // BORNAGAIN_PYTHON +} + #endif // NUMPYUTILS_H diff --git a/Core/Instrument/Histogram1D.cpp b/Core/Instrument/Histogram1D.cpp index 1801a639c5a..0383e114dc7 100644 --- a/Core/Instrument/Histogram1D.cpp +++ b/Core/Instrument/Histogram1D.cpp @@ -14,7 +14,7 @@ // ************************************************************************** // #include "Histogram1D.h" -#include "NumpyUtils.h" +#include "ArrayUtils.h" #include "VariableBinAxis.h" #include <memory> @@ -71,17 +71,17 @@ std::vector<double> Histogram1D::getBinErrors() const PyObject* Histogram1D::getBinCentersNumpy() const { - return Util::createNumpyArray(getBinCenters()); + return ArrayUtils::createNumpyArray(getBinCenters()); } PyObject* Histogram1D::getBinValuesNumpy() const { - return Util::createNumpyArray(getBinValues()); + return ArrayUtils::createNumpyArray(getBinValues()); } PyObject* Histogram1D::getBinErrorsNumpy() const { - return Util::createNumpyArray(getBinErrors()); + return ArrayUtils::createNumpyArray(getBinErrors()); } #endif // BORNAGAIN_PYTHON diff --git a/Core/Instrument/Histogram2D.cpp b/Core/Instrument/Histogram2D.cpp index 3f2e88e2c16..5b80a0f4358 100644 --- a/Core/Instrument/Histogram2D.cpp +++ b/Core/Instrument/Histogram2D.cpp @@ -17,7 +17,7 @@ #include "Histogram1D.h" #include "VariableBinAxis.h" #include "BornAgainNamespace.h" -#include "Utils.h" +#include "ArrayUtils.h" #include <memory> @@ -45,7 +45,7 @@ Histogram2D::Histogram2D(const OutputData<double>& data) Histogram2D::Histogram2D(const std::vector<std::vector<double>>& data) { - auto shape = Util::getShape(data); + auto shape = ArrayUtils::getShape(data); const size_t nrows = shape.first; const size_t ncols = shape.second; @@ -138,7 +138,7 @@ void Histogram2D::setContent(const std::vector<std::vector<double> > &data) void Histogram2D::addContent(const std::vector<std::vector<double> > &data) { - auto shape = Util::getShape(data); + auto shape = ArrayUtils::getShape(data); const size_t nrows = shape.first; const size_t ncols = shape.second; diff --git a/Core/Parametrization/ParameterPool.cpp b/Core/Parametrization/ParameterPool.cpp index 451b502a03c..e5d59daf693 100644 --- a/Core/Parametrization/ParameterPool.cpp +++ b/Core/Parametrization/ParameterPool.cpp @@ -117,7 +117,7 @@ std::vector<RealParameter*> ParameterPool::getMatchedParameters(const std::strin std::vector<RealParameter*> selected_parameters; // loop over all parameters in the pool for (auto* par: m_params) - if( StringUtil::matchesPattern( par->getName(), pattern ) ) + if( StringUtils::matchesPattern( par->getName(), pattern ) ) selected_parameters.push_back(par); if( selected_parameters.empty() ) report_find_matched_parameters_error(pattern); @@ -145,7 +145,7 @@ int ParameterPool::setMatchedParametersValue(const std::string& pattern, double { int npars(0); for (auto* par: m_params) { - if( StringUtil::matchesPattern( par->getName(), pattern ) ) { + if( StringUtils::matchesPattern( par->getName(), pattern ) ) { try { par->setValue(value); npars++; diff --git a/Core/Simulation/Simulation.cpp b/Core/Simulation/Simulation.cpp index ed03f54113c..5697b4220f3 100644 --- a/Core/Simulation/Simulation.cpp +++ b/Core/Simulation/Simulation.cpp @@ -21,7 +21,7 @@ #include "ParameterPool.h" #include "ParameterSample.h" #include "SimulationElement.h" -#include "Utils.h" +#include "StringUtils.h" #include <gsl/gsl_errno.h> #include <thread> #include <iomanip> @@ -294,7 +294,7 @@ void Simulation::runSingleSimulation() throw Exceptions::RuntimeErrorException( "Simulation::runSingleSimulation() -> " "At least one simulation thread has terminated unexpectedly.\n" - "Messages: " + StringUtil::join(failure_messages, " --- ")); + "Messages: " + StringUtils::join(failure_messages, " --- ")); } normalize(batch_start, batch_end); } diff --git a/Core/Tools/Utils.cpp b/Core/Tools/SysUtils.cpp similarity index 66% rename from Core/Tools/Utils.cpp rename to Core/Tools/SysUtils.cpp index c1ebb5b0a63..059f0a963b9 100644 --- a/Core/Tools/Utils.cpp +++ b/Core/Tools/SysUtils.cpp @@ -13,7 +13,7 @@ // // ************************************************************************** // -#include "Utils.h" +#include "SysUtils.h" #include <boost/date_time/posix_time/posix_time.hpp> #include <stdexcept> @@ -22,7 +22,7 @@ #endif #endif -std::string Util::getCurrentDateAndTime() +std::string SysUtils::getCurrentDateAndTime() { using boost::posix_time::ptime; using boost::posix_time::second_clock; @@ -33,29 +33,17 @@ std::string Util::getCurrentDateAndTime() } //! enables exception throw in the case of NaN, Inf -void Util::enableFloatingPointExceptions() +void SysUtils::enableFloatingPointExceptions() { #ifdef DEBUG_FPE #ifndef _WIN32 - std::cout << "Util::EnableFloatingPointExceptions() -> " + std::cout << "SysUtils::EnableFloatingPointExceptions() -> " "Enabling floating point exception debugging\n"; feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); // feenableexcept(-1); #endif // _WIN32 #else - std::cout << "Util::EnableFloatingPointExceptions() -> " + std::cout << "SysUtils::EnableFloatingPointExceptions() -> " "Can't enable floating point exceptions. Available in debug mode only.\n"; #endif } - -std::pair<size_t, size_t> Util::getShape(const std::vector<std::vector<double>>& data) -{ - size_t nrows = data.size(); - size_t ncols(0); - if(nrows) ncols = data[0].size(); - for(size_t row=0; row<nrows; row++) - if(data[row].size() != ncols) - throw std::runtime_error("Util::getShape() -> Error. " - "Number of elements is different from row to row."); - return std::make_pair(nrows, ncols); -} diff --git a/Core/Tools/Utils.h b/Core/Tools/SysUtils.h similarity index 81% rename from Core/Tools/Utils.h rename to Core/Tools/SysUtils.h index c411afd68a3..427c5c373dd 100644 --- a/Core/Tools/Utils.h +++ b/Core/Tools/SysUtils.h @@ -19,18 +19,14 @@ #include "WinDllMacros.h" #include "StringUtils.h" #include <string> -#include <vector> -namespace Util { +namespace SysUtils { BA_CORE_API_ std::string getCurrentDateAndTime(); //! enables exception throw in the case of NaN, Inf BA_CORE_API_ void enableFloatingPointExceptions(); - //! Returns shape nrows, ncols of 2D array. - BA_CORE_API_ std::pair<size_t, size_t> getShape(const std::vector<std::vector<double>>& data); - -} // namespace Util +} // namespace SysUtils #endif // UTILS_H diff --git a/Fit/Kernel/FitKernelImpl.cpp b/Fit/Kernel/FitKernelImpl.cpp index 494d8020718..49d0b3205b0 100644 --- a/Fit/Kernel/FitKernelImpl.cpp +++ b/Fit/Kernel/FitKernelImpl.cpp @@ -89,7 +89,7 @@ std::string FitKernelImpl::reportResults() const { std::ostringstream result; result << std::endl; - result << MinimizerUtil::sectionString("FitSuite::printResults"); + result << MinimizerUtils::sectionString("FitSuite::printResults"); result << "functionCalls: " << m_objective_function.functionCalls() << " (" << m_time_interval.runTime() << " sec total)" << "\n"; result << m_minimizer->reportResults(); diff --git a/Fit/Kernel/MinimizerCatalogue.cpp b/Fit/Kernel/MinimizerCatalogue.cpp index 72f52eab63c..d92d05fdec7 100644 --- a/Fit/Kernel/MinimizerCatalogue.cpp +++ b/Fit/Kernel/MinimizerCatalogue.cpp @@ -42,7 +42,7 @@ std::string MinimizerCatalogue::toString() const for(MinimizerInfo minimizer : m_minimizers) { result << boost::format("%-15s| %-64s\n") % minimizer.name() - % MinimizerUtil::toString(minimizer.algorithmNames(), std::string(" ")); + % MinimizerUtils::toString(minimizer.algorithmNames(), std::string(" ")); } return result.str(); diff --git a/Fit/Kernel/MinimizerOptions.cpp b/Fit/Kernel/MinimizerOptions.cpp index 39330b5ffa2..c8d576bb955 100644 --- a/Fit/Kernel/MinimizerOptions.cpp +++ b/Fit/Kernel/MinimizerOptions.cpp @@ -35,7 +35,7 @@ std::string MinimizerOptions::toOptionString() const void MinimizerOptions::setOptionString(const std::string &options) { // splits multiple option string "Strategy=1;Tolerance=0.01;" - std::vector<std::string> tokens = StringUtil::split(options, delimeter); + std::vector<std::string> tokens = StringUtils::split(options, delimeter); try { for(std::string opt : tokens) if(opt.size()) @@ -54,7 +54,7 @@ void MinimizerOptions::setOptionString(const std::string &options) void MinimizerOptions::processCommand(const std::string &command) { - std::vector<std::string> tokens = StringUtil::split(command, "="); + std::vector<std::string> tokens = StringUtils::split(command, "="); if(tokens.size() != 2) throw std::runtime_error("MinimizerOptions::processOption() -> Can't parse option '"+ command+"'"); diff --git a/Fit/Kernel/MinimizerResultsHelper.cpp b/Fit/Kernel/MinimizerResultsHelper.cpp index 72ed9e021cc..2a2f1255cc6 100644 --- a/Fit/Kernel/MinimizerResultsHelper.cpp +++ b/Fit/Kernel/MinimizerResultsHelper.cpp @@ -39,7 +39,7 @@ std::string MinimizerResultsHelper::reportResults(const RootMinimizerAdapter *mi { std::ostringstream result; - result << MinimizerUtil::sectionString(); + result << MinimizerUtils::sectionString(); result << reportDescription(minimizer); result << reportOption(minimizer); result << reportStatus(minimizer); @@ -51,7 +51,7 @@ std::string MinimizerResultsHelper::reportResults(const FitParameterSet *paramet { std::ostringstream result; - result << MinimizerUtil::sectionString("FitParameters"); + result << MinimizerUtils::sectionString("FitParameters"); result << "Npar Name StartValue Limits FitValue Error" << std::endl; @@ -69,7 +69,7 @@ std::string MinimizerResultsHelper::reportResults(const FitParameterSet *paramet FitParameterSet::corr_matrix_t matrix = parameters->correlationMatrix(); if(matrix.size()) { - result << MinimizerUtil::sectionString("Correlations"); + result << MinimizerUtils::sectionString("Correlations"); for(size_t i=0; i<matrix.size(); ++i) { result << boost::format("#%-2d ") %i; for(size_t j=0; j<matrix[i].size(); ++j) { @@ -97,13 +97,13 @@ std::string MinimizerResultsHelper::reportOption(const RootMinimizerAdapter *min return std::string(); std::ostringstream result; - result << MinimizerUtil::sectionString("Options"); + result << MinimizerUtils::sectionString("Options"); for(auto option : minimizer->options()) { std::ostringstream opt; opt << std::setw(5) << std::left << option->value() << option->description(); result << reportValue(option->name(), opt.str()); } - result << MinimizerUtil::sectionString("OptionString"); + result << MinimizerUtils::sectionString("OptionString"); result << minimizer->options().toOptionString() << std::endl; return result.str(); @@ -112,7 +112,7 @@ std::string MinimizerResultsHelper::reportOption(const RootMinimizerAdapter *min std::string MinimizerResultsHelper::reportStatus(const RootMinimizerAdapter *minimizer) const { std::ostringstream result; - result << MinimizerUtil::sectionString("Status"); + result << MinimizerUtils::sectionString("Status"); auto status = minimizer->statusMap(); for(auto it : status) { diff --git a/Fit/Kernel/MinimizerUtils.cpp b/Fit/Kernel/MinimizerUtils.cpp index 479051da45a..4ee284927ca 100644 --- a/Fit/Kernel/MinimizerUtils.cpp +++ b/Fit/Kernel/MinimizerUtils.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Fit/Kernel/MinimizerUtil.cpp -//! @brief Declares namespace MinimizerUtil. +//! @brief Declares namespace MinimizerUtils. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -19,7 +19,7 @@ #include <cmath> #include <limits> -std::string MinimizerUtil::toString(const std::vector<std::string> &v, const std::string &delim) +std::string MinimizerUtils::toString(const std::vector<std::string> &v, const std::string &delim) { std::stringstream s; std::for_each(v.begin(), v.end(), [&s, &delim](const std::string &elem) {s << elem << delim; }); @@ -28,7 +28,7 @@ std::string MinimizerUtil::toString(const std::vector<std::string> &v, const std //! Returns translation of GSL error code to string. -std::map<int, std::string> MinimizerUtil::gslErrorDescriptionMap() +std::map<int, std::string> MinimizerUtils::gslErrorDescriptionMap() { std::map<int, std::string> result; @@ -69,7 +69,7 @@ std::map<int, std::string> MinimizerUtil::gslErrorDescriptionMap() return result; } -std::string MinimizerUtil::gslErrorDescription(int errorCode) +std::string MinimizerUtils::gslErrorDescription(int errorCode) { static std::map<int, std::string> errorDescription = gslErrorDescriptionMap(); @@ -80,17 +80,17 @@ std::string MinimizerUtil::gslErrorDescription(int errorCode) return std::string("Unknown error"); } -bool MinimizerUtil::numbersDiffer(double a, double b, double tol) +bool MinimizerUtils::numbersDiffer(double a, double b, double tol) { constexpr double eps = std::numeric_limits<double>::epsilon(); if (tol<1) - throw std::runtime_error("MinimizerUtil::numbersDiffer() -> Error.Not intended for tol<1"); + throw std::runtime_error("MinimizerUtils::numbersDiffer() -> Error.Not intended for tol<1"); return std::abs(a-b) > eps * std::max( tol*eps, std::abs(b) ); } //! Returns horizontal line of 80 characters length with section name in it. -std::string MinimizerUtil::sectionString(const std::string §ionName, int report_width) +std::string MinimizerUtils::sectionString(const std::string §ionName, int report_width) { std::ostringstream result; if(sectionName.empty()) { diff --git a/Fit/Kernel/MinimizerUtils.h b/Fit/Kernel/MinimizerUtils.h index 7c0d6d702fe..ed36a31a21a 100644 --- a/Fit/Kernel/MinimizerUtils.h +++ b/Fit/Kernel/MinimizerUtils.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Fit/Kernel/MinimizerUtils.h -//! @brief Declares namespace MinimizerUtil. +//! @brief Declares namespace MinimizerUtils. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -22,7 +22,7 @@ #include <map> -namespace MinimizerUtil { +namespace MinimizerUtils { BA_CORE_API_ std::string toString(const std::vector<std::string> &v, const std::string &delim = ""); diff --git a/Fit/Parameters/FitParameterSet.cpp b/Fit/Parameters/FitParameterSet.cpp index c039c35ba9b..b671134f0c7 100644 --- a/Fit/Parameters/FitParameterSet.cpp +++ b/Fit/Parameters/FitParameterSet.cpp @@ -156,7 +156,7 @@ bool FitParameterSet::valuesDifferFrom(const std::vector<double> &pars_values, d check_array_size(pars_values); for (size_t i=0; i<m_parameters.size(); ++i) - if (MinimizerUtil::numbersDiffer(m_parameters[i]->value(), pars_values[i], tol)) + if (MinimizerUtils::numbersDiffer(m_parameters[i]->value(), pars_values[i], tol)) return true; return false; } diff --git a/Fit/RootAdapter/GSLLevenbergMarquardtMinimizer.cpp b/Fit/RootAdapter/GSLLevenbergMarquardtMinimizer.cpp index aaef32a0d10..d2dd049e0cb 100644 --- a/Fit/RootAdapter/GSLLevenbergMarquardtMinimizer.cpp +++ b/Fit/RootAdapter/GSLLevenbergMarquardtMinimizer.cpp @@ -81,7 +81,7 @@ int GSLLevenbergMarquardtMinimizer::maxIterations() const std::string GSLLevenbergMarquardtMinimizer::statusToString() const { - return MinimizerUtil::gslErrorDescription(rootMinimizer()->Status()); + return MinimizerUtils::gslErrorDescription(rootMinimizer()->Status()); } std::map<std::string, std::string> GSLLevenbergMarquardtMinimizer::statusMap() const diff --git a/Fit/RootAdapter/GSLMultiMinimizer.cpp b/Fit/RootAdapter/GSLMultiMinimizer.cpp index 049b22d320c..9154717f630 100644 --- a/Fit/RootAdapter/GSLMultiMinimizer.cpp +++ b/Fit/RootAdapter/GSLMultiMinimizer.cpp @@ -57,7 +57,7 @@ int GSLMultiMinimizer::maxIterations() const std::string GSLMultiMinimizer::statusToString() const { - return MinimizerUtil::gslErrorDescription(rootMinimizer()->Status()); + return MinimizerUtils::gslErrorDescription(rootMinimizer()->Status()); } void GSLMultiMinimizer::propagateOptions() diff --git a/Fit/Utils/StringUtils.cpp b/Fit/Utils/StringUtils.cpp index 0cccab0fd47..3f25bb5e213 100644 --- a/Fit/Utils/StringUtils.cpp +++ b/Fit/Utils/StringUtils.cpp @@ -18,7 +18,7 @@ #include <boost/regex.hpp> //! Returns true if text matches pattern with wildcards '*' and '?'. -bool StringUtil::matchesPattern(const std::string& text, const std::string& wildcardPattern) +bool StringUtils::matchesPattern(const std::string& text, const std::string& wildcardPattern) { bool caseSensitive(true); @@ -50,7 +50,7 @@ bool StringUtil::matchesPattern(const std::string& text, const std::string& wild } //! Returns string right-padded with blanks. -std::string StringUtil::padRight(const std::string& name, int length) +std::string StringUtils::padRight(const std::string& name, int length) { std::string result = name; result.resize(length,' '); @@ -58,21 +58,21 @@ std::string StringUtil::padRight(const std::string& name, int length) } //! Returns token vector obtained by splitting string at delimiters. -std::vector<std::string> StringUtil::split(const std::string& text, const std::string& delimiter) +std::vector<std::string> StringUtils::split(const std::string& text, const std::string& delimiter) { std::vector<std::string> tokens; boost::split(tokens, text, boost::is_any_of(delimiter)); return tokens; } -void StringUtil::replaceItemsFromString( +void StringUtils::replaceItemsFromString( std::string& text, const std::vector<std::string>& items, const std::string& replacement) { for(size_t i=0; i<items.size(); ++i) boost::replace_all(text, items[i], replacement); } -std::string StringUtil::join(const std::vector<std::string>& joinable, const std::string& joint) +std::string StringUtils::join(const std::vector<std::string>& joinable, const std::string& joint) { std::string result; size_t n = joinable.size(); @@ -82,7 +82,7 @@ std::string StringUtil::join(const std::vector<std::string>& joinable, const std return result; } -std::string StringUtil::removeSubstring(const std::string &text, const std::string &substr) +std::string StringUtils::removeSubstring(const std::string &text, const std::string &substr) { std::string result = text; for(std::string::size_type i=result.find(substr); i!=std::string::npos; i=result.find(substr)) diff --git a/Fit/Utils/StringUtils.h b/Fit/Utils/StringUtils.h index 8431e846f57..3c93fe06a06 100644 --- a/Fit/Utils/StringUtils.h +++ b/Fit/Utils/StringUtils.h @@ -22,7 +22,7 @@ //! Utility functions to analyze or modify strings. -namespace StringUtil { +namespace StringUtils { //! Returns true if text matches pattern with wildcards '*' and '?'. BA_CORE_API_ bool matchesPattern(const std::string& text, const std::string& wildcardPattern); diff --git a/GUI/coregui/Views/InfoWidgets/GroupInfoBox.cpp b/GUI/coregui/Views/InfoWidgets/GroupInfoBox.cpp index b5fb8591bd7..95b2df59818 100644 --- a/GUI/coregui/Views/InfoWidgets/GroupInfoBox.cpp +++ b/GUI/coregui/Views/InfoWidgets/GroupInfoBox.cpp @@ -94,7 +94,7 @@ void GroupInfoBox::paintEvent(QPaintEvent*) // draw groupbox int shift(1); - if(GUI_OS_Util::HostOsInfo::isLinuxHost()) + if(GUI_OS_Utils::HostOsInfo::isLinuxHost()) shift = 3; paint.drawItemPixmap(option.rect.adjusted(0, shift, 0, 0), Qt::AlignTop | Qt::AlignRight, diff --git a/GUI/coregui/Views/WelcomeView.cpp b/GUI/coregui/Views/WelcomeView.cpp index 4624de9528c..0461bb7eae0 100644 --- a/GUI/coregui/Views/WelcomeView.cpp +++ b/GUI/coregui/Views/WelcomeView.cpp @@ -224,7 +224,7 @@ void WelcomeView::generateRecentProjectList() palette.setColor(QPalette::ButtonText,QColor(41,73,150)); slotButtons[i] = new QCommandLinkButton; - slotButtons[i]->setText(GUI_StringUtil::withTildeHomePath(file)); + slotButtons[i]->setText(GUI_StringUtils::withTildeHomePath(file)); slotButtons[i]->setFont(font); slotButtons[i]->setPalette(palette); //slotButtons[i]->setDescription("Recent description"); @@ -250,7 +250,7 @@ QString WelcomeView::getCurrentProjectFancyName() QString result("Untitled"); if(ProjectDocument *projectDocument = m_projectManager->getDocument()) { if(projectDocument->hasValidNameAndPath()) - result = GUI_StringUtil::withTildeHomePath(projectDocument->getProjectFileName()); + result = GUI_StringUtils::withTildeHomePath(projectDocument->getProjectFileName()); else result = projectDocument->getProjectName(); } diff --git a/GUI/coregui/mainwindow/actionmanager.cpp b/GUI/coregui/mainwindow/actionmanager.cpp index 7e71c13f480..54b62cb51d7 100644 --- a/GUI/coregui/mainwindow/actionmanager.cpp +++ b/GUI/coregui/mainwindow/actionmanager.cpp @@ -103,7 +103,7 @@ void ActionManager::createMenus() { m_menuBar = new QMenuBar(0); // No parent (System menu bar on Mac OS X) - if (!GUI_OS_Util::HostOsInfo::isMacHost()) + if (!GUI_OS_Utils::HostOsInfo::isMacHost()) m_mainWindow->setMenuBar(m_menuBar); // File Menu @@ -151,9 +151,9 @@ void ActionManager::aboutToShowRecentProjects() bool hasRecentProjects = false; foreach(QString file, m_mainWindow->projectManager()->getRecentProjects() ) { hasRecentProjects = true; - qDebug() << file << QDir::toNativeSeparators(GUI_StringUtil::withTildeHomePath(file)); + qDebug() << file << QDir::toNativeSeparators(GUI_StringUtils::withTildeHomePath(file)); QAction *action = m_recentProjectsMenu->addAction( - QDir::toNativeSeparators(GUI_StringUtil::withTildeHomePath(file))); + QDir::toNativeSeparators(GUI_StringUtils::withTildeHomePath(file))); action->setData(qVariantFromValue(file)); connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(openRecentProject())); diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp index 57dd8374891..b936d10c653 100644 --- a/GUI/coregui/mainwindow/mainwindow.cpp +++ b/GUI/coregui/mainwindow/mainwindow.cpp @@ -223,7 +223,7 @@ void MainWindow::initApplication() QCoreApplication::setApplicationVersion(GUIHelpers::getBornAgainVersionString()); QCoreApplication::setOrganizationName(QLatin1String(Constants::APPLICATION_NAME)); - if (!GUI_OS_Util::HostOsInfo::isMacHost()) + if (!GUI_OS_Utils::HostOsInfo::isMacHost()) QApplication::setWindowIcon(QIcon(":/images/BornAgain.ico")); QString baseName = QApplication::style()->objectName(); diff --git a/GUI/coregui/utils/hostosinfo.h b/GUI/coregui/utils/hostosinfo.h index 9d826528baa..e1d0cf2e046 100644 --- a/GUI/coregui/utils/hostosinfo.h +++ b/GUI/coregui/utils/hostosinfo.h @@ -20,7 +20,7 @@ #include "WinDllMacros.h" #include <QString> -namespace GUI_OS_Util { +namespace GUI_OS_Utils { #define QTC_WIN_EXE_SUFFIX ".exe" diff --git a/GUI/coregui/utils/qstringutils.cpp b/GUI/coregui/utils/qstringutils.cpp index ecbff903fda..1cf1a1f500a 100644 --- a/GUI/coregui/utils/qstringutils.cpp +++ b/GUI/coregui/utils/qstringutils.cpp @@ -18,12 +18,12 @@ #include "hostosinfo.h" #include <QDir> -namespace GUI_StringUtil +namespace GUI_StringUtils { QString withTildeHomePath(const QString &path) { - if (GUI_OS_Util::HostOsInfo::isWindowsHost()) + if (GUI_OS_Utils::HostOsInfo::isWindowsHost()) return path; static const QString homePath = QDir::homePath(); @@ -37,4 +37,4 @@ QString withTildeHomePath(const QString &path) return outPath; } -} // namespace GUI_StringUtil +} // namespace GUI_StringUtils diff --git a/GUI/coregui/utils/qstringutils.h b/GUI/coregui/utils/qstringutils.h index 29d1d7aaa0e..bd0401cbf84 100644 --- a/GUI/coregui/utils/qstringutils.h +++ b/GUI/coregui/utils/qstringutils.h @@ -20,7 +20,7 @@ #include "WinDllMacros.h" #include <QString> -namespace GUI_StringUtil +namespace GUI_StringUtils { BA_CORE_API_ QString withTildeHomePath(const QString &path); diff --git a/Tests/Functional/Core/CoreTest.cpp b/Tests/Functional/Core/CoreTest.cpp index faf306bc5d1..4c9df759cc2 100644 --- a/Tests/Functional/Core/CoreTest.cpp +++ b/Tests/Functional/Core/CoreTest.cpp @@ -18,7 +18,6 @@ #include "GISASSimulation.h" #include "IntensityDataFunctions.h" #include "IntensityDataIOFactory.h" -#include "Utils.h" CoreTest::CoreTest( const std::string& name, const std::string& description, GISASSimulation* simulation, diff --git a/Tests/Functional/GUI/GUITest.cpp b/Tests/Functional/GUI/GUITest.cpp index 5459ddfed15..91e1c5f53ed 100644 --- a/Tests/Functional/GUI/GUITest.cpp +++ b/Tests/Functional/GUI/GUITest.cpp @@ -24,7 +24,6 @@ #include "MaterialModel.h" #include "MaterialSvc.h" #include "SampleModel.h" -#include "Utils.h" GUITest::GUITest(const std::string &name, const std::string &description, GISASSimulation *reference_simulation, double threshold) diff --git a/Tests/Functional/GUI/GUITranslationTest/GUITranslationTest.cpp b/Tests/Functional/GUI/GUITranslationTest/GUITranslationTest.cpp index 102c5ff5bcf..1bf01cf369f 100644 --- a/Tests/Functional/GUI/GUITranslationTest/GUITranslationTest.cpp +++ b/Tests/Functional/GUI/GUITranslationTest/GUITranslationTest.cpp @@ -161,7 +161,7 @@ bool GUITranslationTest::checkMissedTranslations() std::vector<std::string> domainNames = pool->getParameterNames(); std::vector<std::string> missedNames; for(auto name : domainNames) { - std::string domainName = "*" + StringUtil::removeSubstring(name, "/GISASSimulation"); + std::string domainName = "*" + StringUtils::removeSubstring(name, "/GISASSimulation"); bool translationFound(false); for(auto pair : m_translations) { if(pair.translatedName == domainName) { diff --git a/Tests/Functional/PyCore/export/PyExportTest.cpp b/Tests/Functional/PyCore/export/PyExportTest.cpp index 3af1c786c1f..841fe62aa70 100644 --- a/Tests/Functional/PyCore/export/PyExportTest.cpp +++ b/Tests/Functional/PyCore/export/PyExportTest.cpp @@ -20,7 +20,6 @@ #include "IntensityDataIOFactory.h" #include "PythonFormatting.h" #include "SimulationFactory.h" -#include "Utils.h" #include <cassert> #include <cstdio> #include <fstream> diff --git a/Tests/Functional/PyCore/persistence/PyPersistenceTest.cpp b/Tests/Functional/PyCore/persistence/PyPersistenceTest.cpp index 71a88176f1d..484bd051793 100644 --- a/Tests/Functional/PyCore/persistence/PyPersistenceTest.cpp +++ b/Tests/Functional/PyCore/persistence/PyPersistenceTest.cpp @@ -20,7 +20,7 @@ #include "IntensityDataIOFactory.h" #include "PythonFormatting.h" #include "SimulationFactory.h" -#include "Utils.h" +#include "StringUtils.h" #include <yaml-cpp/yaml.h> #include <cstdio> #include <fstream> @@ -77,7 +77,7 @@ PyPersistenceTest::glob2map(const std::string& dir, const std::string& stem) std::map<const std::string, const std::string> ret; for (const std::string& fname: FileUtils::glob(dir, stem+"\\.\\w+\\..+")) { std::vector<std::string> fname_segments = - StringUtil::split(FileUtils::filename(fname), "."); + StringUtils::split(FileUtils::filename(fname), "."); ret.insert(make_pair(fname_segments[1]+"."+fname_segments[2], fname)); } return ret; @@ -113,7 +113,7 @@ bool PyPersistenceTest::compareFilePair( const std::string& dat_fpath, const std::string& ref_fpath) { std::cout << "Comparing dat='" << dat_fpath << "' with ref='" << ref_fpath << "':\n"; - const std::string extension = StringUtil::split(FileUtils::filename(dat_fpath), ".")[2]; + const std::string extension = StringUtils::split(FileUtils::filename(dat_fpath), ".")[2]; if ( extension=="int" ) return compareIntensityPair( dat_fpath, ref_fpath ); if ( extension=="yaml" ) diff --git a/Tests/Functional/TestMachinery/StandardSimulationsRegistry.cpp b/Tests/Functional/TestMachinery/StandardSimulationsRegistry.cpp index 72f44591adf..54884328ace 100644 --- a/Tests/Functional/TestMachinery/StandardSimulationsRegistry.cpp +++ b/Tests/Functional/TestMachinery/StandardSimulationsRegistry.cpp @@ -379,8 +379,8 @@ void StandardSimulationsRegistry::printCatalogue(std::ostream& ostr) const { for(auto it = m_catalogue.begin(); it != m_catalogue.end(); ++it) { SimulationInfo info = it->second; - ostr << StringUtil::padRight(info.m_test_name, 20) << " | "; - ostr << StringUtil::padRight(info.m_test_description, 40) << " | "; + ostr << StringUtils::padRight(info.m_test_name, 20) << " | "; + ostr << StringUtils::padRight(info.m_test_description, 40) << " | "; ostr << info.m_simulation_name << ", "; ostr << info.m_sample_builder_name << ", "; ostr << info.m_subtest_type; diff --git a/Tests/UnitTests/Core/0/FixedBinAxisTest.h b/Tests/UnitTests/Core/0/FixedBinAxisTest.h index 8a4c240b249..b1de3dcc0e3 100644 --- a/Tests/UnitTests/Core/0/FixedBinAxisTest.h +++ b/Tests/UnitTests/Core/0/FixedBinAxisTest.h @@ -27,7 +27,7 @@ TEST_F(FixedBinAxisTest, IndexedAccessor) EXPECT_DOUBLE_EQ(-1.0, a2[0]); EXPECT_DOUBLE_EQ(0.0, a2[1]); EXPECT_DOUBLE_EQ(1.0, a2[2]); - ASSERT_THROW( a2[3], Exception::OutOfBoundsException); + ASSERT_THROW( a2[3], Exceptions::OutOfBoundsException); } TEST_F(FixedBinAxisTest, VectorOfUnitLength) @@ -47,7 +47,7 @@ TEST_F(FixedBinAxisTest, FindClosestIndex) EXPECT_EQ( size_t(0), v1.findClosestIndex(0.25)); EXPECT_EQ( size_t(1), v1.findClosestIndex(0.5)); EXPECT_EQ( size_t(1), v1.findClosestIndex(0.6)); -// ASSERT_THROW( v1.findClosestIndex(1.0), Exception::OutOfBoundsException); +// ASSERT_THROW( v1.findClosestIndex(1.0), Exceptions::OutOfBoundsException); EXPECT_EQ( size_t(1), v1.findClosestIndex(1.0)); FixedBinAxis v2("name", 3, -1.5, 1.5); @@ -57,7 +57,7 @@ TEST_F(FixedBinAxisTest, FindClosestIndex) EXPECT_EQ(size_t(1), v2.findClosestIndex(0.0)); EXPECT_EQ(size_t(2), v2.findClosestIndex(0.5)); EXPECT_EQ(size_t(2), v2.findClosestIndex(1.499)); -// ASSERT_THROW( v2.findClosestIndex(1.5), Exception::OutOfBoundsException); +// ASSERT_THROW( v2.findClosestIndex(1.5), Exceptions::OutOfBoundsException); EXPECT_EQ(size_t(2), v2.findClosestIndex(1.5)); } @@ -87,7 +87,7 @@ TEST_F(FixedBinAxisTest, CheckBin) EXPECT_DOUBLE_EQ( 9.5, bin19.m_lower); EXPECT_DOUBLE_EQ( 10.0, bin19.m_upper); - ASSERT_THROW( axis.getBin(20), Exception::OutOfBoundsException); + ASSERT_THROW( axis.getBin(20), Exceptions::OutOfBoundsException); FixedBinAxis axis2("name", 3, -1, 2.0); EXPECT_DOUBLE_EQ(-0.5, axis2.getBin(0).getMidPoint()); diff --git a/Tests/UnitTests/Core/0/Histogram1DTest.h b/Tests/UnitTests/Core/0/Histogram1DTest.h index 39f0a3649d5..afe317ee32f 100644 --- a/Tests/UnitTests/Core/0/Histogram1DTest.h +++ b/Tests/UnitTests/Core/0/Histogram1DTest.h @@ -21,7 +21,7 @@ TEST_F(Histogram1DTest, FixedBinConstructor) EXPECT_EQ(0.0, hist.getXmin()); EXPECT_EQ(5.0, hist.getXmax()); EXPECT_EQ(std::string("x-axis"), hist.getXaxis().getName()); - EXPECT_THROW(hist.getYaxis(), Exception::LogicErrorException); + EXPECT_THROW(hist.getYaxis(), Exceptions::LogicErrorException); for(size_t index=0; index<hist.getTotalNumberOfBins(); ++index) { EXPECT_EQ(index, hist.getGlobalBin(index)); EXPECT_EQ(int(index), hist.getXaxisIndex(index)); diff --git a/Tests/UnitTests/Core/0/VariableBinAxisTest.h b/Tests/UnitTests/Core/0/VariableBinAxisTest.h index 689833dccce..5ec39726213 100644 --- a/Tests/UnitTests/Core/0/VariableBinAxisTest.h +++ b/Tests/UnitTests/Core/0/VariableBinAxisTest.h @@ -27,17 +27,17 @@ TEST_F(VariableBinAxisTest, VectorOfUnitLength) TEST_F(VariableBinAxisTest, ValidityOfCOnstructor) { std::vector<double> values; - ASSERT_THROW( VariableBinAxis("name",1,values), Exception::LogicErrorException); + ASSERT_THROW( VariableBinAxis("name",1,values), Exceptions::LogicErrorException); values.resize(5); - ASSERT_THROW( VariableBinAxis("name",5,values), Exception::LogicErrorException); + ASSERT_THROW( VariableBinAxis("name",5,values), Exceptions::LogicErrorException); static const double arr1[] = {-1.5, -1.5, 0.5, 1.5}; std::vector<double> v1 (arr1, arr1 + sizeof(arr1) / sizeof(arr1[0]) ); - ASSERT_THROW( VariableBinAxis("name", 3, v1), Exception::LogicErrorException); + ASSERT_THROW( VariableBinAxis("name", 3, v1), Exceptions::LogicErrorException); static const double arr2[] = {1.5, -0.5, 0.5, -1.5}; std::vector<double> v2 (arr2, arr2 + sizeof(arr2) / sizeof(arr2[0]) ); - ASSERT_THROW( VariableBinAxis("name", 3, v2), Exception::LogicErrorException); + ASSERT_THROW( VariableBinAxis("name", 3, v2), Exceptions::LogicErrorException); } @@ -71,7 +71,7 @@ TEST_F(VariableBinAxisTest, IndexedAccessor) EXPECT_DOUBLE_EQ(-1.0, a2[0]); EXPECT_DOUBLE_EQ(0.0, a2[1]); EXPECT_DOUBLE_EQ(1.0, a2[2]); - ASSERT_THROW( a2[3], Exception::OutOfBoundsException); + ASSERT_THROW( a2[3], Exceptions::OutOfBoundsException); } @@ -86,7 +86,7 @@ TEST_F(VariableBinAxisTest, FindClosestIndex) EXPECT_EQ( size_t(0), v1.findClosestIndex(0.25)); EXPECT_EQ( size_t(1), v1.findClosestIndex(0.5)); EXPECT_EQ( size_t(1), v1.findClosestIndex(0.6)); -// ASSERT_THROW( v1.findClosestIndex(1.0), Exception::OutOfBoundsException); +// ASSERT_THROW( v1.findClosestIndex(1.0), Exceptions::OutOfBoundsException); EXPECT_EQ( size_t(1), v1.findClosestIndex(1.0)); static const double arr2[] = {-1.5, -0.5, 0.5, 1.5}; @@ -98,7 +98,7 @@ TEST_F(VariableBinAxisTest, FindClosestIndex) EXPECT_EQ(size_t(1), v2.findClosestIndex(0.0)); EXPECT_EQ(size_t(2), v2.findClosestIndex(0.5)); EXPECT_EQ(size_t(2), v2.findClosestIndex(1.499)); -// ASSERT_THROW( v2.findClosestIndex(1.5), Exception::OutOfBoundsException); +// ASSERT_THROW( v2.findClosestIndex(1.5), Exceptions::OutOfBoundsException); EXPECT_EQ(size_t(2), v2.findClosestIndex(1.5)); static const double arr3[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; diff --git a/Tests/UnitTests/Core/2/SpecularSimulationTest.h b/Tests/UnitTests/Core/2/SpecularSimulationTest.h index 25ed8a2595d..eb126512b42 100644 --- a/Tests/UnitTests/Core/2/SpecularSimulationTest.h +++ b/Tests/UnitTests/Core/2/SpecularSimulationTest.h @@ -36,13 +36,13 @@ SpecularSimulationTest::SpecularSimulationTest() TEST_F(SpecularSimulationTest, InitialState) { SpecularSimulation sim; - ASSERT_THROW( sim.runSimulation(), Exception::ClassInitializationException); + ASSERT_THROW( sim.runSimulation(), Exceptions::ClassInitializationException); EXPECT_EQ(nullptr, sim.getAlphaAxis()); EXPECT_EQ(nullptr, sim.getSample()); EXPECT_EQ(nullptr, sim.getSampleBuilder().get()); - ASSERT_THROW( sim.getScalarR(0), Exception::ClassInitializationException); - ASSERT_THROW( sim.getScalarT(0), Exception::ClassInitializationException); - ASSERT_THROW( sim.getScalarKz(0), Exception::ClassInitializationException); + ASSERT_THROW( sim.getScalarR(0), Exceptions::ClassInitializationException); + ASSERT_THROW( sim.getScalarT(0), Exceptions::ClassInitializationException); + ASSERT_THROW( sim.getScalarKz(0), Exceptions::ClassInitializationException); } TEST_F(SpecularSimulationTest, CloneOfEmpty) @@ -50,13 +50,13 @@ TEST_F(SpecularSimulationTest, CloneOfEmpty) SpecularSimulation sim; SpecularSimulation *clone = sim.clone(); - ASSERT_THROW( clone->runSimulation(), Exception::ClassInitializationException); + ASSERT_THROW( clone->runSimulation(), Exceptions::ClassInitializationException); EXPECT_EQ(nullptr, clone->getAlphaAxis()); EXPECT_EQ(nullptr, clone->getSample()); EXPECT_EQ(nullptr, clone->getSampleBuilder().get()); - ASSERT_THROW( clone->getScalarR(0), Exception::ClassInitializationException); - ASSERT_THROW( clone->getScalarT(0), Exception::ClassInitializationException); - ASSERT_THROW( clone->getScalarKz(0), Exception::ClassInitializationException); + ASSERT_THROW( clone->getScalarR(0), Exceptions::ClassInitializationException); + ASSERT_THROW( clone->getScalarT(0), Exceptions::ClassInitializationException); + ASSERT_THROW( clone->getScalarKz(0), Exceptions::ClassInitializationException); delete clone; } @@ -83,18 +83,18 @@ TEST_F(SpecularSimulationTest, ConstructSimulation) sim.setSample(multilayer); EXPECT_EQ( size_t(3), dynamic_cast<MultiLayer *>(sim.getSample())->getNumberOfLayers()); - ASSERT_THROW( sim.getScalarR(0), Exception::ClassInitializationException); - ASSERT_THROW( sim.getScalarT(0), Exception::ClassInitializationException); - ASSERT_THROW( sim.getScalarKz(0), Exception::ClassInitializationException); + ASSERT_THROW( sim.getScalarR(0), Exceptions::ClassInitializationException); + ASSERT_THROW( sim.getScalarT(0), Exceptions::ClassInitializationException); + ASSERT_THROW( sim.getScalarKz(0), Exceptions::ClassInitializationException); sim.runSimulation(); EXPECT_EQ(size_t(10), sim.getScalarR(0).size()); EXPECT_EQ(size_t(10), sim.getScalarT(0).size()); EXPECT_EQ(size_t(10), sim.getScalarKz(0).size()); - ASSERT_THROW( sim.getScalarR(3), Exception::OutOfBoundsException); - ASSERT_THROW( sim.getScalarT(3), Exception::OutOfBoundsException); - ASSERT_THROW( sim.getScalarKz(3), Exception::OutOfBoundsException); + ASSERT_THROW( sim.getScalarR(3), Exceptions::OutOfBoundsException); + ASSERT_THROW( sim.getScalarT(3), Exceptions::OutOfBoundsException); + ASSERT_THROW( sim.getScalarKz(3), Exceptions::OutOfBoundsException); } @@ -108,9 +108,9 @@ TEST_F(SpecularSimulationTest, SimulationClone) EXPECT_EQ( size_t(3), dynamic_cast<MultiLayer *>(clone->getSample())->getNumberOfLayers()); - ASSERT_THROW( clone->getScalarR(0), Exception::ClassInitializationException); - ASSERT_THROW( clone->getScalarT(0), Exception::ClassInitializationException); - ASSERT_THROW( clone->getScalarKz(0), Exception::ClassInitializationException); + ASSERT_THROW( clone->getScalarR(0), Exceptions::ClassInitializationException); + ASSERT_THROW( clone->getScalarT(0), Exceptions::ClassInitializationException); + ASSERT_THROW( clone->getScalarKz(0), Exceptions::ClassInitializationException); delete clone; sim.runSimulation(); diff --git a/Tests/UnitTests/Core/3/RegionOfInterestTest.h b/Tests/UnitTests/Core/3/RegionOfInterestTest.h index 930b8ceee35..2231879aa17 100644 --- a/Tests/UnitTests/Core/3/RegionOfInterestTest.h +++ b/Tests/UnitTests/Core/3/RegionOfInterestTest.h @@ -39,7 +39,7 @@ TEST_F(RegionOfInterestTest, constructor) EXPECT_EQ(roi.roiIndex(9), 2u); EXPECT_EQ(roi.roiIndex(21), 8u); EXPECT_EQ(roi.roiIndex(22), 9u); - EXPECT_THROW(roi.roiIndex(23), Exception::RuntimeErrorException); + EXPECT_THROW(roi.roiIndex(23), Exceptions::RuntimeErrorException); // converting local ro index to global detector index EXPECT_EQ(roi.detectorIndex(0), 5u); @@ -105,7 +105,7 @@ TEST_F(RegionOfInterestTest, clone) EXPECT_EQ(clone->roiIndex(9), 2u); EXPECT_EQ(clone->roiIndex(21), 8u); EXPECT_EQ(clone->roiIndex(22), 9u); - EXPECT_THROW(clone->roiIndex(23), Exception::RuntimeErrorException); + EXPECT_THROW(clone->roiIndex(23), Exceptions::RuntimeErrorException); // converting local ro index to global detector index EXPECT_EQ(clone->detectorIndex(0), 5u); diff --git a/Tests/UnitTests/Core/3/SphericalDetectorTest.h b/Tests/UnitTests/Core/3/SphericalDetectorTest.h index 35a75183686..20f91e6a5a8 100644 --- a/Tests/UnitTests/Core/3/SphericalDetectorTest.h +++ b/Tests/UnitTests/Core/3/SphericalDetectorTest.h @@ -49,10 +49,10 @@ TEST_F(SphericalDetectorTest, initialState) EXPECT_EQ(nullptr, detector.regionOfInterest()); // behavior - ASSERT_THROW(detector.getAxis(0), Exception::OutOfBoundsException); + ASSERT_THROW(detector.getAxis(0), Exceptions::OutOfBoundsException); OutputData<double>* p_intensity_map(nullptr); ASSERT_THROW(detector.applyDetectorResolution(p_intensity_map), - Exception::NullPointerException); + Exceptions::NullPointerException); } //! Construction of the detector with axes. diff --git a/Tests/UnitTests/Core/4/ChiSquaredModuleTest.h b/Tests/UnitTests/Core/4/ChiSquaredModuleTest.h index 1753c4e21f7..51a5c09eeaf 100644 --- a/Tests/UnitTests/Core/4/ChiSquaredModuleTest.h +++ b/Tests/UnitTests/Core/4/ChiSquaredModuleTest.h @@ -47,8 +47,8 @@ TEST_F(ChiSquaredModuleTest, InitialState) // EXPECT_TRUE( dynamic_cast<const DefaultAllDataSelector*>(m_chi_empty.getFittingDataSelector())); EXPECT_EQ( nullptr, m_chi_empty.getIntensityNormalizer()); EXPECT_EQ( nullptr, m_chi_empty.getIntensityFunction()); -// ASSERT_THROW(m_chi_empty.calculateChiSquared(), Exception::NullPointerException); -// ASSERT_THROW(m_chi_empty.createChi2DifferenceMap(), Exception::NullPointerException); +// ASSERT_THROW(m_chi_empty.calculateChiSquared(), Exceptions::NullPointerException); +// ASSERT_THROW(m_chi_empty.createChi2DifferenceMap(), Exceptions::NullPointerException); } TEST_F(ChiSquaredModuleTest, CloneOfEmpty) @@ -60,8 +60,8 @@ TEST_F(ChiSquaredModuleTest, CloneOfEmpty) // EXPECT_TRUE( dynamic_cast<const DefaultAllDataSelector*>(clone_of_empty->getFittingDataSelector())); EXPECT_EQ( nullptr, clone_of_empty->getIntensityNormalizer()); EXPECT_EQ( nullptr, clone_of_empty->getIntensityFunction()); -// ASSERT_THROW(clone_of_empty->calculateChiSquared(), Exception::NullPointerException); -// ASSERT_THROW(clone_of_empty->createChi2DifferenceMap(), Exception::NullPointerException); +// ASSERT_THROW(clone_of_empty->calculateChiSquared(), Exceptions::NullPointerException); +// ASSERT_THROW(clone_of_empty->createChi2DifferenceMap(), Exceptions::NullPointerException); delete clone_of_empty; } diff --git a/Tests/UnitTests/Core/5/DistributionsTest.h b/Tests/UnitTests/Core/5/DistributionsTest.h index cba77141b3c..3b3e9d37b7a 100644 --- a/Tests/UnitTests/Core/5/DistributionsTest.h +++ b/Tests/UnitTests/Core/5/DistributionsTest.h @@ -41,7 +41,7 @@ TEST_F(DistributionsTest, DistributionGateDefaultConstructor) TEST_F(DistributionsTest, DistributionGateConstructor) { // Throw error when m_min > m_max: - EXPECT_THROW(DistributionGate(1.1, 1.0), Exception::ClassInitializationException); + EXPECT_THROW(DistributionGate(1.1, 1.0), Exceptions::ClassInitializationException); // When m_min == m_max, only one sample is generated (the mean): DistributionGate distr1(1.0, 1.0); diff --git a/Tests/UnitTests/Core/5/ParameterDistributionTest.h b/Tests/UnitTests/Core/5/ParameterDistributionTest.h index 6e90ad33faa..c09cc5fac97 100644 --- a/Tests/UnitTests/Core/5/ParameterDistributionTest.h +++ b/Tests/UnitTests/Core/5/ParameterDistributionTest.h @@ -20,9 +20,9 @@ TEST_F(ParameterDistributionTest, ParameterDistributionConstructor) std::string name = "MainParameterName"; DistributionGate distribution(1.0, 2.0); EXPECT_THROW(ParameterDistribution(name, distribution, 1, -1.0), - Exception::RuntimeErrorException); + Exceptions::RuntimeErrorException); EXPECT_THROW(ParameterDistribution(name, distribution, 0), - Exception::RuntimeErrorException); + Exceptions::RuntimeErrorException); // Sigma constructor ParameterDistribution pardistr(name, distribution, 1); diff --git a/Tests/UnitTests/Core/5/ParameterPoolTest.h b/Tests/UnitTests/Core/5/ParameterPoolTest.h index 9caaabecdff..f70ac46599c 100644 --- a/Tests/UnitTests/Core/5/ParameterPoolTest.h +++ b/Tests/UnitTests/Core/5/ParameterPoolTest.h @@ -32,7 +32,7 @@ ParameterPoolTest::ParameterPoolTest() TEST_F(ParameterPoolTest, InitialState) { EXPECT_EQ( size_t(0), m_empty_pool.size() ); - ASSERT_THROW( m_empty_pool.getParameter("NotExistingName"), Exception::LogicErrorException ); + ASSERT_THROW( m_empty_pool.getParameter("NotExistingName"), Exceptions::LogicErrorException ); } @@ -49,7 +49,7 @@ TEST_F(ParameterPoolTest, registerParameters) pars = m_pool.getMatchedParameters("a_par*"); EXPECT_EQ( size_t(2), pars.size() ); - ASSERT_THROW( m_pool.setParameterValue("NonExistingName", 3.2), Exception::LogicErrorException ); + ASSERT_THROW( m_pool.setParameterValue("NonExistingName", 3.2), Exceptions::LogicErrorException ); m_pool.setParameterValue("b_par3", 3.2); EXPECT_EQ( double(3.2), m_pool.getParameter("b_par3").getValue()); @@ -95,7 +95,7 @@ TEST_F(ParameterPoolTest, SetMatchedParametersValue) pool.registerParameter("xx_x", &x); pool.registerParameter("xx_y", &y); pool.registerParameter("xx_z", &z); - EXPECT_THROW( pool.setMatchedParametersValue("zz*", 4.0), Exception::LogicErrorException ); + EXPECT_THROW( pool.setMatchedParametersValue("zz*", 4.0), Exceptions::LogicErrorException ); pool.setMatchedParametersValue("xx*", 4.0); EXPECT_EQ( double(4.0), pool.getParameter("xx_x").getValue()); EXPECT_EQ( double(4.0), pool.getParameter("xx_y").getValue()); @@ -107,17 +107,17 @@ TEST_F(ParameterPoolTest, LimitsOnParameterValue) double x(0.0); ParameterPool pool; - EXPECT_THROW(pool.registerParameter("xx_x", &x, Limits::limited(1.0, 2.0)), Exception::OutOfBoundsException); + EXPECT_THROW(pool.registerParameter("xx_x", &x, Limits::limited(1.0, 2.0)), Exceptions::OutOfBoundsException); pool.registerParameter("xx_x", &x, Limits::limited(-1.0, 1.0)); EXPECT_TRUE(pool.setParameterValue("xx_x", 0.5)); EXPECT_EQ(0.5, x); - EXPECT_THROW(pool.setParameterValue("xx_x", 2.0), Exception::LogicErrorException); + EXPECT_THROW(pool.setParameterValue("xx_x", 2.0), Exceptions::LogicErrorException); EXPECT_EQ(0.5, x); - EXPECT_THROW(pool.setMatchedParametersValue("xx*", 2.0), Exception::LogicErrorException); + EXPECT_THROW(pool.setMatchedParametersValue("xx*", 2.0), Exceptions::LogicErrorException); EXPECT_EQ(0.5, x); } diff --git a/Tests/UnitTests/Core/6/LLDataTest.h b/Tests/UnitTests/Core/6/LLDataTest.h index 1e6705a7500..ae80906010b 100644 --- a/Tests/UnitTests/Core/6/LLDataTest.h +++ b/Tests/UnitTests/Core/6/LLDataTest.h @@ -183,7 +183,7 @@ TEST_F(LLDataTest, Addition) { LLData<float> *fl_data_1d2 = new LLData<float>(1u, odim1); fl_data_1d2->setAll(10.0); - EXPECT_THROW((*fl_data_1d) += (*fl_data_1d2), Exception::RuntimeErrorException); + EXPECT_THROW((*fl_data_1d) += (*fl_data_1d2), Exceptions::RuntimeErrorException); LLData<Eigen::Matrix2d> *other_matrix_data_2d = new LLData<Eigen::Matrix2d>(*matrix_data_2d); @@ -223,7 +223,7 @@ TEST_F(LLDataTest, Substraction) { LLData<float> *fl_data_1d2 = new LLData<float>(1u, odim1); fl_data_1d2->setAll(10.0); - EXPECT_THROW((*fl_data_1d) -= (*fl_data_1d2), Exception::RuntimeErrorException); + EXPECT_THROW((*fl_data_1d) -= (*fl_data_1d2), Exceptions::RuntimeErrorException); LLData<Eigen::Matrix2d> *other_matrix_data_2d = new LLData<Eigen::Matrix2d>(*matrix_data_2d); matrix_data_2d->setAll( Eigen::Matrix2d::Identity()); @@ -260,7 +260,7 @@ TEST_F(LLDataTest, Multiplication) { LLData<float> *fl_data_1d2 = new LLData<float>(1u, odim1); fl_data_1d2->setAll(10.0); - EXPECT_THROW((*fl_data_1d) *= (*fl_data_1d2), Exception::RuntimeErrorException); + EXPECT_THROW((*fl_data_1d) *= (*fl_data_1d2), Exceptions::RuntimeErrorException); LLData<Eigen::Matrix2d> *other_matrix_data_2d = new LLData<Eigen::Matrix2d>(*matrix_data_2d); matrix_data_2d->setAll( 2*Eigen::Matrix2d::Identity()); @@ -297,7 +297,7 @@ TEST_F(LLDataTest, Division) { LLData<float> *fl_data_1d2 = new LLData<float>(1u, odim1); fl_data_1d2->setAll(10.0); - EXPECT_THROW((*fl_data_1d) /= (*fl_data_1d2), Exception::RuntimeErrorException); + EXPECT_THROW((*fl_data_1d) /= (*fl_data_1d2), Exceptions::RuntimeErrorException); delete fl_data_1d2; diff --git a/Tests/UnitTests/Fit/0/StringUtilsTest.h b/Tests/UnitTests/Fit/0/StringUtilsTest.h index 800ffe5ec8d..f73256418ba 100644 --- a/Tests/UnitTests/Fit/0/StringUtilsTest.h +++ b/Tests/UnitTests/Fit/0/StringUtilsTest.h @@ -15,7 +15,7 @@ protected: TEST_F(StringUtilsTest, removeSubstring) { std::string target("one two threeone five one"); - std::string result = StringUtil::removeSubstring(target, "one"); + std::string result = StringUtils::removeSubstring(target, "one"); EXPECT_EQ(result, " two three five "); } -- GitLab