From 093fefdee4393cd35d5db7b1a87a6dc5a647a901 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Wed, 3 May 2023 10:07:58 +0200 Subject: [PATCH] rm trailing 's' from namespaces *Util --- Base/Py/PyFmt.cpp | 10 +- Base/Py/PyUtil.cpp | 34 ++-- Base/Py/PyUtil.h | 6 +- Base/Util/Algorithms.h | 16 +- Base/Util/FileSystemUtil.cpp | 34 ++-- Base/Util/FileSystemUtil.h | 4 +- Base/Util/StringUtil.cpp | 26 +-- Base/Util/StringUtil.h | 6 +- Base/Util/SysUtil.cpp | 4 +- Base/Util/SysUtil.h | 4 +- Device/Data/ArrayUtil.cpp | 12 +- Device/Data/ArrayUtil.h | 4 +- Device/Data/DataUtil.cpp | 32 ++-- Device/Data/DataUtil.h | 6 +- Device/Histo/DiffUtil.cpp | 2 +- Device/Histo/DiffUtil.h | 2 +- Device/IO/DataFormatUtil.cpp | 50 +++--- Device/IO/DataFormatUtil.h | 4 +- Device/IO/IOFactory.cpp | 28 +-- Device/IO/ReadReflectometry.cpp | 4 +- Device/IO/ReadWriteINT.cpp | 6 +- Device/IO/ReadWriteNicos.cpp | 30 ++-- Device/IO/ReadWriteNumpyTXT.cpp | 12 +- Device/IO/ReadWriteTiff.cpp | 2 +- Device/Mask/Line.cpp | 4 +- GUI/Model/Device/RealItem.cpp | 3 +- GUI/Model/Model/ParameterTreeUtil.cpp | 2 +- GUI/Model/Model/ParameterTreeUtil.h | 2 +- GUI/Support/Util/QCP_Util.cpp | 2 +- GUI/View/Import/ImportDataUtil.cpp | 14 +- GUI/View/Import/ImportDataUtil.h | 2 +- GUI/View/Plot2D/IntensityDataFFTPresenter.cpp | 2 +- GUI/View/PlotUtil/RangeUtil.cpp | 2 +- GUI/View/PlotUtil/RangeUtil.h | 2 +- GUI/View/Project/PyImportAssistant.cpp | 2 +- GUI/View/SampleDesigner/SampleListView.cpp | 2 +- Param/Node/INode.cpp | 2 +- Sample/Aggregate/ParticleLayout.cpp | 2 +- Sample/Multilayer/Layer.cpp | 2 +- Sample/Multilayer/MultiLayer.cpp | 2 +- Sample/Multilayer/PyImport.cpp | 8 +- Sim/Fitting/FitObjective.cpp | 12 +- Sim/Fitting/FitPrintService.cpp | 2 +- Sim/Simulation/ISimulation.cpp | 2 +- .../Consistence/CompareTwoReferences.cpp | 2 +- .../Functional/CoreSpecial/CoreIOPathTest.cpp | 4 +- .../CoreSpecial/FourierTransformationTest.cpp | 16 +- Tests/Suite/GUI/Check.cpp | 2 +- Tests/Suite/Persist/Check.cpp | 6 +- Tests/Suite/Py/Check.cpp | 2 +- Tests/Unit/Base/Concat.cpp | 16 +- Tests/Unit/Base/FileSystemUtilsTest.cpp | 170 +++++++++--------- Tests/Unit/Base/MinMaxValueTest.cpp | 22 +-- Tests/Unit/Base/StringUtilsTest.cpp | 76 ++++---- Tests/Unit/Device/ArrayUtilsTest.cpp | 8 +- Tests/Unit/Device/FixedBinAxisTest.cpp | 2 +- .../Device/IntensityDataFunctionsTest.cpp | 21 ++- Tests/Unit/Device/PointwiseAxisTest.cpp | 2 +- Tests/Unit/Device/RectangularDetectorTest.cpp | 6 +- Tests/Unit/GUI/TestDataItems.cpp | 4 +- Tests/Unit/GUI/TestFormFactorItems.cpp | 2 +- Tests/Unit/PyBinding/Embedded.cpp | 8 +- Tests/Unit/PyBinding/PyInfo.cpp | 6 +- auto/Wrap/libBornAgainDevice_wrap.cpp | 26 +-- 64 files changed, 404 insertions(+), 406 deletions(-) diff --git a/Base/Py/PyFmt.cpp b/Base/Py/PyFmt.cpp index 9217267dd83..f3c55bb71dc 100644 --- a/Base/Py/PyFmt.cpp +++ b/Base/Py/PyFmt.cpp @@ -29,7 +29,7 @@ std::string Py::Fmt::printImportedSymbols(const std::string& code) for (const std::string key : {"R3"}) if (code.find(key) != std::string::npos) to_declare.push_back(key); - return "from bornagain import " + BaseUtils::String::join(to_declare, ", ") + "\n"; + return "from bornagain import " + BaseUtil::String::join(to_declare, ", ") + "\n"; } std::string Py::Fmt::printInt(int value) @@ -152,7 +152,7 @@ std::string Py::Fmt::printArguments(const std::vector<std::pair<double, std::str std::vector<std::string> args; for (const auto& argument : arguments) args.push_back(Py::Fmt::printValue(argument.first, argument.second)); - return BaseUtils::String::join(args, ", "); + return BaseUtil::String::join(args, ", "); } std::string Py::Fmt::printArguments( @@ -161,7 +161,7 @@ std::string Py::Fmt::printArguments( std::vector<std::string> args; for (const auto& argument : arguments) args.push_back(Py::Fmt::printValue(argument.first, argument.second)); - return BaseUtils::String::join(args, ", "); + return BaseUtil::String::join(args, ", "); } std::string Py::Fmt::printFunction(const std::string& name, @@ -183,12 +183,12 @@ std::string Py::Fmt::printFunction(const std::string& name, double value1, const bool Py::Fmt::isSquare(double length1, double length2, double angle) { - return length1 == length2 && BaseUtils::algo::almostEqual(angle, (pi / 2), 2); + return length1 == length2 && BaseUtil::algo::almostEqual(angle, (pi / 2), 2); } bool Py::Fmt::isHexagonal(double length1, double length2, double angle) { - return length1 == length2 && BaseUtils::algo::almostEqual(angle, (2 * pi) / 3.0, 2); + return length1 == length2 && BaseUtil::algo::almostEqual(angle, (2 * pi) / 3.0, 2); } std::string Py::Fmt::printKvector(const R3 value) diff --git a/Base/Py/PyUtil.cpp b/Base/Py/PyUtil.cpp index e1ce562230c..107ee4630cf 100644 --- a/Base/Py/PyUtil.cpp +++ b/Base/Py/PyUtil.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file Base/Py/PyUtil.cpp -//! @brief IOmplements various functions from PyUtils namespace +//! @brief IOmplements various functions from PyUtil namespace //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -22,7 +22,7 @@ #include <sstream> #include <stdexcept> -std::string BaseUtils::Python::toString(PyObject* obj) +std::string BaseUtil::Python::toString(PyObject* obj) { std::string result; PyObject* pyStr = PyUnicode_AsEncodedString(obj, "utf-8", "replace"); @@ -33,7 +33,7 @@ std::string BaseUtils::Python::toString(PyObject* obj) return result; } -std::vector<std::string> BaseUtils::Python::toVectorString(PyObject* obj) +std::vector<std::string> BaseUtil::Python::toVectorString(PyObject* obj) { std::vector<std::string> result; @@ -53,14 +53,14 @@ std::vector<std::string> BaseUtils::Python::toVectorString(PyObject* obj) return result; } -std::string BaseUtils::Python::toString(char* c) +std::string BaseUtil::Python::toString(char* c) { if (c) return c; return ""; } -std::string BaseUtils::Python::toString(wchar_t* c) +std::string BaseUtil::Python::toString(wchar_t* c) { if (!c) return ""; @@ -68,7 +68,7 @@ std::string BaseUtils::Python::toString(wchar_t* c) return std::string(wstr.begin(), wstr.end()); } -PyObject* BaseUtils::Python::import_bornagain(const std::vector<std::string>& paths) +PyObject* BaseUtil::Python::import_bornagain(const std::vector<std::string>& paths) { if (Py_IsInitialized()) return nullptr; @@ -102,7 +102,7 @@ PyObject* BaseUtils::Python::import_bornagain(const std::vector<std::string>& pa return pmod; } -std::string BaseUtils::Python::pythonRuntimeInfo() +std::string BaseUtil::Python::pythonRuntimeInfo() { Py_InitializeEx(0); @@ -110,20 +110,20 @@ std::string BaseUtils::Python::pythonRuntimeInfo() // Runtime environment result << std::string(60, '=') << "\n"; - result << "PATH: " << BaseUtils::System::getenv("PATH") << "\n"; - result << "PYTHONPATH: " << BaseUtils::System::getenv("PYTHONPATH") << "\n"; - result << "PYTHONHOME: " << BaseUtils::System::getenv("PYTHONHOME") << "\n"; + result << "PATH: " << BaseUtil::System::getenv("PATH") << "\n"; + result << "PYTHONPATH: " << BaseUtil::System::getenv("PYTHONPATH") << "\n"; + result << "PYTHONHOME: " << BaseUtil::System::getenv("PYTHONHOME") << "\n"; // Embedded Python details - result << "Py_GetProgramName(): " << BaseUtils::Python::toString(Py_GetProgramName()) << "\n"; - result << "Py_GetProgramFullPath(): " << BaseUtils::Python::toString(Py_GetProgramFullPath()) + result << "Py_GetProgramName(): " << BaseUtil::Python::toString(Py_GetProgramName()) << "\n"; + result << "Py_GetProgramFullPath(): " << BaseUtil::Python::toString(Py_GetProgramFullPath()) << "\n"; - result << "Py_GetPath(): " << BaseUtils::Python::toString(Py_GetPath()) << "\n"; - result << "Py_GetPythonHome(): " << BaseUtils::Python::toString(Py_GetPythonHome()) << "\n"; + result << "Py_GetPath(): " << BaseUtil::Python::toString(Py_GetPath()) << "\n"; + result << "Py_GetPythonHome(): " << BaseUtil::Python::toString(Py_GetPythonHome()) << "\n"; // Runtime Python's sys.path PyObject* sysPath = PySys_GetObject((char*)"path"); - auto content = BaseUtils::Python::toVectorString(sysPath); + auto content = BaseUtil::Python::toVectorString(sysPath); result << "sys.path: "; for (auto s : content) result << s << ","; @@ -135,7 +135,7 @@ std::string BaseUtils::Python::pythonRuntimeInfo() // Attempt to retrieve Python stack trace // https://stackoverflow.com/questions/1796510/accessing-a-python-traceback-from-the-c-api -std::string BaseUtils::Python::pythonStackTrace() +std::string BaseUtil::Python::pythonStackTrace() { std::stringstream result; @@ -175,7 +175,7 @@ std::string BaseUtils::Python::pythonStackTrace() return result.str(); } -PyObject* BaseUtils::Python::createNumpyArray(const std::vector<double>& data) +PyObject* BaseUtil::Python::createNumpyArray(const std::vector<double>& data) { const size_t ndim(1); npy_int ndim_numpy = ndim; diff --git a/Base/Py/PyUtil.h b/Base/Py/PyUtil.h index 07343351d33..54846d5ee2c 100644 --- a/Base/Py/PyUtil.h +++ b/Base/Py/PyUtil.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file Base/Py/PyUtil.h -//! @brief Defines PyUtils namespace +//! @brief Defines PyUtil namespace //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -27,7 +27,7 @@ class MultiLayer; -namespace BaseUtils::Python { +namespace BaseUtil::Python { //! Converts PyObject into string, if possible, or throws exception. std::string toString(PyObject* obj); @@ -50,7 +50,7 @@ std::string pythonStackTrace(); PyObject* createNumpyArray(const std::vector<double>& data); -} // namespace BaseUtils::Python +} // namespace BaseUtil::Python #endif // BORNAGAIN_PYTHON diff --git a/Base/Util/Algorithms.h b/Base/Util/Algorithms.h index a450c5b9377..864d1ce4ff6 100644 --- a/Base/Util/Algorithms.h +++ b/Base/Util/Algorithms.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file Base/Util/Algorithms.h -//! @brief Defines and implements namespace BaseUtils::algo with some algorithms +//! @brief Defines and implements namespace BaseUtil::algo with some algorithms //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -25,7 +25,7 @@ //! Some additions to standard library algorithms. -namespace BaseUtils::algo { +namespace BaseUtil::algo { //! Returns true if two doubles agree within machine epsilon times ulp (units in the last place). inline bool almostEqual(double a, double b, int ulp) @@ -46,15 +46,15 @@ double max_value(const Iterator& begin, const Iterator& end, const Evaluator& ev template <class T> std::vector<T> concat(const std::vector<T>& v1, const std::vector<T>& v2); -} // namespace BaseUtils::algo +} // namespace BaseUtil::algo // ************************************************************************************************ // Implementation // ************************************************************************************************ template <typename Evaluator, typename Iterator> -double BaseUtils::algo::min_value(const Iterator& begin, const Iterator& end, - const Evaluator& evaluate) +double BaseUtil::algo::min_value(const Iterator& begin, const Iterator& end, + const Evaluator& evaluate) { ASSERT(begin != end); double result = evaluate(*begin); @@ -65,8 +65,8 @@ double BaseUtils::algo::min_value(const Iterator& begin, const Iterator& end, } template <typename Evaluator, typename Iterator> -double BaseUtils::algo::max_value(const Iterator& begin, const Iterator& end, - const Evaluator& evaluate) +double BaseUtil::algo::max_value(const Iterator& begin, const Iterator& end, + const Evaluator& evaluate) { ASSERT(begin != end); double result = evaluate(*begin); @@ -77,7 +77,7 @@ double BaseUtils::algo::max_value(const Iterator& begin, const Iterator& end, } template <class T> -std::vector<T> BaseUtils::algo::concat(const std::vector<T>& v1, const std::vector<T>& v2) +std::vector<T> BaseUtil::algo::concat(const std::vector<T>& v1, const std::vector<T>& v2) { std::vector<T> v = v1; v.insert(v.end(), v2.begin(), v2.end()); diff --git a/Base/Util/FileSystemUtil.cpp b/Base/Util/FileSystemUtil.cpp index 54847b28f63..6e290dc57cd 100644 --- a/Base/Util/FileSystemUtil.cpp +++ b/Base/Util/FileSystemUtil.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file Base/Util/FileSystemUtil.cpp -//! @brief Implements namespace BaseUtils::Filesystem +//! @brief Implements namespace BaseUtil::Filesystem //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -23,19 +23,19 @@ namespace fs = std::filesystem; -std::string BaseUtils::Filesystem::extension(const std::string& path) +std::string BaseUtil::Filesystem::extension(const std::string& path) { return fs::path(path).extension().string(); } -bool BaseUtils::Filesystem::hasExtension(const std::string& path, const std::string& ref_extension) +bool BaseUtil::Filesystem::hasExtension(const std::string& path, const std::string& ref_extension) { - return BaseUtils::String::to_lower(extension(path)) == ref_extension; + return BaseUtil::String::to_lower(extension(path)) == ref_extension; } -std::string BaseUtils::Filesystem::extensions(const std::string& path) +std::string BaseUtil::Filesystem::extensions(const std::string& path) { - const auto name = BaseUtils::Filesystem::filename(path); + const auto name = BaseUtil::Filesystem::filename(path); if (name == "..") return {}; @@ -43,7 +43,7 @@ std::string BaseUtils::Filesystem::extensions(const std::string& path) return pos != std::string::npos ? name.substr(pos, name.size() - pos) : ""; } -bool BaseUtils::Filesystem::createDirectory(const std::string& dir_name) +bool BaseUtil::Filesystem::createDirectory(const std::string& dir_name) { #ifdef _WIN32 return fs::create_directory(convert_utf8_to_utf16(dir_name)); @@ -52,7 +52,7 @@ bool BaseUtils::Filesystem::createDirectory(const std::string& dir_name) #endif } -bool BaseUtils::Filesystem::createDirectories(const std::string& dir_name) +bool BaseUtil::Filesystem::createDirectories(const std::string& dir_name) { #ifdef _WIN32 return fs::create_directories(convert_utf8_to_utf16(dir_name)); @@ -61,11 +61,11 @@ bool BaseUtils::Filesystem::createDirectories(const std::string& dir_name) #endif } -std::vector<std::string> BaseUtils::Filesystem::filesInDirectory(const std::string& dir_name) +std::vector<std::string> BaseUtil::Filesystem::filesInDirectory(const std::string& dir_name) { std::vector<std::string> result; if (!fs::exists(dir_name)) - throw std::runtime_error("BaseUtils::Filesystem::filesInDirectory '" + dir_name + throw std::runtime_error("BaseUtil::Filesystem::filesInDirectory '" + dir_name + "' does not exist"); for (const auto& entry : fs::directory_iterator(dir_name)) @@ -75,7 +75,7 @@ std::vector<std::string> BaseUtils::Filesystem::filesInDirectory(const std::stri return result; } -std::string BaseUtils::Filesystem::jointPath(const std::string& path1, const std::string& path2) +std::string BaseUtil::Filesystem::jointPath(const std::string& path1, const std::string& path2) { ASSERT(!path2.empty()); @@ -85,19 +85,19 @@ std::string BaseUtils::Filesystem::jointPath(const std::string& path1, const std return (fs::path(path1) / fs::path(path2)).string(); } -std::string BaseUtils::Filesystem::filename(const std::string& path) +std::string BaseUtil::Filesystem::filename(const std::string& path) { return fs::path(path).filename().string(); } -std::string BaseUtils::Filesystem::stem(const std::string& path) +std::string BaseUtil::Filesystem::stem(const std::string& path) { return fs::path(path).stem().string(); } -std::string BaseUtils::Filesystem::stem_ext(const std::string& path) +std::string BaseUtil::Filesystem::stem_ext(const std::string& path) { - const auto name = BaseUtils::Filesystem::filename(path); + const auto name = BaseUtil::Filesystem::filename(path); if (name == "..") return ".."; @@ -105,13 +105,13 @@ std::string BaseUtils::Filesystem::stem_ext(const std::string& path) return pos != std::string::npos ? name.substr(0, pos) : name; } -std::wstring BaseUtils::Filesystem::convert_utf8_to_utf16(const std::string& str) +std::wstring BaseUtil::Filesystem::convert_utf8_to_utf16(const std::string& str) { std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; return converter.from_bytes(str); } -bool BaseUtils::Filesystem::IsFileExists(const std::string& path) +bool BaseUtil::Filesystem::IsFileExists(const std::string& path) { #ifdef _WIN32 return fs::exists(convert_utf8_to_utf16(path)); diff --git a/Base/Util/FileSystemUtil.h b/Base/Util/FileSystemUtil.h index aac662e9fb7..00e022cd96e 100644 --- a/Base/Util/FileSystemUtil.h +++ b/Base/Util/FileSystemUtil.h @@ -23,7 +23,7 @@ //! Utility functions to deal with file system. -namespace BaseUtils::Filesystem { +namespace BaseUtil::Filesystem { //! Returns extension of given filename. //! "/home/user/filename.int" -> ".int", "/home/user/filename.int.gz" -> ".gz" @@ -65,6 +65,6 @@ std::wstring convert_utf8_to_utf16(const std::string& str); //! Returns true if file with given name exists on disk. bool IsFileExists(const std::string& path); -} // namespace BaseUtils::Filesystem +} // namespace BaseUtil::Filesystem #endif // BORNAGAIN_BASE_UTIL_FILESYSTEMUTIL_H diff --git a/Base/Util/StringUtil.cpp b/Base/Util/StringUtil.cpp index 6fa20d3cdf3..002ee2e2f6b 100644 --- a/Base/Util/StringUtil.cpp +++ b/Base/Util/StringUtil.cpp @@ -18,7 +18,7 @@ #include <regex> //! Returns string right-padded with blanks. -std::string BaseUtils::String::padRight(const std::string& name, size_t length) +std::string BaseUtil::String::padRight(const std::string& name, size_t length) { std::string result = name; result.resize(length, ' '); @@ -26,24 +26,24 @@ std::string BaseUtils::String::padRight(const std::string& name, size_t length) } //! Returns token vector obtained by splitting string at delimiters. -std::vector<std::string> BaseUtils::String::split(const std::string& text, - const std::string& delimiter) +std::vector<std::string> BaseUtil::String::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 BaseUtils::String::replaceItemsFromString(std::string& text, - const std::vector<std::string>& items, - const std::string& replacement) +void BaseUtil::String::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 BaseUtils::String::join(const std::vector<std::string>& joinable, - const std::string& joint) +std::string BaseUtil::String::join(const std::vector<std::string>& joinable, + const std::string& joint) { std::string result; size_t n = joinable.size(); @@ -55,13 +55,13 @@ std::string BaseUtils::String::join(const std::vector<std::string>& joinable, return result; } -std::string BaseUtils::String::to_lower(std::string text) +std::string BaseUtil::String::to_lower(std::string text) { boost::to_lower(text); return text; } -bool BaseUtils::String::to_int(const std::string& str, int* result) +bool BaseUtil::String::to_int(const std::string& str, int* result) { const char* first = str.data() + str.find_first_not_of(' '); const char* last = str.data() + str.size(); @@ -84,7 +84,7 @@ bool BaseUtils::String::to_int(const std::string& str, int* result) return true; } -std::string BaseUtils::String::trim(const std::string& str, const std::string& whitespace) +std::string BaseUtil::String::trim(const std::string& str, const std::string& whitespace) { const auto strBegin = str.find_first_not_of(whitespace); @@ -97,7 +97,7 @@ std::string BaseUtils::String::trim(const std::string& str, const std::string& w return str.substr(strBegin, strRange); } -std::string BaseUtils::String::trimFront(const std::string& str, const std::string& whitespace) +std::string BaseUtil::String::trimFront(const std::string& str, const std::string& whitespace) { const auto strBegin = str.find_first_not_of(whitespace); @@ -107,7 +107,7 @@ std::string BaseUtils::String::trimFront(const std::string& str, const std::stri return str.substr(strBegin); } -bool BaseUtils::String::startsWith(const std::string& str, const std::string& substr) +bool BaseUtil::String::startsWith(const std::string& str, const std::string& substr) { return str.rfind(substr, 0) == 0; } diff --git a/Base/Util/StringUtil.h b/Base/Util/StringUtil.h index a6adc2b7a26..915a221a0a6 100644 --- a/Base/Util/StringUtil.h +++ b/Base/Util/StringUtil.h @@ -25,7 +25,7 @@ //! Utility functions to analyze or modify strings. -namespace BaseUtils::String { +namespace BaseUtil::String { std::string padRight(const std::string& name, size_t length); @@ -67,10 +67,10 @@ std::string trimFront(const std::string& str, const std::string& whitespace = " //! True if the string starts with substr. The comparison is case sensitive bool startsWith(const std::string& str, const std::string& substr); -} // namespace BaseUtils::String +} // namespace BaseUtil::String template <typename T> -std::string BaseUtils::String::scientific(const T value, int n) +std::string BaseUtil::String::scientific(const T value, int n) { std::ostringstream out; out << std::scientific << std::setprecision(n) << value; diff --git a/Base/Util/SysUtil.cpp b/Base/Util/SysUtil.cpp index a15aae53978..b397b68e119 100644 --- a/Base/Util/SysUtil.cpp +++ b/Base/Util/SysUtil.cpp @@ -19,7 +19,7 @@ #include <sstream> #include <stdexcept> -std::string BaseUtils::System::getCurrentDateAndTime() +std::string BaseUtil::System::getCurrentDateAndTime() { using clock = std::chrono::system_clock; @@ -29,7 +29,7 @@ std::string BaseUtils::System::getCurrentDateAndTime() return output.str(); } -std::string BaseUtils::System::getenv(const std::string& name) +std::string BaseUtil::System::getenv(const std::string& name) { if (char* c = std::getenv(name.c_str())) return c; diff --git a/Base/Util/SysUtil.h b/Base/Util/SysUtil.h index 9025521d992..e03b905ba48 100644 --- a/Base/Util/SysUtil.h +++ b/Base/Util/SysUtil.h @@ -22,13 +22,13 @@ //! System call wrappers. -namespace BaseUtils::System { +namespace BaseUtil::System { std::string getCurrentDateAndTime(); //! Returns environment variable. std::string getenv(const std::string& name); -} // namespace BaseUtils::System +} // namespace BaseUtil::System #endif // BORNAGAIN_BASE_UTIL_SYSUTIL_H diff --git a/Device/Data/ArrayUtil.cpp b/Device/Data/ArrayUtil.cpp index a0f3cf88ac9..530600dd962 100644 --- a/Device/Data/ArrayUtil.cpp +++ b/Device/Data/ArrayUtil.cpp @@ -18,7 +18,7 @@ #include "Device/Data/Datafield.h" #include <stdexcept> -std::pair<size_t, size_t> DataUtils::Array::getShape(const std::vector<std::vector<double>>& data) +std::pair<size_t, size_t> DataUtil::Array::getShape(const std::vector<std::vector<double>>& data) { size_t nrows = data.size(); size_t ncols(0); @@ -29,7 +29,7 @@ std::pair<size_t, size_t> DataUtils::Array::getShape(const std::vector<std::vect return std::make_pair(nrows, ncols); } -std::unique_ptr<Datafield> DataUtils::Array::createPField1D(const std::vector<double>& vec) +std::unique_ptr<Datafield> DataUtil::Array::createPField1D(const std::vector<double>& vec) { const size_t N = vec.size(); std::vector<const IAxis*> axes{new FixedBinAxis("axis0", N, 0.0, (double)N)}; @@ -37,9 +37,9 @@ std::unique_ptr<Datafield> DataUtils::Array::createPField1D(const std::vector<do } std::unique_ptr<Datafield> -DataUtils::Array::createPField2D(const std::vector<std::vector<double>>& vec) +DataUtil::Array::createPField2D(const std::vector<std::vector<double>>& vec) { - auto shape = DataUtils::Array::getShape(vec); + auto shape = DataUtil::Array::getShape(vec); const size_t nrows = shape.first; const size_t ncols = shape.second; @@ -60,14 +60,14 @@ DataUtils::Array::createPField2D(const std::vector<std::vector<double>>& vec) return std::make_unique<Datafield>(std::move(axes), out); } -std::vector<double> DataUtils::Array::createVector1D(const Datafield& data) +std::vector<double> DataUtil::Array::createVector1D(const Datafield& data) { ASSERT(data.rank() == 1); std::vector<double> result = data.flatVector(); return result; } -std::vector<std::vector<double>> DataUtils::Array::createVector2D(const Datafield& data) +std::vector<std::vector<double>> DataUtil::Array::createVector2D(const Datafield& data) { std::vector<std::vector<double>> result; diff --git a/Device/Data/ArrayUtil.h b/Device/Data/ArrayUtil.h index 67dfac5373d..5a89e2decaa 100644 --- a/Device/Data/ArrayUtil.h +++ b/Device/Data/ArrayUtil.h @@ -25,7 +25,7 @@ class Datafield; //! Array utility functions getShape -namespace DataUtils::Array { +namespace DataUtil::Array { //! Returns shape nrows, ncols of 2D array. std::pair<size_t, size_t> getShape(const std::vector<std::vector<double>>& data); @@ -40,6 +40,6 @@ std::vector<double> createVector1D(const Datafield& data); //! Creates 2D vector from Datafield. std::vector<std::vector<double>> createVector2D(const Datafield& data); -} // namespace DataUtils::Array +} // namespace DataUtil::Array #endif // BORNAGAIN_DEVICE_DATA_ARRAYUTIL_H diff --git a/Device/Data/DataUtil.cpp b/Device/Data/DataUtil.cpp index b1fc99b2b7d..38e083b2664 100644 --- a/Device/Data/DataUtil.cpp +++ b/Device/Data/DataUtil.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file Device/Data/DataUtil.cpp -//! @brief Implements namespace DataUtils. +//! @brief Implements namespace DataUtil. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -37,7 +37,7 @@ std::vector<std::vector<double>> FT2DArray(const std::vector<std::vector<double> } // namespace -std::unique_ptr<Datafield> DataUtils::Data::createRearrangedDataSet(const Datafield& data, int n) +std::unique_ptr<Datafield> DataUtil::Data::createRearrangedDataSet(const Datafield& data, int n) { ASSERT(data.rank() == 2); n = (4 + n % 4) % 4; @@ -77,7 +77,7 @@ std::unique_ptr<Datafield> DataUtils::Data::createRearrangedDataSet(const Datafi return output; } -std::vector<std::vector<double>> DataUtils::Data::create2DArrayfromDatafield(const Datafield& data) +std::vector<std::vector<double>> DataUtil::Data::create2DArrayfromDatafield(const Datafield& data) { ASSERT(data.rank() == 2); std::vector<std::vector<double>> array_2d; @@ -100,7 +100,7 @@ std::vector<std::vector<double>> DataUtils::Data::create2DArrayfromDatafield(con } std::unique_ptr<Datafield> -DataUtils::Data::vecvecToDatafield(const std::vector<std::vector<double>>& array_2d) +DataUtil::Data::vecvecToDatafield(const std::vector<std::vector<double>>& array_2d) { size_t nrows = array_2d.size(); size_t ncols = array_2d[0].size(); @@ -116,29 +116,29 @@ DataUtils::Data::vecvecToDatafield(const std::vector<std::vector<double>>& array return std::make_unique<Datafield>(std::move(axes), out); } -std::unique_ptr<Datafield> DataUtils::Data::createFFT(const Datafield& data) +std::unique_ptr<Datafield> DataUtil::Data::createFFT(const Datafield& data) { - auto array_2d = DataUtils::Data::create2DArrayfromDatafield(data); + auto array_2d = DataUtil::Data::create2DArrayfromDatafield(data); auto fft_array_2d = FT2DArray(array_2d); - return DataUtils::Data::vecvecToDatafield(fft_array_2d); + return DataUtil::Data::vecvecToDatafield(fft_array_2d); } -Datafield* DataUtils::Data::importArrayToDatafield(const std::vector<double>& vec) +Datafield* DataUtil::Data::importArrayToDatafield(const std::vector<double>& vec) { - return DataUtils::Array::createPField1D(vec).release(); + return DataUtil::Array::createPField1D(vec).release(); } -Datafield* DataUtils::Data::importArrayToDatafield(const std::vector<std::vector<double>>& vec) +Datafield* DataUtil::Data::importArrayToDatafield(const std::vector<std::vector<double>>& vec) { - return DataUtils::Array::createPField2D(vec).release(); + return DataUtil::Array::createPField2D(vec).release(); } -std::vector<std::pair<double, double>> DataUtils::Data::FindPeaks(const Datafield& data, - double sigma, - const std::string& option, - double threshold) +std::vector<std::pair<double, double>> DataUtil::Data::FindPeaks(const Datafield& data, + double sigma, + const std::string& option, + double threshold) { - std::vector<std::vector<double>> arr = DataUtils::Array::createVector2D(data); + std::vector<std::vector<double>> arr = DataUtil::Array::createVector2D(data); tspectrum::Spectrum2D spec; auto peaks = spec.find_peaks(arr, sigma, option, threshold); diff --git a/Device/Data/DataUtil.h b/Device/Data/DataUtil.h index f57a51424c0..75ddfed7f69 100644 --- a/Device/Data/DataUtil.h +++ b/Device/Data/DataUtil.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file Device/Data/DataUtil.h -//! @brief Defines namespace DataUtils. +//! @brief Defines namespace DataUtil. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -21,7 +21,7 @@ class Datafield; -namespace DataUtils::Data { +namespace DataUtil::Data { //! Creates a vector of vectors of double (2D Array) from Datafield. std::vector<std::vector<double>> create2DArrayfromDatafield(const Datafield& data); @@ -52,6 +52,6 @@ std::unique_ptr<Datafield> createFFT(const Datafield& data); #endif // SWIG -} // namespace DataUtils::Data +} // namespace DataUtil::Data #endif // BORNAGAIN_DEVICE_DATA_DATAUTIL_H diff --git a/Device/Histo/DiffUtil.cpp b/Device/Histo/DiffUtil.cpp index 03b32d1f68b..e539d53c8d6 100644 --- a/Device/Histo/DiffUtil.cpp +++ b/Device/Histo/DiffUtil.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file Device/Histo/DiffUtil.cpp -//! @brief Implements namespace DataUtils. +//! @brief Implements namespace DataUtil. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/Device/Histo/DiffUtil.h b/Device/Histo/DiffUtil.h index ca9d5ffdbc0..eda4c13a82a 100644 --- a/Device/Histo/DiffUtil.h +++ b/Device/Histo/DiffUtil.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file Device/Histo/DiffUtil.h -//! @brief Defines namespace DataUtils. +//! @brief Defines namespace DataUtil. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/Device/IO/DataFormatUtil.cpp b/Device/IO/DataFormatUtil.cpp index 25a3f0c237e..e62bfe8a247 100644 --- a/Device/IO/DataFormatUtil.cpp +++ b/Device/IO/DataFormatUtil.cpp @@ -38,15 +38,15 @@ std::istringstream getAxisStringRepresentation(std::istream& input_stream) std::string line; std::getline(input_stream, line); const std::vector<std::string> to_replace = {",", "\"", "(", ")", "[", "]"}; - BaseUtils::String::replaceItemsFromString(line, to_replace, " "); + BaseUtil::String::replaceItemsFromString(line, to_replace, " "); return std::istringstream(line); } std::string uncompressedFilename(const std::string& name) { - if (DataUtils::Format::isGZipped(name)) + if (DataUtil::Format::isGZipped(name)) return name.substr(0, name.size() - GzipExtension.size()); - if (DataUtils::Format::isBZipped(name)) + if (DataUtil::Format::isBZipped(name)) return name.substr(0, name.size() - BzipExtension.size()); return name; } @@ -63,7 +63,7 @@ IAxis* createFixedBinLikeAxis(std::istringstream iss) throw std::runtime_error("createFixedBinLikeAxis -> Error. Cannot parse the string."); std::vector<double> boundaries; - DataUtils::Format::readLineOfDoubles(boundaries, iss); + DataUtil::Format::readLineOfDoubles(boundaries, iss); if (boundaries.size() != 2) throw std::runtime_error("Error in createFixedBinLikeAxis: Cannot parse the string while " "reading boundaries."); @@ -80,7 +80,7 @@ IAxis* createDiscreteAxis(std::istringstream iss) throw std::runtime_error("Error in createDiscreteAxis: Cannot parse the string."); std::vector<double> coordinates; - DataUtils::Format::readLineOfDoubles(coordinates, iss); + DataUtil::Format::readLineOfDoubles(coordinates, iss); return new DiscreteAxis(name, coordinates); } @@ -91,58 +91,58 @@ const std::vector<std::pair<std::string, createAxisFun>> type_map = { } // namespace -bool DataUtils::Format::isCompressed(const std::string& name) +bool DataUtil::Format::isCompressed(const std::string& name) { return isGZipped(name) || isBZipped(name); } //! Does name contain *.gz extension? -bool DataUtils::Format::isGZipped(const std::string& name) +bool DataUtil::Format::isGZipped(const std::string& name) { - return BaseUtils::Filesystem::hasExtension(name, GzipExtension); + return BaseUtil::Filesystem::hasExtension(name, GzipExtension); } -bool DataUtils::Format::isBZipped(const std::string& name) +bool DataUtil::Format::isBZipped(const std::string& name) { - return BaseUtils::Filesystem::hasExtension(name, BzipExtension); + return BaseUtil::Filesystem::hasExtension(name, BzipExtension); } -bool DataUtils::Format::isIntFile(const std::string& file_name) +bool DataUtil::Format::isIntFile(const std::string& file_name) { - return BaseUtils::Filesystem::hasExtension(uncompressedFilename(file_name), IntExtension); + return BaseUtil::Filesystem::hasExtension(uncompressedFilename(file_name), IntExtension); } -bool DataUtils::Format::isNicosFile(const std::string& file_name) +bool DataUtil::Format::isNicosFile(const std::string& file_name) { - return BaseUtils::Filesystem::hasExtension(uncompressedFilename(file_name), NicosExtension); + return BaseUtil::Filesystem::hasExtension(uncompressedFilename(file_name), NicosExtension); } -bool DataUtils::Format::isTiffFile(const std::string& file_name) +bool DataUtil::Format::isTiffFile(const std::string& file_name) { - return BaseUtils::Filesystem::hasExtension(uncompressedFilename(file_name), TiffExtension) - || BaseUtils::Filesystem::hasExtension(uncompressedFilename(file_name), TiffExtension2); + return BaseUtil::Filesystem::hasExtension(uncompressedFilename(file_name), TiffExtension) + || BaseUtil::Filesystem::hasExtension(uncompressedFilename(file_name), TiffExtension2); } //! Creates axis of certain type from input stream -IAxis* DataUtils::Format::createAxis(std::istream& input_stream) +IAxis* DataUtil::Format::createAxis(std::istream& input_stream) { auto iss = getAxisStringRepresentation(input_stream); std::string type; if (!(iss >> type)) throw std::runtime_error( - "Error in DataUtils::Format::createAxis:: Cannot read axis type from input"); + "Error in DataUtil::Format::createAxis:: Cannot read axis type from input"); for (auto iter = type_map.cbegin(); iter != type_map.end(); ++iter) if (iter->first == type) return iter->second(std::move(iss)); - throw std::runtime_error("Error in DataUtils::Format::createAxis:" + throw std::runtime_error("Error in DataUtil::Format::createAxis:" "Unknown axis type '" + type + "'"); } //! Fills output data raw buffer from input stream -void DataUtils::Format::fillDatafield(Datafield* data, std::istream& input_stream) +void DataUtil::Format::fillDatafield(Datafield* data, std::istream& input_stream) { std::string line; size_t iout = 0; @@ -183,18 +183,18 @@ void DataUtils::Format::fillDatafield(Datafield* data, std::istream& input_strea // #migration +++ this works only if separator is space or tab; it does not work e.g. with comma or // semicolon -std::vector<double> DataUtils::Format::parse_doubles(const std::string& str) +std::vector<double> DataUtil::Format::parse_doubles(const std::string& str) { std::vector<double> result; std::istringstream iss(str); - DataUtils::Format::readLineOfDoubles(result, iss); + DataUtil::Format::readLineOfDoubles(result, iss); if (result.empty()) { std::string out = str; const size_t max_string_length(10); if (out.size() > max_string_length) out.resize(max_string_length, ' '); out += " ..."; - throw std::runtime_error("DataUtils::Format::parse_doubles -> Error! Cannot parse double " + throw std::runtime_error("DataUtil::Format::parse_doubles -> Error! Cannot parse double " "values from a string '" + out + "'"); } @@ -203,7 +203,7 @@ std::vector<double> DataUtils::Format::parse_doubles(const std::string& str) // #migration +++ this works only if separator is space or tab; it does not work e.g. with comma or // semicolon -void DataUtils::Format::readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss) +void DataUtil::Format::readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss) { iss.imbue(std::locale::classic()); std::copy(std::istream_iterator<double>(iss), std::istream_iterator<double>(), diff --git a/Device/IO/DataFormatUtil.h b/Device/IO/DataFormatUtil.h index 2aa94a31f86..070e7cd79d2 100644 --- a/Device/IO/DataFormatUtil.h +++ b/Device/IO/DataFormatUtil.h @@ -26,7 +26,7 @@ class Datafield; //! Utility functions for data input and output. -namespace DataUtils::Format { +namespace DataUtil::Format { //! Returns true if name contains *.gz extension bool isCompressed(const std::string& name); @@ -54,6 +54,6 @@ std::vector<double> parse_doubles(const std::string& str); void readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss); -} // namespace DataUtils::Format +} // namespace DataUtil::Format #endif // BORNAGAIN_DEVICE_IO_DATAFORMATUTIL_H diff --git a/Device/IO/IOFactory.cpp b/Device/IO/IOFactory.cpp index 68b73e07e88..fa8613d6066 100644 --- a/Device/IO/IOFactory.cpp +++ b/Device/IO/IOFactory.cpp @@ -82,11 +82,11 @@ Datafield* IOFactory::readReflectometryData(const std::string& file_name) void IOFactory::writeDatafield(const Datafield& data, const std::string& file_name) { try { - if (DataUtils::Format::isIntFile(file_name)) + if (DataUtil::Format::isIntFile(file_name)) functional_write(file_name, [&](std::ostream& s) { ReadWriteINT().writeDatafield(data, s); }); #ifdef BA_TIFF_SUPPORT - else if (DataUtils::Format::isTiffFile(file_name)) + else if (DataUtil::Format::isTiffFile(file_name)) functional_write(file_name, [&](std::ostream& s) { ReadWriteTiff().writeDatafield(data, s); }); #endif @@ -101,7 +101,7 @@ void IOFactory::writeDatafield(const Datafield& data, const std::string& file_na void IOFactory::functional_write(const std::string& file_name, std::function<void(std::ostream&)> writeData) { - using namespace DataUtils::Format; + using namespace DataUtil::Format; std::ofstream fout; std::ios_base::openmode openmode = std::ios::out; @@ -109,7 +109,7 @@ void IOFactory::functional_write(const std::string& file_name, openmode = std::ios::out | std::ios_base::binary; #ifdef _WIN32 - fout.open(BaseUtils::Filesystem::convert_utf8_to_utf16(file_name), openmode); + fout.open(BaseUtil::Filesystem::convert_utf8_to_utf16(file_name), openmode); #else fout.open(file_name, openmode); #endif @@ -122,9 +122,9 @@ void IOFactory::functional_write(const std::string& file_name, writeData(ss); boost::iostreams::filtering_streambuf<boost::iostreams::input> input_filtered; - if (DataUtils::Format::isGZipped(file_name)) + if (DataUtil::Format::isGZipped(file_name)) input_filtered.push(boost::iostreams::gzip_compressor()); - else if (DataUtils::Format::isBZipped(file_name)) + else if (DataUtil::Format::isBZipped(file_name)) input_filtered.push(boost::iostreams::bzip2_compressor()); input_filtered.push(ss); @@ -137,11 +137,11 @@ bool IOFactory::fileTypeMatchesLoaderSelector(const std::string& fileName, Loade { switch (selector) { case bornagain: - return DataUtils::Format::isIntFile(fileName); + return DataUtil::Format::isIntFile(fileName); case nicos: - return DataUtils::Format::isNicosFile(fileName); + return DataUtil::Format::isNicosFile(fileName); case tiff: - return DataUtils::Format::isTiffFile(fileName); + return DataUtil::Format::isTiffFile(fileName); case automatic: return false; } @@ -152,17 +152,17 @@ bool IOFactory::fileTypeMatchesLoaderSelector(const std::string& fileName, Loade Datafield* IOFactory::functional_read(const std::string& file_name, std::function<Datafield*(std::istream&)> readData) { - if (!BaseUtils::Filesystem::IsFileExists(file_name)) + if (!BaseUtil::Filesystem::IsFileExists(file_name)) throw std::runtime_error("File does not exist: " + file_name); - using namespace DataUtils::Format; + using namespace DataUtil::Format; std::ifstream input_stream; std::ios_base::openmode openmode = std::ios::in; if (isTiffFile(file_name) || isCompressed(file_name)) openmode = std::ios::in | std::ios_base::binary; #ifdef _WIN32 - input_stream.open(BaseUtils::Filesystem::convert_utf8_to_utf16(file_name), openmode); + input_stream.open(BaseUtil::Filesystem::convert_utf8_to_utf16(file_name), openmode); #else input_stream.open(file_name, openmode); #endif @@ -173,9 +173,9 @@ Datafield* IOFactory::functional_read(const std::string& file_name, throw std::runtime_error("File is not good, probably it is a directory:" + file_name); boost::iostreams::filtering_streambuf<boost::iostreams::input> input_filtered; - if (DataUtils::Format::isGZipped(file_name)) + if (DataUtil::Format::isGZipped(file_name)) input_filtered.push(boost::iostreams::gzip_decompressor()); - else if (DataUtils::Format::isBZipped(file_name)) + else if (DataUtil::Format::isBZipped(file_name)) input_filtered.push(boost::iostreams::bzip2_decompressor()); input_filtered.push(input_stream); // we use stringstream since it provides random access which is important for tiff files diff --git a/Device/IO/ReadReflectometry.cpp b/Device/IO/ReadReflectometry.cpp index 1931f15e5db..6c2326a1322 100644 --- a/Device/IO/ReadReflectometry.cpp +++ b/Device/IO/ReadReflectometry.cpp @@ -31,11 +31,11 @@ Datafield* ReadReflectometry::readDatafield(std::istream& inStream) // Read numbers from file: while (std::getline(inStream, line)) { - line = BaseUtils::String::trim(line); + line = BaseUtil::String::trim(line); try { // #bamigration +++ this works only if separator is space or tab; it does not // work e.g. with comma or semicolon - std::vector<double> rowVec = DataUtils::Format::parse_doubles(line); + std::vector<double> rowVec = DataUtil::Format::parse_doubles(line); // take only non-negative Q values if (rowVec[0] >= 0.0) diff --git a/Device/IO/ReadWriteINT.cpp b/Device/IO/ReadWriteINT.cpp index b8d9d49e4d2..42eef28e3e9 100644 --- a/Device/IO/ReadWriteINT.cpp +++ b/Device/IO/ReadWriteINT.cpp @@ -27,17 +27,17 @@ Datafield* ReadWriteINT::readDatafield(std::istream& input_stream) std::vector<const IAxis*> axes; while (std::getline(input_stream, line)) { - line = BaseUtils::String::trim(line); + line = BaseUtil::String::trim(line); if (line.find("axis") != std::string::npos) - axes.emplace_back(DataUtils::Format::createAxis(input_stream)); + axes.emplace_back(DataUtil::Format::createAxis(input_stream)); if (line.find("data") != std::string::npos) break; } // std::cout << "Read " << axes.size() << " axes" << std::endl; auto* result = new Datafield(std::move(axes)); - DataUtils::Format::fillDatafield(result, input_stream); + DataUtil::Format::fillDatafield(result, input_stream); return result; } diff --git a/Device/IO/ReadWriteNicos.cpp b/Device/IO/ReadWriteNicos.cpp index f635d84ab6d..b3bce4ccfc0 100644 --- a/Device/IO/ReadWriteNicos.cpp +++ b/Device/IO/ReadWriteNicos.cpp @@ -29,12 +29,12 @@ std::string lineRelatedError(const std::string& errorText, int lineNumber) unsigned int readAssignedPositiveIntValue(const std::string& line, int lineNumber) { - const auto parts = BaseUtils::String::split(line, "="); + const auto parts = BaseUtil::String::split(line, "="); if (parts.size() != 2) throw std::runtime_error(lineRelatedError("Missing assigned value", lineNumber)); int value = 0; - if (!BaseUtils::String::to_int(parts[1], &value)) + if (!BaseUtil::String::to_int(parts[1], &value)) throw std::runtime_error( lineRelatedError("Cannot parse assigned value '" + parts[1] + "'", lineNumber)); @@ -62,10 +62,10 @@ Datafield* IO::readNicosData(std::istream& input_stream) bool typeFound = false; while (std::getline(input_stream, line)) { lineNumber++; - line = BaseUtils::String::trimFront(line, " "); + line = BaseUtil::String::trimFront(line, " "); if (!inFileSection) { - if (BaseUtils::String::startsWith(line, "%File")) { + if (BaseUtil::String::startsWith(line, "%File")) { inFileSection = true; fileSectionFound = true; continue; @@ -73,20 +73,20 @@ Datafield* IO::readNicosData(std::istream& input_stream) continue; } - if (BaseUtils::String::startsWith(line, "%")) + if (BaseUtil::String::startsWith(line, "%")) break; // next section - if (BaseUtils::String::startsWith(line, "Type=")) { - const auto parts = BaseUtils::String::split(line, "="); + if (BaseUtil::String::startsWith(line, "Type=")) { + const auto parts = BaseUtil::String::split(line, "="); if (parts[1] != "SANSDRaw") throw std::runtime_error( lineRelatedError("Unsupported file type '" + parts[1] + "'", lineNumber)); typeFound = true; } - if (BaseUtils::String::startsWith(line, "DataSizeX")) + if (BaseUtil::String::startsWith(line, "DataSizeX")) width = readAssignedPositiveIntValue(line, lineNumber); - else if (BaseUtils::String::startsWith(line, "DataSizeY")) + else if (BaseUtil::String::startsWith(line, "DataSizeY")) height = readAssignedPositiveIntValue(line, lineNumber); if (width != 0 && height != 0) break; @@ -112,10 +112,10 @@ Datafield* IO::readNicosData(std::istream& input_stream) while (std::getline(input_stream, line)) { lineNumber++; - line = BaseUtils::String::trimFront(line, " "); + line = BaseUtil::String::trimFront(line, " "); if (!inCountSection) { - if (BaseUtils::String::startsWith(line, "%Counts")) { + if (BaseUtil::String::startsWith(line, "%Counts")) { inCountSection = true; countSectionFound = true; continue; @@ -123,15 +123,15 @@ Datafield* IO::readNicosData(std::istream& input_stream) continue; } - if (BaseUtils::String::startsWith(line, "%")) + if (BaseUtil::String::startsWith(line, "%")) break; // next section // line is a data line - line = BaseUtils::String::trim(line, " "); + line = BaseUtil::String::trim(line, " "); if (line.empty()) continue; - const auto valuesAsString = BaseUtils::String::split(line, ","); + const auto valuesAsString = BaseUtil::String::split(line, ","); if (valuesAsString.size() != width) throw std::runtime_error( lineRelatedError("Number of found values (" + std::to_string(valuesAsString.size()) @@ -144,7 +144,7 @@ Datafield* IO::readNicosData(std::istream& input_stream) // to show first line at top of image int value = 0; - if (!BaseUtils::String::to_int(valuesAsString[col], &value)) + if (!BaseUtil::String::to_int(valuesAsString[col], &value)) throw std::runtime_error(lineRelatedError( "Value '" + valuesAsString[col] + "' could not be converted to integer", lineNumber)); diff --git a/Device/IO/ReadWriteNumpyTXT.cpp b/Device/IO/ReadWriteNumpyTXT.cpp index 4ec6fa4ee41..8ed1dbc6f40 100644 --- a/Device/IO/ReadWriteNumpyTXT.cpp +++ b/Device/IO/ReadWriteNumpyTXT.cpp @@ -38,12 +38,12 @@ Datafield* ReadWriteNumpyTXT::readDatafield(std::istream& input_stream) // Read numbers from input stream: while (std::getline(input_stream, line)) { - line = BaseUtils::String::trim(line); + line = BaseUtil::String::trim(line); if (line.empty() || !isDoubleStartChar(line[0])) continue; try { - std::vector<double> dataInRow = DataUtils::Format::parse_doubles(line); + std::vector<double> dataInRow = DataUtil::Format::parse_doubles(line); data.push_back(dataInRow); } catch (...) { continue; @@ -67,17 +67,17 @@ Datafield* ReadWriteNumpyTXT::readDatafield(std::istream& input_stream) } if (nrows < 2) - return DataUtils::Array::createPField1D(data[0]).release(); + return DataUtil::Array::createPField1D(data[0]).release(); if (ncols < 2) { const size_t size = data.size(); std::vector<double> vector1d(size); for (size_t i = 0; i < size; ++i) vector1d[i] = data[i][0]; - return DataUtils::Array::createPField1D(vector1d).release(); + return DataUtil::Array::createPField1D(vector1d).release(); } - return DataUtils::Array::createPField2D(data).release(); + return DataUtil::Array::createPField2D(data).release(); } void ReadWriteNumpyTXT::writeDatafield(const Datafield& data, std::ostream& output_stream) @@ -119,7 +119,7 @@ void ReadWriteNumpyTXT::write2DRepresentation(const Datafield& data, std::ostrea output_stream << "# [nrows=" << nrows << ", ncols=" << ncols << "]" << std::endl; - std::vector<std::vector<double>> dataArray = DataUtils::Array::createVector2D(data); + std::vector<std::vector<double>> dataArray = DataUtil::Array::createVector2D(data); output_stream.imbue(std::locale::classic()); output_stream << std::scientific << std::setprecision(12); diff --git a/Device/IO/ReadWriteTiff.cpp b/Device/IO/ReadWriteTiff.cpp index 143bea7b6ba..513f6927953 100644 --- a/Device/IO/ReadWriteTiff.cpp +++ b/Device/IO/ReadWriteTiff.cpp @@ -205,7 +205,7 @@ void ReadWriteTiff::write_header() { ASSERT(m_tiff); TIFFSetField(m_tiff, TIFFTAG_ARTIST, "BornAgain.IOFactory"); - TIFFSetField(m_tiff, TIFFTAG_DATETIME, BaseUtils::System::getCurrentDateAndTime().c_str()); + TIFFSetField(m_tiff, TIFFTAG_DATETIME, BaseUtil::System::getCurrentDateAndTime().c_str()); TIFFSetField(m_tiff, TIFFTAG_IMAGEDESCRIPTION, "Image converted from BornAgain intensity file."); TIFFSetField(m_tiff, TIFFTAG_SOFTWARE, "BornAgain"); diff --git a/Device/Mask/Line.cpp b/Device/Mask/Line.cpp index d45719468af..8c5edf86981 100644 --- a/Device/Mask/Line.cpp +++ b/Device/Mask/Line.cpp @@ -73,7 +73,7 @@ VerticalLine::VerticalLine(double x) bool VerticalLine::contains(double x, double /*y*/) const { - return BaseUtils::algo::almostEqual(x, m_x, 2); + return BaseUtil::algo::almostEqual(x, m_x, 2); } bool VerticalLine::contains(const Bin1D& binx, const Bin1D& /*biny*/) const @@ -92,7 +92,7 @@ HorizontalLine::HorizontalLine(double y) bool HorizontalLine::contains(double /*x*/, double y) const { - return BaseUtils::algo::almostEqual(y, m_y, 2); + return BaseUtil::algo::almostEqual(y, m_y, 2); } bool HorizontalLine::contains(const Bin1D& /*binx*/, const Bin1D& biny) const diff --git a/GUI/Model/Device/RealItem.cpp b/GUI/Model/Device/RealItem.cpp index 9d84ccf4a87..9cd502a2195 100644 --- a/GUI/Model/Device/RealItem.cpp +++ b/GUI/Model/Device/RealItem.cpp @@ -293,8 +293,7 @@ void RealItem::rotateData() // -- now rotate data std::unique_ptr<const Datafield> input(intensityDataItem()->c_field()); - intensityDataItem()->setDatafield( - DataUtils::Data::createRearrangedDataSet(*input, 1).release()); + intensityDataItem()->setDatafield(DataUtil::Data::createRearrangedDataSet(*input, 1).release()); intensityDataItem()->setAxesRangeToData(); } diff --git a/GUI/Model/Model/ParameterTreeUtil.cpp b/GUI/Model/Model/ParameterTreeUtil.cpp index 4e3d753fc89..7a261c5a038 100644 --- a/GUI/Model/Model/ParameterTreeUtil.cpp +++ b/GUI/Model/Model/ParameterTreeUtil.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file GUI/Model/Model/ParameterTreeUtil.cpp -//! @brief Implements ParameterTreeUtils namespace +//! @brief Implements ParameterTreeUtil namespace //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/GUI/Model/Model/ParameterTreeUtil.h b/GUI/Model/Model/ParameterTreeUtil.h index a50c617460b..912080d4f33 100644 --- a/GUI/Model/Model/ParameterTreeUtil.h +++ b/GUI/Model/Model/ParameterTreeUtil.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file GUI/Model/Model/ParameterTreeUtil.h -//! @brief Defines namespace GUI::Model::ParameterTreeUtils +//! @brief Defines namespace GUI::Model::ParameterTreeUtil //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/GUI/Support/Util/QCP_Util.cpp b/GUI/Support/Util/QCP_Util.cpp index fa2368dbf1a..14639396735 100644 --- a/GUI/Support/Util/QCP_Util.cpp +++ b/GUI/Support/Util/QCP_Util.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file GUI/Support/Util/QCP_Util.cpp -//! @brief Implements RangeUtils namespace +//! @brief Implements RangeUtil namespace //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/GUI/View/Import/ImportDataUtil.cpp b/GUI/View/Import/ImportDataUtil.cpp index ebab5ce9d00..9423ead4a90 100644 --- a/GUI/View/Import/ImportDataUtil.cpp +++ b/GUI/View/Import/ImportDataUtil.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file GUI/View/Import/ImportDataUtil.cpp -//! @brief Implements ImportDataUtils namespace +//! @brief Implements ImportDataUtil namespace //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -64,9 +64,9 @@ QString GUI::View::ImportDataUtil::Import1dData(RealItem* realItem, const std::string fileNameStdString = fileName.toStdString(); if (selectedLoader == nullptr) { - if (DataUtils::Format::isCompressed(fileNameStdString) - || DataUtils::Format::isIntFile(fileNameStdString) - || DataUtils::Format::isTiffFile(fileNameStdString)) { + if (DataUtil::Format::isCompressed(fileNameStdString) + || DataUtil::Format::isIntFile(fileNameStdString) + || DataUtil::Format::isTiffFile(fileNameStdString)) { try { ImportDataInfo info(ImportKnownData(fileName), Coords::QSPACE); if (info) { @@ -76,8 +76,8 @@ QString GUI::View::ImportDataUtil::Import1dData(RealItem* realItem, } catch (std::exception& ex) { // If it is not tiff but e.g. dat.gz, it could be tried with CSV import const bool tryWithLoaders = - (DataUtils::Format::isIntFile(fileNameStdString) - && !DataUtils::Format::isCompressed( + (DataUtil::Format::isIntFile(fileNameStdString) + && !DataUtil::Format::isCompressed( fileNameStdString)); // #baimport support compressed if (!tryWithLoaders) @@ -100,7 +100,7 @@ QString GUI::View::ImportDataUtil::Import1dData(RealItem* realItem, if (fileContent.isEmpty()) return "The imported file is empty."; - if (DataUtils::Format::isCompressed(fileNameStdString)) { + if (DataUtil::Format::isCompressed(fileNameStdString)) { // #baimport implement decompress } diff --git a/GUI/View/Import/ImportDataUtil.h b/GUI/View/Import/ImportDataUtil.h index 2f56b959396..da10204800a 100644 --- a/GUI/View/Import/ImportDataUtil.h +++ b/GUI/View/Import/ImportDataUtil.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file GUI/View/Import/ImportDataUtil.h -//! @brief Defines ImportDataUtils namespace +//! @brief Defines ImportDataUtil namespace //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/GUI/View/Plot2D/IntensityDataFFTPresenter.cpp b/GUI/View/Plot2D/IntensityDataFFTPresenter.cpp index 9a82f8d6709..3c1bfb60f7e 100644 --- a/GUI/View/Plot2D/IntensityDataFFTPresenter.cpp +++ b/GUI/View/Plot2D/IntensityDataFFTPresenter.cpp @@ -44,7 +44,7 @@ IntensityDataItem* IntensityDataFFTPresenter::fftItem(IntensityDataItem* origIte ASSERT(origItem); QApplication::setOverrideCursor(Qt::WaitCursor); - m_fftItem->setDatafield(DataUtils::Data::createFFT(*origItem->c_field()).release()); + m_fftItem->setDatafield(DataUtil::Data::createFFT(*origItem->c_field()).release()); QApplication::restoreOverrideCursor(); diff --git a/GUI/View/PlotUtil/RangeUtil.cpp b/GUI/View/PlotUtil/RangeUtil.cpp index 5ffad383bbb..5aea4519761 100644 --- a/GUI/View/PlotUtil/RangeUtil.cpp +++ b/GUI/View/PlotUtil/RangeUtil.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file GUI/View/PlotUtil/RangeUtil.cpp -//! @brief Implements RangeUtils namespace +//! @brief Implements RangeUtil namespace //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/GUI/View/PlotUtil/RangeUtil.h b/GUI/View/PlotUtil/RangeUtil.h index 41e85fcb995..8a176a32396 100644 --- a/GUI/View/PlotUtil/RangeUtil.h +++ b/GUI/View/PlotUtil/RangeUtil.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file GUI/View/PlotUtil/RangeUtil.h -//! @brief Defines RangeUtils namespace +//! @brief Defines RangeUtil namespace //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/GUI/View/Project/PyImportAssistant.cpp b/GUI/View/Project/PyImportAssistant.cpp index 045f78c71a5..58459747b16 100644 --- a/GUI/View/Project/PyImportAssistant.cpp +++ b/GUI/View/Project/PyImportAssistant.cpp @@ -42,7 +42,7 @@ namespace { std::string bornagainDir() { - std::string pythonPath = BaseUtils::System::getenv("PYTHONPATH"); + std::string pythonPath = BaseUtil::System::getenv("PYTHONPATH"); return pythonPath.empty() ? BABuild::buildLibDir() : ""; } diff --git a/GUI/View/SampleDesigner/SampleListView.cpp b/GUI/View/SampleDesigner/SampleListView.cpp index a19b8fe2b4f..9fe822b226c 100644 --- a/GUI/View/SampleDesigner/SampleListView.cpp +++ b/GUI/View/SampleDesigner/SampleListView.cpp @@ -96,7 +96,7 @@ SampleListView::SampleListView(QWidget* parent, ProjectDocument* document) "returning a valid multi-layer."); #ifdef Q_OS_MAC - if (BaseUtils::System::getenv("PYTHONHOME").empty()) + if (BaseUtil::System::getenv("PYTHONHOME").empty()) m_importSampleAction->setEnabled(false); #endif diff --git a/Param/Node/INode.cpp b/Param/Node/INode.cpp index 20f1c0e8ee0..78836829198 100644 --- a/Param/Node/INode.cpp +++ b/Param/Node/INode.cpp @@ -62,7 +62,7 @@ void INode::requestIn(std::vector<std::string>& errs, const double& val, const s std::string INode::jointError(const std::vector<std::string> errs) const { - return "{ " + className() + ": [ " + BaseUtils::String::join(errs, ", ") + " ] }"; + return "{ " + className() + ": [ " + BaseUtil::String::join(errs, ", ") + " ] }"; } void INode::validateOrThrow() const diff --git a/Sample/Aggregate/ParticleLayout.cpp b/Sample/Aggregate/ParticleLayout.cpp index 96f27905f9c..8ea4bcff290 100644 --- a/Sample/Aggregate/ParticleLayout.cpp +++ b/Sample/Aggregate/ParticleLayout.cpp @@ -108,6 +108,6 @@ std::string ParticleLayout::validate() const } if (!errs.empty()) - return "[ " + BaseUtils::String::join(errs, ", ") + " ]"; + return "[ " + BaseUtil::String::join(errs, ", ") + " ]"; return ""; } diff --git a/Sample/Multilayer/Layer.cpp b/Sample/Multilayer/Layer.cpp index efee90b7d9e..c3f325e570c 100644 --- a/Sample/Multilayer/Layer.cpp +++ b/Sample/Multilayer/Layer.cpp @@ -70,6 +70,6 @@ std::string Layer::validate() const } if (!errs.empty()) - return "[ " + BaseUtils::String::join(errs, ", ") + " ]"; + return "[ " + BaseUtil::String::join(errs, ", ") + " ]"; return ""; } diff --git a/Sample/Multilayer/MultiLayer.cpp b/Sample/Multilayer/MultiLayer.cpp index a21927c9a05..ff79045d26c 100644 --- a/Sample/Multilayer/MultiLayer.cpp +++ b/Sample/Multilayer/MultiLayer.cpp @@ -165,7 +165,7 @@ std::string MultiLayer::validate() const requestGe0(errs, m_crossCorrLength, "CrossCorrelationLength"); if (!errs.empty()) - return "[ " + BaseUtils::String::join(errs, ", ") + " ]"; + return "[ " + BaseUtil::String::join(errs, ", ") + " ]"; //! Precompute interface coordinates size_t N = numberOfLayers(); diff --git a/Sample/Multilayer/PyImport.cpp b/Sample/Multilayer/PyImport.cpp index 81bd3f2fe81..962ea3407ab 100644 --- a/Sample/Multilayer/PyImport.cpp +++ b/Sample/Multilayer/PyImport.cpp @@ -25,7 +25,7 @@ std::string error_description(const std::string& title) { std::stringstream buf; buf << title << "\n"; - buf << BaseUtils::Python::pythonStackTrace() << "\n"; + buf << BaseUtil::Python::pythonStackTrace() << "\n"; return buf.str(); } @@ -35,7 +35,7 @@ std::unique_ptr<MultiLayer> Py::Import::createFromPython(const std::string& scri const std::string& functionName, const std::string& path) { - BaseUtils::Python::import_bornagain({path}); + BaseUtil::Python::import_bornagain({path}); PyObject* pCompiledFn = Py_CompileString(script.c_str(), "", Py_file_input); if (!pCompiledFn) @@ -86,7 +86,7 @@ std::unique_ptr<MultiLayer> Py::Import::createFromPython(const std::string& scri std::vector<std::string> Py::Import::listOfFunctions(const std::string& script, const std::string& path) { - BaseUtils::Python::import_bornagain({path}); + BaseUtil::Python::import_bornagain({path}); PyObject* pCompiledFn = Py_CompileString(script.c_str(), "", Py_file_input); if (!pCompiledFn) @@ -108,7 +108,7 @@ std::vector<std::string> Py::Import::listOfFunctions(const std::string& script, Py_ssize_t pos = 0; while (PyDict_Next(dict, &pos, &key, &value)) { if (PyCallable_Check(value)) { - std::string func_name = BaseUtils::Python::toString(key); + std::string func_name = BaseUtil::Python::toString(key); if (func_name.find("__") == std::string::npos) result.push_back(func_name); } diff --git a/Sim/Fitting/FitObjective.cpp b/Sim/Fitting/FitObjective.cpp index c86d09466d8..48c5761ff84 100644 --- a/Sim/Fitting/FitObjective.cpp +++ b/Sim/Fitting/FitObjective.cpp @@ -150,14 +150,14 @@ void FitObjective::execAddSimulationAndData(const simulation_builder_t& builder, void FitObjective::addSimulationAndData(const PyBuilderCallback& callback, const std::vector<std::vector<double>>& data, double weight) { - execAddSimulationAndData(simulationBuilder(callback), *DataUtils::Array::createPField2D(data), + execAddSimulationAndData(simulationBuilder(callback), *DataUtil::Array::createPField2D(data), nullptr, weight); } void FitObjective::addSimulationAndData(const PyBuilderCallback& callback, const std::vector<double>& data, double weight) { - execAddSimulationAndData(simulationBuilder(callback), *DataUtils::Array::createPField1D(data), + execAddSimulationAndData(simulationBuilder(callback), *DataUtil::Array::createPField1D(data), nullptr, weight); } @@ -165,16 +165,16 @@ void FitObjective::addSimulationAndData(const PyBuilderCallback& callback, const std::vector<std::vector<double>>& data, const std::vector<std::vector<double>>& stdv, double weight) { - execAddSimulationAndData(simulationBuilder(callback), *DataUtils::Array::createPField2D(data), - DataUtils::Array::createPField2D(stdv), weight); + execAddSimulationAndData(simulationBuilder(callback), *DataUtil::Array::createPField2D(data), + DataUtil::Array::createPField2D(stdv), weight); } void FitObjective::addSimulationAndData(const PyBuilderCallback& callback, const std::vector<double>& data, const std::vector<double>& stdv, double weight) { - execAddSimulationAndData(simulationBuilder(callback), *DataUtils::Array::createPField1D(data), - DataUtils::Array::createPField1D(stdv), weight); + execAddSimulationAndData(simulationBuilder(callback), *DataUtil::Array::createPField1D(data), + DataUtil::Array::createPField1D(stdv), weight); } double FitObjective::evaluate(const mumufit::Parameters& params) diff --git a/Sim/Fitting/FitPrintService.cpp b/Sim/Fitting/FitPrintService.cpp index 589f6422fca..6c79123c579 100644 --- a/Sim/Fitting/FitPrintService.cpp +++ b/Sim/Fitting/FitPrintService.cpp @@ -87,7 +87,7 @@ std::string FitPrintService::parameterString(const FitObjective& objective) const auto length = length_of_longest_name(params); for (const auto& par : params) { - result << BaseUtils::String::padRight(par.name(), length) << std::scientific + result << BaseUtil::String::padRight(par.name(), length) << std::scientific << std::setprecision(6) << " " << par.startValue() << " " << par.limits().toString() << " " << par.value() << "\n"; } diff --git a/Sim/Simulation/ISimulation.cpp b/Sim/Simulation/ISimulation.cpp index 5174f460105..9b0cc279177 100644 --- a/Sim/Simulation/ISimulation.cpp +++ b/Sim/Simulation/ISimulation.cpp @@ -256,6 +256,6 @@ void ISimulation::runSingleSimulation(const ReSample& re_sample, size_t batch_st // Check successful completion. if (!failure_messages.empty()) throw std::runtime_error("Unexpected error(s) in simulation thread(s):\n" - + BaseUtils::String::join(failure_messages, "\n")); + + BaseUtil::String::join(failure_messages, "\n")); } } diff --git a/Tests/Functional/Consistence/CompareTwoReferences.cpp b/Tests/Functional/Consistence/CompareTwoReferences.cpp index 905a0b664ac..1e8c6269b02 100644 --- a/Tests/Functional/Consistence/CompareTwoReferences.cpp +++ b/Tests/Functional/Consistence/CompareTwoReferences.cpp @@ -27,7 +27,7 @@ std::unique_ptr<Datafield> load(const std::string& name) { ASSERT(!name.empty()); const std::string path = - BaseUtils::Filesystem::jointPath(BATesting::ReferenceDir_Suite(), name + ".int.gz"); + BaseUtil::Filesystem::jointPath(BATesting::ReferenceDir_Suite(), name + ".int.gz"); std::unique_ptr<Datafield> data; try { data.reset(IOFactory::readDatafield(path)); diff --git a/Tests/Functional/CoreSpecial/CoreIOPathTest.cpp b/Tests/Functional/CoreSpecial/CoreIOPathTest.cpp index 56b6d680664..6e9b9c5fff7 100644 --- a/Tests/Functional/CoreSpecial/CoreIOPathTest.cpp +++ b/Tests/Functional/CoreSpecial/CoreIOPathTest.cpp @@ -51,7 +51,7 @@ TEST(CoreIOPathTest, CoreIOPath) const std::filesystem::path test_dir(BATesting::TestOutDir_Core()); - BaseUtils::Filesystem::createDirectories(test_dir.string()); + BaseUtil::Filesystem::createDirectories(test_dir.string()); // tests file writing when file name contains cyrillic characters std::filesystem::path test_file(filename_rus); @@ -59,6 +59,6 @@ TEST(CoreIOPathTest, CoreIOPath) // tests file writing and directory creation when dirname contains cyrillic characters std::filesystem::path test_subdir_rus(dirname_rus); - BaseUtils::Filesystem::createDirectories((test_dir / test_subdir_rus).string()); + BaseUtil::Filesystem::createDirectories((test_dir / test_subdir_rus).string()); EXPECT_TRUE(test_io(data.get(), (test_dir / test_subdir_rus / test_file).string())); } diff --git a/Tests/Functional/CoreSpecial/FourierTransformationTest.cpp b/Tests/Functional/CoreSpecial/FourierTransformationTest.cpp index 04bb2372695..c5ac93c9b35 100644 --- a/Tests/Functional/CoreSpecial/FourierTransformationTest.cpp +++ b/Tests/Functional/CoreSpecial/FourierTransformationTest.cpp @@ -30,9 +30,9 @@ const double threshold = 1e-10; //! Returns name of fft image based on given image name. std::string fftReferenceImage(const std::string& input_image) { - auto filename = BaseUtils::Filesystem::filename(input_image); - return BaseUtils::Filesystem::jointPath(BATesting::ReferenceDir_CoreSpecial(), - "FourierTransformation_" + filename); + auto filename = BaseUtil::Filesystem::filename(input_image); + return BaseUtil::Filesystem::jointPath(BATesting::ReferenceDir_CoreSpecial(), + "FourierTransformation_" + filename); } //! Runs test over one image. Returns true upon success. @@ -45,7 +45,7 @@ bool test_fft(const std::string& input_image_name, const std::string& reference_ std::unique_ptr<Datafield> input_image; try { const auto filename = - BaseUtils::Filesystem::jointPath(BATesting::ReferenceDir_Suite(), input_image_name); + BaseUtil::Filesystem::jointPath(BATesting::ReferenceDir_Suite(), input_image_name); input_image.reset(IOFactory::readDatafield(filename)); } catch (const std::exception&) { std::cout << "Error: no input image.\n"; @@ -53,7 +53,7 @@ bool test_fft(const std::string& input_image_name, const std::string& reference_ } std::cout << "transforming" << std::endl; - std::unique_ptr<Datafield> fft = DataUtils::Data::createFFT(*input_image); + std::unique_ptr<Datafield> fft = DataUtil::Data::createFFT(*input_image); std::cout << "loading reference" << std::endl; std::unique_ptr<Datafield> reference_fft; @@ -70,9 +70,9 @@ bool test_fft(const std::string& input_image_name, const std::string& reference_ DiffUtil::meanRelVecDiff(fft->flatVector(), reference_fft->flatVector()) <= threshold; if (!success) { - BaseUtils::Filesystem::createDirectory(BATesting::TestOutDir_Core()); - std::string out_fname = BaseUtils::Filesystem::jointPath( - BATesting::TestOutDir_Core(), BaseUtils::Filesystem::filename(reference_fft_name)); + BaseUtil::Filesystem::createDirectory(BATesting::TestOutDir_Core()); + std::string out_fname = BaseUtil::Filesystem::jointPath( + BATesting::TestOutDir_Core(), BaseUtil::Filesystem::filename(reference_fft_name)); IOFactory::writeDatafield(*fft, out_fname); std::cout << "New fft image stored in " << out_fname << std::endl; } diff --git a/Tests/Suite/GUI/Check.cpp b/Tests/Suite/GUI/Check.cpp index 56e1a0c2aa4..abc837cc548 100644 --- a/Tests/Suite/GUI/Check.cpp +++ b/Tests/Suite/GUI/Check.cpp @@ -66,7 +66,7 @@ bool checkSimulation(const std::string& name, ISimulation& sim, const double lim // Save simulation, as it differs from reference. const auto dir = fs::path(BATesting::TestOutDir()) / fs::path("Suite") / fs::path("GUI"); - BaseUtils::Filesystem::createDirectories(dir.string()); + BaseUtil::Filesystem::createDirectories(dir.string()); const std::map<const std::string, const SimulationResult&> tosave{{"gui", data2}, {"std", ref_data}}; diff --git a/Tests/Suite/Persist/Check.cpp b/Tests/Suite/Persist/Check.cpp index 80fa5da91bd..d404783a415 100644 --- a/Tests/Suite/Persist/Check.cpp +++ b/Tests/Suite/Persist/Check.cpp @@ -36,7 +36,7 @@ bool checkSimulation(const std::string& name, ISimulation& direct_simulation, co ASSERT(!name.empty()); try { const std::string refPath = - BaseUtils::Filesystem::jointPath(BATesting::ReferenceDir_Suite(), name + ".int.gz"); + BaseUtil::Filesystem::jointPath(BATesting::ReferenceDir_Suite(), name + ".int.gz"); std::cout << "- reference: " << refPath << "\n"; reference.reset(IOFactory::readDatafield(refPath)); } catch (const std::exception&) { @@ -56,9 +56,9 @@ bool checkSimulation(const std::string& name, ISimulation& direct_simulation, co } // Save simulation, as it differs from reference. - BaseUtils::Filesystem::createDirectories(BATesting::TestOutDir_Suite()); + BaseUtil::Filesystem::createDirectories(BATesting::TestOutDir_Suite()); std::string out_fname = - BaseUtils::Filesystem::jointPath(BATesting::TestOutDir_Suite(), name + ".int.gz"); + BaseUtil::Filesystem::jointPath(BATesting::TestOutDir_Suite(), name + ".int.gz"); IOFactory::writeDatafield(result_data, out_fname); std::cout << "Notes:\n- to visualize an intensity map, use " << BABuild::srcDir() << "/devtools/view/plot-int.py\n" diff --git a/Tests/Suite/Py/Check.cpp b/Tests/Suite/Py/Check.cpp index 00b70587e0b..4be8023dd05 100644 --- a/Tests/Suite/Py/Check.cpp +++ b/Tests/Suite/Py/Check.cpp @@ -32,7 +32,7 @@ namespace { std::vector<double> domainData(const std::string& test_name, const ISimulation& direct_simulation) { const auto dir = fs::path(BATesting::TestOutDir()) / fs::path("Suite") / fs::path("Py"); - BaseUtils::Filesystem::createDirectories(dir.string()); + BaseUtil::Filesystem::createDirectories(dir.string()); const std::string output_path = (dir / fs::path(test_name + ".ref.int.gz")).string(); std::remove(output_path.c_str()); diff --git a/Tests/Unit/Base/Concat.cpp b/Tests/Unit/Base/Concat.cpp index 5a55151de71..8a74d7f35c2 100644 --- a/Tests/Unit/Base/Concat.cpp +++ b/Tests/Unit/Base/Concat.cpp @@ -9,10 +9,10 @@ TEST(ConcatTest, SimpleType) std::vector<int> B{4, 5}; std::vector<int> N; - EXPECT_EQ(BaseUtils::algo::concat(A, B), (std::vector<int>{1, 2, 3, 4, 5})); - EXPECT_EQ(BaseUtils::algo::concat(A, A), (std::vector<int>{1, 2, 3, 1, 2, 3})); - EXPECT_EQ(BaseUtils::algo::concat(A, N), A); - EXPECT_EQ(BaseUtils::algo::concat(N, B), B); + EXPECT_EQ(BaseUtil::algo::concat(A, B), (std::vector<int>{1, 2, 3, 4, 5})); + EXPECT_EQ(BaseUtil::algo::concat(A, A), (std::vector<int>{1, 2, 3, 1, 2, 3})); + EXPECT_EQ(BaseUtil::algo::concat(A, N), A); + EXPECT_EQ(BaseUtil::algo::concat(N, B), B); } TEST(ConcatTest, Struct) @@ -27,8 +27,8 @@ TEST(ConcatTest, Struct) V B{{"b", 2.}, {"c", .3}}; V N; - EXPECT_EQ(BaseUtils::algo::concat(A, B), (V{{"a", 11.}, {"b", 2.}, {"c", .3}})); - EXPECT_EQ(BaseUtils::algo::concat(A, A), (V{{"a", 11.}, {"a", 11.}})); - EXPECT_EQ(BaseUtils::algo::concat(A, N), A); - EXPECT_EQ(BaseUtils::algo::concat(N, B), B); + EXPECT_EQ(BaseUtil::algo::concat(A, B), (V{{"a", 11.}, {"b", 2.}, {"c", .3}})); + EXPECT_EQ(BaseUtil::algo::concat(A, A), (V{{"a", 11.}, {"a", 11.}})); + EXPECT_EQ(BaseUtil::algo::concat(A, N), A); + EXPECT_EQ(BaseUtil::algo::concat(N, B), B); } diff --git a/Tests/Unit/Base/FileSystemUtilsTest.cpp b/Tests/Unit/Base/FileSystemUtilsTest.cpp index e67e67b30c1..b8234ec6dde 100644 --- a/Tests/Unit/Base/FileSystemUtilsTest.cpp +++ b/Tests/Unit/Base/FileSystemUtilsTest.cpp @@ -8,7 +8,7 @@ class FileSystemUtilsTest : public ::testing::Test { protected: void SetUp() override { - BaseUtils::Filesystem::createDirectories(BATesting::TestOutDir_Core()); + BaseUtil::Filesystem::createDirectories(BATesting::TestOutDir_Core()); ASSERT_TRUE(std::filesystem::exists(BATesting::TestOutDir_Core())); ASSERT_TRUE(assureNonExistingTestCasePath()); } @@ -28,7 +28,7 @@ protected: std::string testCasePath() const { - return BaseUtils::Filesystem::jointPath(BATesting::TestOutDir_Core(), testCaseFolderName()); + return BaseUtil::Filesystem::jointPath(BATesting::TestOutDir_Core(), testCaseFolderName()); } //! Assures the test case specific path is not existent. Removes it if necessary. @@ -44,106 +44,106 @@ protected: TEST_F(FileSystemUtilsTest, extension) { - EXPECT_EQ(BaseUtils::Filesystem::extension(""), ""); - EXPECT_EQ(BaseUtils::Filesystem::extension("/home/james/"), ""); - EXPECT_EQ(BaseUtils::Filesystem::extension("/home/james/."), ""); - EXPECT_EQ(BaseUtils::Filesystem::extension("/home/james/.."), ""); - EXPECT_EQ(BaseUtils::Filesystem::extension("/home/james/.hidden"), ""); - EXPECT_EQ(BaseUtils::Filesystem::extension("/home/james/.hidden.txt"), ".txt"); - EXPECT_EQ(BaseUtils::Filesystem::extension("/home/james/file.txt"), ".txt"); - EXPECT_EQ(BaseUtils::Filesystem::extension("/home/james/file.txt.gz"), ".gz"); - EXPECT_EQ(BaseUtils::Filesystem::extension("/home/james/file.txt.GZ"), ".GZ"); + EXPECT_EQ(BaseUtil::Filesystem::extension(""), ""); + EXPECT_EQ(BaseUtil::Filesystem::extension("/home/james/"), ""); + EXPECT_EQ(BaseUtil::Filesystem::extension("/home/james/."), ""); + EXPECT_EQ(BaseUtil::Filesystem::extension("/home/james/.."), ""); + EXPECT_EQ(BaseUtil::Filesystem::extension("/home/james/.hidden"), ""); + EXPECT_EQ(BaseUtil::Filesystem::extension("/home/james/.hidden.txt"), ".txt"); + EXPECT_EQ(BaseUtil::Filesystem::extension("/home/james/file.txt"), ".txt"); + EXPECT_EQ(BaseUtil::Filesystem::extension("/home/james/file.txt.gz"), ".gz"); + EXPECT_EQ(BaseUtil::Filesystem::extension("/home/james/file.txt.GZ"), ".GZ"); } TEST_F(FileSystemUtilsTest, hasExtension) { - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("", "")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/", "")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/.", "")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/..", "")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/.hidden", "")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/.hidden.txt", ".txt")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/file.txt", ".txt")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/file.TXT", ".txt")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/file.txt.gz", ".gz")); - EXPECT_TRUE(BaseUtils::Filesystem::hasExtension("/home/james/file.TXT.GZ", ".gz")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("", "")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/", "")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/.", "")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/..", "")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/.hidden", "")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/.hidden.txt", ".txt")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/file.txt", ".txt")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/file.TXT", ".txt")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/file.txt.gz", ".gz")); + EXPECT_TRUE(BaseUtil::Filesystem::hasExtension("/home/james/file.TXT.GZ", ".gz")); } TEST_F(FileSystemUtilsTest, extensions) { - EXPECT_EQ(BaseUtils::Filesystem::extensions(""), ""); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/"), ""); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/."), ""); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/.."), ""); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/.hidden"), ""); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/.hidden.txt"), ".txt"); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/.hidden.txt.gz"), ".txt.gz"); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/f"), ""); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/f.txt"), ".txt"); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/file.txt"), ".txt"); - EXPECT_EQ(BaseUtils::Filesystem::extensions("/home/james/file.txt.gz"), ".txt.gz"); + EXPECT_EQ(BaseUtil::Filesystem::extensions(""), ""); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/"), ""); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/."), ""); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/.."), ""); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/.hidden"), ""); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/.hidden.txt"), ".txt"); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/.hidden.txt.gz"), ".txt.gz"); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/f"), ""); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/f.txt"), ".txt"); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/file.txt"), ".txt"); + EXPECT_EQ(BaseUtil::Filesystem::extensions("/home/james/file.txt.gz"), ".txt.gz"); } TEST_F(FileSystemUtilsTest, filename) { - EXPECT_EQ(BaseUtils::Filesystem::filename(""), ""); - EXPECT_EQ(BaseUtils::Filesystem::filename("/home/james/"), ""); - EXPECT_EQ(BaseUtils::Filesystem::filename("/home/james/."), "."); // sic! according to C++17 - EXPECT_EQ(BaseUtils::Filesystem::filename("/home/james/.."), ".."); // sic! according to C++17 - EXPECT_EQ(BaseUtils::Filesystem::filename("/home/james/.hidden"), ".hidden"); - EXPECT_EQ(BaseUtils::Filesystem::filename("/home/james/file.txt"), "file.txt"); - EXPECT_EQ(BaseUtils::Filesystem::filename("/home/james/file"), "file"); + EXPECT_EQ(BaseUtil::Filesystem::filename(""), ""); + EXPECT_EQ(BaseUtil::Filesystem::filename("/home/james/"), ""); + EXPECT_EQ(BaseUtil::Filesystem::filename("/home/james/."), "."); // sic! according to C++17 + EXPECT_EQ(BaseUtil::Filesystem::filename("/home/james/.."), ".."); // sic! according to C++17 + EXPECT_EQ(BaseUtil::Filesystem::filename("/home/james/.hidden"), ".hidden"); + EXPECT_EQ(BaseUtil::Filesystem::filename("/home/james/file.txt"), "file.txt"); + EXPECT_EQ(BaseUtil::Filesystem::filename("/home/james/file"), "file"); } TEST_F(FileSystemUtilsTest, stem) { - EXPECT_EQ(BaseUtils::Filesystem::stem(""), ""); - EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/"), ""); - EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/."), "."); - EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/.."), ".."); - EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/.hidden"), ".hidden"); - EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/.hidden.txt"), ".hidden"); - EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/.hidden.txt.gz"), ".hidden.txt"); - EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/filename.txt"), "filename"); - EXPECT_EQ(BaseUtils::Filesystem::stem("/home/james/filename.txt.gz"), "filename.txt"); + EXPECT_EQ(BaseUtil::Filesystem::stem(""), ""); + EXPECT_EQ(BaseUtil::Filesystem::stem("/home/james/"), ""); + EXPECT_EQ(BaseUtil::Filesystem::stem("/home/james/."), "."); + EXPECT_EQ(BaseUtil::Filesystem::stem("/home/james/.."), ".."); + EXPECT_EQ(BaseUtil::Filesystem::stem("/home/james/.hidden"), ".hidden"); + EXPECT_EQ(BaseUtil::Filesystem::stem("/home/james/.hidden.txt"), ".hidden"); + EXPECT_EQ(BaseUtil::Filesystem::stem("/home/james/.hidden.txt.gz"), ".hidden.txt"); + EXPECT_EQ(BaseUtil::Filesystem::stem("/home/james/filename.txt"), "filename"); + EXPECT_EQ(BaseUtil::Filesystem::stem("/home/james/filename.txt.gz"), "filename.txt"); } TEST_F(FileSystemUtilsTest, StemAndExtension) { - EXPECT_EQ(BaseUtils::Filesystem::stem_ext(""), ""); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/"), ""); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/."), "."); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/.."), ".."); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/.hidden"), ".hidden"); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/.hidden.txt"), ".hidden"); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/.hidden.txt.gz"), ".hidden"); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/filename"), "filename"); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/filename.txt"), "filename"); - EXPECT_EQ(BaseUtils::Filesystem::stem_ext("/home/james/filename.txt.gz"), "filename"); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext(""), ""); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/"), ""); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/."), "."); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/.."), ".."); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/.hidden"), ".hidden"); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/.hidden.txt"), ".hidden"); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/.hidden.txt.gz"), ".hidden"); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/filename"), "filename"); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/filename.txt"), "filename"); + EXPECT_EQ(BaseUtil::Filesystem::stem_ext("/home/james/filename.txt.gz"), "filename"); } TEST_F(FileSystemUtilsTest, createDirectory) { // with absolute path - EXPECT_TRUE(BaseUtils::Filesystem::createDirectory(testCasePath())); - EXPECT_FALSE(BaseUtils::Filesystem::createDirectory(testCasePath())); + EXPECT_TRUE(BaseUtil::Filesystem::createDirectory(testCasePath())); + EXPECT_FALSE(BaseUtil::Filesystem::createDirectory(testCasePath())); // with relative path std::filesystem::current_path(testCasePath()); - EXPECT_TRUE(BaseUtils::Filesystem::createDirectory("sub")); - EXPECT_FALSE(BaseUtils::Filesystem::createDirectory("sub")); + EXPECT_TRUE(BaseUtil::Filesystem::createDirectory("sub")); + EXPECT_FALSE(BaseUtil::Filesystem::createDirectory("sub")); EXPECT_TRUE(std::filesystem::exists("sub")); - EXPECT_TRUE(std::filesystem::exists(BaseUtils::Filesystem::jointPath(testCasePath(), "sub"))); + EXPECT_TRUE(std::filesystem::exists(BaseUtil::Filesystem::jointPath(testCasePath(), "sub"))); } TEST_F(FileSystemUtilsTest, createDirectories) { // with absolute path - const auto sub1 = BaseUtils::Filesystem::jointPath(testCasePath(), "sub1"); - const auto sub2 = BaseUtils::Filesystem::jointPath(sub1, "sub2"); + const auto sub1 = BaseUtil::Filesystem::jointPath(testCasePath(), "sub1"); + const auto sub2 = BaseUtil::Filesystem::jointPath(sub1, "sub2"); - EXPECT_TRUE(BaseUtils::Filesystem::createDirectories(sub2)); - EXPECT_FALSE(BaseUtils::Filesystem::createDirectories(sub2)); + EXPECT_TRUE(BaseUtil::Filesystem::createDirectories(sub2)); + EXPECT_FALSE(BaseUtil::Filesystem::createDirectories(sub2)); EXPECT_TRUE(std::filesystem::exists(testCasePath())); EXPECT_TRUE(std::filesystem::exists(sub1)); EXPECT_TRUE(std::filesystem::exists(sub2)); @@ -151,33 +151,33 @@ TEST_F(FileSystemUtilsTest, createDirectories) // with relative path const auto* const sub4 = "sub3/sub4"; std::filesystem::current_path(sub2); - EXPECT_TRUE(BaseUtils::Filesystem::createDirectories(sub4)); - EXPECT_FALSE(BaseUtils::Filesystem::createDirectories(sub4)); + EXPECT_TRUE(BaseUtil::Filesystem::createDirectories(sub4)); + EXPECT_FALSE(BaseUtil::Filesystem::createDirectories(sub4)); EXPECT_TRUE(std::filesystem::exists("sub3")); EXPECT_TRUE(std::filesystem::exists("sub3/sub4")); - EXPECT_TRUE(std::filesystem::exists(BaseUtils::Filesystem::jointPath(sub2, sub4))); + EXPECT_TRUE(std::filesystem::exists(BaseUtil::Filesystem::jointPath(sub2, sub4))); } TEST_F(FileSystemUtilsTest, jointPath) { #ifdef _WIN32 - EXPECT_EQ(BaseUtils::Filesystem::jointPath("a", "b"), "a\\b"); + EXPECT_EQ(BaseUtil::Filesystem::jointPath("a", "b"), "a\\b"); #else - EXPECT_EQ(BaseUtils::Filesystem::jointPath("a", "b"), "a/b"); + EXPECT_EQ(BaseUtil::Filesystem::jointPath("a", "b"), "a/b"); #endif - EXPECT_FAILED_ASSERT(BaseUtils::Filesystem::jointPath("", "")); - EXPECT_FAILED_ASSERT(BaseUtils::Filesystem::jointPath("a", "")); - EXPECT_EQ(BaseUtils::Filesystem::jointPath("", "b"), "b"); + EXPECT_FAILED_ASSERT(BaseUtil::Filesystem::jointPath("", "")); + EXPECT_FAILED_ASSERT(BaseUtil::Filesystem::jointPath("a", "")); + EXPECT_EQ(BaseUtil::Filesystem::jointPath("", "b"), "b"); } TEST_F(FileSystemUtilsTest, filesInDirectoryIsFileExists) { - EXPECT_ANY_THROW(BaseUtils::Filesystem::filesInDirectory("non-existent/directory")); + EXPECT_ANY_THROW(BaseUtil::Filesystem::filesInDirectory("non-existent/directory")); // assure clean preconditions - ASSERT_TRUE(BaseUtils::Filesystem::createDirectories(testCasePath())); - ASSERT_TRUE(BaseUtils::Filesystem::filesInDirectory(testCasePath()).empty()); + ASSERT_TRUE(BaseUtil::Filesystem::createDirectories(testCasePath())); + ASSERT_TRUE(BaseUtil::Filesystem::filesInDirectory(testCasePath()).empty()); // create a few files std::filesystem::current_path(testCasePath()); @@ -185,16 +185,16 @@ TEST_F(FileSystemUtilsTest, filesInDirectoryIsFileExists) std::ofstream("file2.txt"); std::ofstream("file3.txt"); - EXPECT_EQ(BaseUtils::Filesystem::filesInDirectory(testCasePath()).size(), 3uL); // abs - EXPECT_EQ(BaseUtils::Filesystem::filesInDirectory(".").size(), 3uL); // rel - const auto files = BaseUtils::Filesystem::filesInDirectory("."); + EXPECT_EQ(BaseUtil::Filesystem::filesInDirectory(testCasePath()).size(), 3uL); // abs + EXPECT_EQ(BaseUtil::Filesystem::filesInDirectory(".").size(), 3uL); // rel + const auto files = BaseUtil::Filesystem::filesInDirectory("."); EXPECT_TRUE(std::find(files.begin(), files.end(), "file1.txt") != files.end()); EXPECT_TRUE(std::find(files.begin(), files.end(), "file2.txt") != files.end()); EXPECT_TRUE(std::find(files.begin(), files.end(), "file3.txt") != files.end()); // tests for IsFileExists - EXPECT_TRUE(BaseUtils::Filesystem::IsFileExists("file1.txt")); - EXPECT_TRUE(BaseUtils::Filesystem::IsFileExists("file2.txt")); - EXPECT_TRUE(BaseUtils::Filesystem::IsFileExists("file3.txt")); - EXPECT_FALSE(BaseUtils::Filesystem::IsFileExists("nonexisting.txt")); + EXPECT_TRUE(BaseUtil::Filesystem::IsFileExists("file1.txt")); + EXPECT_TRUE(BaseUtil::Filesystem::IsFileExists("file2.txt")); + EXPECT_TRUE(BaseUtil::Filesystem::IsFileExists("file3.txt")); + EXPECT_FALSE(BaseUtil::Filesystem::IsFileExists("nonexisting.txt")); } diff --git a/Tests/Unit/Base/MinMaxValueTest.cpp b/Tests/Unit/Base/MinMaxValueTest.cpp index 886ee8bb845..1be7f33007a 100644 --- a/Tests/Unit/Base/MinMaxValueTest.cpp +++ b/Tests/Unit/Base/MinMaxValueTest.cpp @@ -9,24 +9,24 @@ TEST(MinMaxValueTest, MinMaxValueAlmostEq) std::vector<int> C{1, 2, 3}; val = - BaseUtils::algo::min_value(A.begin(), A.end(), [](const double& x) -> double { return x; }); + BaseUtil::algo::min_value(A.begin(), A.end(), [](const double& x) -> double { return x; }); EXPECT_EQ(val, 0.); - val = BaseUtils::algo::max_value(A.begin(), A.end(), - [](const double& x) -> double { return 2 + x; }); + val = BaseUtil::algo::max_value(A.begin(), A.end(), + [](const double& x) -> double { return 2 + x; }); EXPECT_NEAR(val, 2., 1e-15); - val = BaseUtils::algo::min_value(C.begin(), C.end(), [](const int& i) -> double { return i; }); + val = BaseUtil::algo::min_value(C.begin(), C.end(), [](const int& i) -> double { return i; }); EXPECT_EQ(val, 1); - val = BaseUtils::algo::min_value(C.begin(), C.end(), [](const int& i) -> double { return -i; }); + val = BaseUtil::algo::min_value(C.begin(), C.end(), [](const int& i) -> double { return -i; }); EXPECT_EQ(val, -3); - val = BaseUtils::algo::min_value(C.begin(), C.end(), - [](const int& i) -> double { return pow(i - 2.1, 2); }); + val = BaseUtil::algo::min_value(C.begin(), C.end(), + [](const int& i) -> double { return pow(i - 2.1, 2); }); EXPECT_NEAR(val, 0.01, 1e-13); - val = BaseUtils::algo::max_value(C.begin(), C.end(), [](const int& i) -> double { return i; }); + val = BaseUtil::algo::max_value(C.begin(), C.end(), [](const int& i) -> double { return i; }); EXPECT_EQ(val, 3); - val = BaseUtils::algo::max_value(C.begin(), C.end(), [](const int& i) -> double { return -i; }); + val = BaseUtil::algo::max_value(C.begin(), C.end(), [](const int& i) -> double { return -i; }); EXPECT_EQ(val, -1); - val = BaseUtils::algo::max_value(C.begin(), C.end(), - [](const int& i) -> double { return -pow(i - 2.1, 2); }); + val = BaseUtil::algo::max_value(C.begin(), C.end(), + [](const int& i) -> double { return -pow(i - 2.1, 2); }); EXPECT_NEAR(val, -0.01, 1e-13); } diff --git a/Tests/Unit/Base/StringUtilsTest.cpp b/Tests/Unit/Base/StringUtilsTest.cpp index ec60f3ce8b7..cdaef8a43c0 100644 --- a/Tests/Unit/Base/StringUtilsTest.cpp +++ b/Tests/Unit/Base/StringUtilsTest.cpp @@ -4,91 +4,91 @@ TEST(StringUtilsTest, toInt) { - EXPECT_TRUE(BaseUtils::String::to_int("1", nullptr)); - EXPECT_FALSE(BaseUtils::String::to_int("a", nullptr)); + EXPECT_TRUE(BaseUtil::String::to_int("1", nullptr)); + EXPECT_FALSE(BaseUtil::String::to_int("a", nullptr)); int v = 2; - EXPECT_FALSE(BaseUtils::String::to_int("", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int(" ", &v)); + EXPECT_FALSE(BaseUtil::String::to_int(" ", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("r", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("r", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("1r", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("1r", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("1r ", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("1r ", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("r1", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("r1", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("1 r", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("1 r", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("r 1", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("r 1", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("111111111111111111111111111111111", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("111111111111111111111111111111111", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("1\t", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("1\t", &v)); EXPECT_EQ(v, 2); - EXPECT_FALSE(BaseUtils::String::to_int("\t1", &v)); + EXPECT_FALSE(BaseUtil::String::to_int("\t1", &v)); EXPECT_EQ(v, 2); - EXPECT_TRUE(BaseUtils::String::to_int("1", &v)); + EXPECT_TRUE(BaseUtil::String::to_int("1", &v)); EXPECT_EQ(v, 1); - EXPECT_TRUE(BaseUtils::String::to_int(" 2", &v)); + EXPECT_TRUE(BaseUtil::String::to_int(" 2", &v)); EXPECT_EQ(v, 2); - EXPECT_TRUE(BaseUtils::String::to_int(" 3 ", &v)); + EXPECT_TRUE(BaseUtil::String::to_int(" 3 ", &v)); EXPECT_EQ(v, 3); - EXPECT_TRUE(BaseUtils::String::to_int("4 ", &v)); + EXPECT_TRUE(BaseUtil::String::to_int("4 ", &v)); EXPECT_EQ(v, 4); - EXPECT_TRUE(BaseUtils::String::to_int("01", &v)); + EXPECT_TRUE(BaseUtil::String::to_int("01", &v)); EXPECT_EQ(v, 1); - EXPECT_TRUE(BaseUtils::String::to_int("0000", &v)); + EXPECT_TRUE(BaseUtil::String::to_int("0000", &v)); EXPECT_EQ(v, 0); - EXPECT_TRUE(BaseUtils::String::to_int("65535", &v)); + EXPECT_TRUE(BaseUtil::String::to_int("65535", &v)); EXPECT_EQ(v, 65535); - EXPECT_TRUE(BaseUtils::String::to_int("-10", &v)); + EXPECT_TRUE(BaseUtil::String::to_int("-10", &v)); EXPECT_EQ(v, -10); - EXPECT_TRUE(BaseUtils::String::to_int(" -20 ", &v)); + EXPECT_TRUE(BaseUtil::String::to_int(" -20 ", &v)); EXPECT_EQ(v, -20); } TEST(StringUtilsTest, trimFront) { - EXPECT_EQ(BaseUtils::String::trimFront(" "), ""); - EXPECT_EQ(BaseUtils::String::trimFront(" a"), "a"); - EXPECT_EQ(BaseUtils::String::trimFront("\t a"), "a"); - EXPECT_EQ(BaseUtils::String::trimFront("\t a", " "), "\t a"); - EXPECT_EQ(BaseUtils::String::trimFront("\t\ta"), "a"); - EXPECT_EQ(BaseUtils::String::trimFront("a "), "a "); + EXPECT_EQ(BaseUtil::String::trimFront(" "), ""); + EXPECT_EQ(BaseUtil::String::trimFront(" a"), "a"); + EXPECT_EQ(BaseUtil::String::trimFront("\t a"), "a"); + EXPECT_EQ(BaseUtil::String::trimFront("\t a", " "), "\t a"); + EXPECT_EQ(BaseUtil::String::trimFront("\t\ta"), "a"); + EXPECT_EQ(BaseUtil::String::trimFront("a "), "a "); } TEST(StringUtilsTest, startsWith) { - EXPECT_TRUE(BaseUtils::String::startsWith("a", "a")); - EXPECT_TRUE(BaseUtils::String::startsWith("ab", "a")); - EXPECT_TRUE(BaseUtils::String::startsWith(" a", " a")); - EXPECT_TRUE(BaseUtils::String::startsWith("abc", "ab")); - EXPECT_TRUE(BaseUtils::String::startsWith("\tabc", "\t")); - EXPECT_TRUE(BaseUtils::String::startsWith("abc", "")); - - EXPECT_FALSE(BaseUtils::String::startsWith("ab", "abc")); - EXPECT_FALSE(BaseUtils::String::startsWith("abc", "A")); - EXPECT_FALSE(BaseUtils::String::startsWith(" a", "a")); + EXPECT_TRUE(BaseUtil::String::startsWith("a", "a")); + EXPECT_TRUE(BaseUtil::String::startsWith("ab", "a")); + EXPECT_TRUE(BaseUtil::String::startsWith(" a", " a")); + EXPECT_TRUE(BaseUtil::String::startsWith("abc", "ab")); + EXPECT_TRUE(BaseUtil::String::startsWith("\tabc", "\t")); + EXPECT_TRUE(BaseUtil::String::startsWith("abc", "")); + + EXPECT_FALSE(BaseUtil::String::startsWith("ab", "abc")); + EXPECT_FALSE(BaseUtil::String::startsWith("abc", "A")); + EXPECT_FALSE(BaseUtil::String::startsWith(" a", "a")); } diff --git a/Tests/Unit/Device/ArrayUtilsTest.cpp b/Tests/Unit/Device/ArrayUtilsTest.cpp index 7ef8f9005aa..4e923b51174 100644 --- a/Tests/Unit/Device/ArrayUtilsTest.cpp +++ b/Tests/Unit/Device/ArrayUtilsTest.cpp @@ -8,7 +8,7 @@ TEST(ArrayUtilsTest, DatafieldFromVector1D) { // double const std::vector<double> vec_double = {10.0, 20.0, 30.0, 40.0}; - auto data1 = DataUtils::Array::createPField1D(vec_double); + auto data1 = DataUtil::Array::createPField1D(vec_double); EXPECT_EQ(data1->size(), vec_double.size()); EXPECT_EQ(data1->flatVector(), vec_double); @@ -22,7 +22,7 @@ TEST(ArrayUtilsTest, DatafieldToVector1D) Datafield data({new FixedBinAxis("axis0", 4, 10.0, 20.0)}); data.setVector(expected); - auto vec = DataUtils::Array::createVector1D(data); + auto vec = DataUtil::Array::createVector1D(data); EXPECT_EQ(vec.size(), data.size()); EXPECT_EQ(vec, expected); @@ -32,7 +32,7 @@ TEST(ArrayUtilsTest, DatafieldFromVector2D) { const std::vector<std::vector<double>> vec_double = { {0.0, 1.0, 2.0, 3.0}, {4.0, 5.0, 6.0, 7.0}, {8.0, 9.0, 10.0, 11.0}}; - auto data = DataUtils::Array::createPField2D(vec_double); + auto data = DataUtil::Array::createPField2D(vec_double); EXPECT_EQ(data->rank(), 2u); EXPECT_EQ(data->size(), 12u); @@ -58,7 +58,7 @@ TEST(ArrayUtilsTest, DatafieldToVector2D) data.setVector(values); - auto vec = DataUtils::Array::createVector2D(data); + auto vec = DataUtil::Array::createVector2D(data); const std::vector<std::vector<double>> expected = { {0.0, 1.0, 2.0, 3.0}, {4.0, 5.0, 6.0, 7.0}, {8.0, 9.0, 10.0, 11.0}}; EXPECT_EQ(vec, expected); diff --git a/Tests/Unit/Device/FixedBinAxisTest.cpp b/Tests/Unit/Device/FixedBinAxisTest.cpp index a7541208919..dc01563fe4f 100644 --- a/Tests/Unit/Device/FixedBinAxisTest.cpp +++ b/Tests/Unit/Device/FixedBinAxisTest.cpp @@ -117,7 +117,7 @@ TEST(FixedBinAxisTest, IOStream) oss << axis; std::istringstream iss(oss.str()); - std::unique_ptr<IAxis> result(DataUtils::Format::createAxis(iss)); + std::unique_ptr<IAxis> result(DataUtil::Format::createAxis(iss)); EXPECT_TRUE(axis == *result); } diff --git a/Tests/Unit/Device/IntensityDataFunctionsTest.cpp b/Tests/Unit/Device/IntensityDataFunctionsTest.cpp index 393aab135d9..9acfcbcc184 100644 --- a/Tests/Unit/Device/IntensityDataFunctionsTest.cpp +++ b/Tests/Unit/Device/IntensityDataFunctionsTest.cpp @@ -5,14 +5,13 @@ #include "Device/Data/Datafield.h" #include "Tests/GTestWrapper/google_test.h" -TEST(DataUtilsTest, createRearrangedDataSet) +TEST(DataUtilTest, createRearrangedDataSet) { Datafield input_data{ {new FixedBinAxis("axis0", 2, 1.0, 2.0), new FixedBinAxis("axis1", 3, 3.0, 4.0)}}; input_data.setVector(std::vector<double>{1.0, 2.0, 3.0, 4.0, 5.0, 6.0}); - std::unique_ptr<Datafield> output_data = - DataUtils::Data::createRearrangedDataSet(input_data, 5); + std::unique_ptr<Datafield> output_data = DataUtil::Data::createRearrangedDataSet(input_data, 5); EXPECT_EQ(size_t(3), output_data->axis(0).size()); EXPECT_EQ(size_t(2), output_data->axis(1).size()); @@ -24,7 +23,7 @@ TEST(DataUtilsTest, createRearrangedDataSet) EXPECT_EQ(input_data[0], (*output_data)[4]); EXPECT_EQ(input_data[3], (*output_data)[5]); - output_data = DataUtils::Data::createRearrangedDataSet(input_data, -6); + output_data = DataUtil::Data::createRearrangedDataSet(input_data, -6); EXPECT_EQ(size_t(2), output_data->axis(0).size()); EXPECT_EQ(size_t(3), output_data->axis(1).size()); @@ -36,7 +35,7 @@ TEST(DataUtilsTest, createRearrangedDataSet) EXPECT_EQ(input_data[1], (*output_data)[4]); EXPECT_EQ(input_data[0], (*output_data)[5]); - output_data = DataUtils::Data::createRearrangedDataSet(input_data, 3); + output_data = DataUtil::Data::createRearrangedDataSet(input_data, 3); EXPECT_EQ(size_t(3), output_data->axis(0).size()); EXPECT_EQ(size_t(2), output_data->axis(1).size()); @@ -49,7 +48,7 @@ TEST(DataUtilsTest, createRearrangedDataSet) EXPECT_EQ(input_data[2], (*output_data)[5]); } -TEST(DataUtilsTest, coordinateToFromBinf) +TEST(DataUtilTest, coordinateToFromBinf) { FixedBinAxis axis("axis", 8, -5.0, 3.0); EXPECT_EQ(0.5, FrameUtil::coordinateToBinf(-4.5, axis)); @@ -71,7 +70,7 @@ TEST(DataUtilsTest, coordinateToFromBinf) //! Transformation of coordinates from one Datafield to another using conversion from axes //! coordinates to bin-fraction-coordinates and then to another axes coordinates. -TEST(DataUtilsTest, datafieldToFromBinf) +TEST(DataUtilTest, datafieldToFromBinf) { Frame data1({new FixedBinAxis("axis0", 8, -5.0, 3.0), new FixedBinAxis("axis1", 3, 2.0, 5.0)}); Frame data2( @@ -91,7 +90,7 @@ TEST(DataUtilsTest, datafieldToFromBinf) EXPECT_DOUBLE_EQ(y, 21.0); } -TEST(DataUtilsTest, create2DArrayfromDatafield) +TEST(DataUtilTest, create2DArrayfromDatafield) { Datafield out_data{ {new FixedBinAxis("axis0", 2, 1.0, 2.0), new FixedBinAxis("axis1", 3, 3.0, 4.0)}}; @@ -113,18 +112,18 @@ TEST(DataUtilsTest, create2DArrayfromDatafield) auto arr_out = out_data.flatVector(); EXPECT_EQ(arr_in, arr_out); - auto array_2d = DataUtils::Data::create2DArrayfromDatafield(out_data); + auto array_2d = DataUtil::Data::create2DArrayfromDatafield(out_data); std::vector<std::vector<double>> array_expected_2d{{arr_in[0], arr_in[1], arr_in[2]}, {arr_in[3], arr_in[4], arr_in[5]}}; EXPECT_EQ(array_expected_2d, array_2d); } -TEST(DataUtilsTest, vecvecToDatafield) +TEST(DataUtilTest, vecvecToDatafield) { std::vector<double> arr_in{1, 2, 3, 4, 5, 6}; std::vector<std::vector<double>> array_2d{{arr_in[0], arr_in[1], arr_in[2]}, {arr_in[3], arr_in[4], arr_in[5]}}; - auto data = DataUtils::Data::vecvecToDatafield(array_2d); + auto data = DataUtil::Data::vecvecToDatafield(array_2d); EXPECT_EQ(arr_in, data->flatVector()); } diff --git a/Tests/Unit/Device/PointwiseAxisTest.cpp b/Tests/Unit/Device/PointwiseAxisTest.cpp index 2e0975330c9..f0fa64c30f0 100644 --- a/Tests/Unit/Device/PointwiseAxisTest.cpp +++ b/Tests/Unit/Device/PointwiseAxisTest.cpp @@ -87,7 +87,7 @@ TEST(PointwiseAxisTest, IOStream) oss << axis; std::istringstream iss(oss.str()); - std::unique_ptr<IAxis> result(DataUtils::Format::createAxis(iss)); + std::unique_ptr<IAxis> result(DataUtil::Format::createAxis(iss)); EXPECT_TRUE(axis == *result); } diff --git a/Tests/Unit/Device/RectangularDetectorTest.cpp b/Tests/Unit/Device/RectangularDetectorTest.cpp index 6ebc889925f..85f3baf3977 100644 --- a/Tests/Unit/Device/RectangularDetectorTest.cpp +++ b/Tests/Unit/Device/RectangularDetectorTest.cpp @@ -17,9 +17,9 @@ double alpha(R3 k) bool isEqual(const R3 lhs, const R3 rhs) { - bool is_equal = BaseUtils::algo::almostEqual(lhs.x(), rhs.x(), 2) - && BaseUtils::algo::almostEqual(lhs.y(), rhs.y(), 2) - && BaseUtils::algo::almostEqual(lhs.z(), rhs.z(), 2); + bool is_equal = BaseUtil::algo::almostEqual(lhs.x(), rhs.x(), 2) + && BaseUtil::algo::almostEqual(lhs.y(), rhs.y(), 2) + && BaseUtil::algo::almostEqual(lhs.z(), rhs.z(), 2); if (!is_equal) std::cout << "lhs:" << lhs << " rhs:" << rhs << " diff:" << (lhs - rhs) << std::endl; return is_equal; diff --git a/Tests/Unit/GUI/TestDataItems.cpp b/Tests/Unit/GUI/TestDataItems.cpp index 730a28f0e6e..1c3f183d7c5 100644 --- a/Tests/Unit/GUI/TestDataItems.cpp +++ b/Tests/Unit/GUI/TestDataItems.cpp @@ -29,13 +29,13 @@ public: // changing item (Datafield) if (typeid(T) == typeid(SpecularDataItem)) { std::vector<double> data = {1, 2, 3}; - item->setDatafield(DataUtils::Array::createPField1D(data).release()); + item->setDatafield(DataUtil::Array::createPField1D(data).release()); } else { std::vector<std::vector<double>> data; data.push_back(std::vector<double>({1, 2, 3})); data.push_back(std::vector<double>({1, 2, 3})); data.push_back(std::vector<double>({1, 2, 3})); - item->setDatafield(DataUtils::Array::createPField2D(data).release()); + item->setDatafield(DataUtil::Array::createPField2D(data).release()); } QDateTime time3 = item->lastModified(); EXPECT_TRUE(time2.msecsTo(time3) > nap_time / 2); diff --git a/Tests/Unit/GUI/TestFormFactorItems.cpp b/Tests/Unit/GUI/TestFormFactorItems.cpp index 7435739935e..0f09863305f 100644 --- a/Tests/Unit/GUI/TestFormFactorItems.cpp +++ b/Tests/Unit/GUI/TestFormFactorItems.cpp @@ -18,5 +18,5 @@ TEST(TestFormFactorItems, Pyramid2Item) EXPECT_EQ(p_ff->length(), 20.0); EXPECT_EQ(p_ff->width(), 16.0); EXPECT_EQ(p_ff->height(), 13.0); - EXPECT_TRUE(BaseUtils::algo::almostEqual(p_ff->alpha(), Units::deg2rad(60.0), 2)); + EXPECT_TRUE(BaseUtil::algo::almostEqual(p_ff->alpha(), Units::deg2rad(60.0), 2)); } diff --git a/Tests/Unit/PyBinding/Embedded.cpp b/Tests/Unit/PyBinding/Embedded.cpp index 32df688c65e..1cbc1649d8d 100644 --- a/Tests/Unit/PyBinding/Embedded.cpp +++ b/Tests/Unit/PyBinding/Embedded.cpp @@ -36,7 +36,7 @@ TEST(Embedded, ImportNumpy) Py_DecRef(pmod); EXPECT_TRUE(pvar); - auto version_string = BaseUtils::Python::toString(pvar); + auto version_string = BaseUtil::Python::toString(pvar); Py_DecRef(pvar); std::cout << "numpy_version_string=" << version_string << std::endl; @@ -150,7 +150,7 @@ TEST(Embedded, CompiledFunction) // convert the result to a string PyObject* pResultRepr = PyObject_Repr(pResult); - std::string result = BaseUtils::Python::toString(pResultRepr); + std::string result = BaseUtil::Python::toString(pResultRepr); Py_DecRef(pResultRepr); Py_Finalize(); @@ -163,7 +163,7 @@ TEST(Embedded, CompiledFunction) TEST(Embedded, ObjectExtract) { - PyObject* pmod = BaseUtils::Python::import_bornagain({BABuild::buildLibDir()}); + PyObject* pmod = BaseUtil::Python::import_bornagain({BABuild::buildLibDir()}); EXPECT_TRUE(pmod); PyObject* ml = PyObject_GetAttrString(pmod, "MultiLayer"); @@ -194,7 +194,7 @@ TEST(Embedded, ObjectExtract) TEST(Embedded, EmbeddedMultiLayer) { - PyObject* pmod = BaseUtils::Python::import_bornagain({BABuild::buildLibDir()}); + PyObject* pmod = BaseUtil::Python::import_bornagain({BABuild::buildLibDir()}); EXPECT_TRUE(pmod); // compile our function diff --git a/Tests/Unit/PyBinding/PyInfo.cpp b/Tests/Unit/PyBinding/PyInfo.cpp index df863f777a2..a022366da8c 100644 --- a/Tests/Unit/PyBinding/PyInfo.cpp +++ b/Tests/Unit/PyBinding/PyInfo.cpp @@ -36,7 +36,7 @@ TEST(PyInfo, SysPath) std::cout << "buildLibDir(): " << BABuild::buildLibDir() << std::endl; // Runtime info - auto content = BaseUtils::Python::pythonRuntimeInfo(); + auto content = BaseUtil::Python::pythonRuntimeInfo(); EXPECT_TRUE(!content.empty()); } @@ -45,7 +45,7 @@ TEST(PyInfo, SysPath) TEST(PyInfo, FunctionCall) { - PyObject* pmod = BaseUtils::Python::import_bornagain({BABuild::buildLibDir()}); + PyObject* pmod = BaseUtil::Python::import_bornagain({BABuild::buildLibDir()}); EXPECT_TRUE(pmod); PyObject* pfun = PyObject_GetAttrString(pmod, "GetVersionNumber"); @@ -63,7 +63,7 @@ TEST(PyInfo, FunctionCall) if (!result) throw std::runtime_error("Error while calling function"); - auto str = BaseUtils::Python::toString(result); + auto str = BaseUtil::Python::toString(result); Py_DecRef(result); Py_Finalize(); diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index 56735f0064b..e9d62d01702 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -28854,7 +28854,7 @@ SWIGINTERN PyObject *_wrap_create2DArrayfromDatafield(PyObject *self, PyObject * SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "create2DArrayfromDatafield" "', argument " "1"" of type '" "Datafield const &""'"); } arg1 = reinterpret_cast< Datafield * >(argp1); - result = DataUtils::Data::create2DArrayfromDatafield((Datafield const &)*arg1); + result = DataUtil::Data::create2DArrayfromDatafield((Datafield const &)*arg1); resultobj = swig::from(static_cast< std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > >(result)); return resultobj; fail: @@ -28880,7 +28880,7 @@ SWIGINTERN PyObject *_wrap_importArrayToDatafield__SWIG_0(PyObject *self, Py_ssi } arg1 = ptr; } - result = (Datafield *)DataUtils::Data::importArrayToDatafield((std::vector< double,std::allocator< double > > const &)*arg1); + result = (Datafield *)DataUtil::Data::importArrayToDatafield((std::vector< double,std::allocator< double > > const &)*arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, 0 | 0 ); if (SWIG_IsNewObj(res1)) delete arg1; return resultobj; @@ -28908,7 +28908,7 @@ SWIGINTERN PyObject *_wrap_importArrayToDatafield__SWIG_1(PyObject *self, Py_ssi } arg1 = ptr; } - result = (Datafield *)DataUtils::Data::importArrayToDatafield((std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &)*arg1); + result = (Datafield *)DataUtil::Data::importArrayToDatafield((std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &)*arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, 0 | 0 ); if (SWIG_IsNewObj(res1)) delete arg1; return resultobj; @@ -28946,8 +28946,8 @@ SWIGINTERN PyObject *_wrap_importArrayToDatafield(PyObject *self, PyObject *args fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'importArrayToDatafield'.\n" " Possible C/C++ prototypes are:\n" - " DataUtils::Data::importArrayToDatafield(std::vector< double,std::allocator< double > > const &)\n" - " DataUtils::Data::importArrayToDatafield(std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &)\n"); + " DataUtil::Data::importArrayToDatafield(std::vector< double,std::allocator< double > > const &)\n" + " DataUtil::Data::importArrayToDatafield(std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &)\n"); return 0; } @@ -28997,7 +28997,7 @@ SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_0(PyObject *self, Py_ssize_t nobjs, P SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "FindPeaks" "', argument " "4"" of type '" "double""'"); } arg4 = static_cast< double >(val4); - result = DataUtils::Data::FindPeaks((Datafield const &)*arg1,arg2,(std::string const &)*arg3,arg4); + result = DataUtil::Data::FindPeaks((Datafield const &)*arg1,arg2,(std::string const &)*arg3,arg4); resultobj = swig::from(static_cast< std::vector< std::pair< double,double >,std::allocator< std::pair< double,double > > > >(result)); if (SWIG_IsNewObj(res3)) delete arg3; return resultobj; @@ -29044,7 +29044,7 @@ SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_1(PyObject *self, Py_ssize_t nobjs, P } arg3 = ptr; } - result = DataUtils::Data::FindPeaks((Datafield const &)*arg1,arg2,(std::string const &)*arg3); + result = DataUtil::Data::FindPeaks((Datafield const &)*arg1,arg2,(std::string const &)*arg3); resultobj = swig::from(static_cast< std::vector< std::pair< double,double >,std::allocator< std::pair< double,double > > > >(result)); if (SWIG_IsNewObj(res3)) delete arg3; return resultobj; @@ -29078,7 +29078,7 @@ SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_2(PyObject *self, Py_ssize_t nobjs, P SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FindPeaks" "', argument " "2"" of type '" "double""'"); } arg2 = static_cast< double >(val2); - result = DataUtils::Data::FindPeaks((Datafield const &)*arg1,arg2); + result = DataUtil::Data::FindPeaks((Datafield const &)*arg1,arg2); resultobj = swig::from(static_cast< std::vector< std::pair< double,double >,std::allocator< std::pair< double,double > > > >(result)); return resultobj; fail: @@ -29102,7 +29102,7 @@ SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_3(PyObject *self, Py_ssize_t nobjs, P SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FindPeaks" "', argument " "1"" of type '" "Datafield const &""'"); } arg1 = reinterpret_cast< Datafield * >(argp1); - result = DataUtils::Data::FindPeaks((Datafield const &)*arg1); + result = DataUtil::Data::FindPeaks((Datafield const &)*arg1); resultobj = swig::from(static_cast< std::vector< std::pair< double,double >,std::allocator< std::pair< double,double > > > >(result)); return resultobj; fail: @@ -29186,10 +29186,10 @@ SWIGINTERN PyObject *_wrap_FindPeaks(PyObject *self, PyObject *args) { fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'FindPeaks'.\n" " Possible C/C++ prototypes are:\n" - " DataUtils::Data::FindPeaks(Datafield const &,double,std::string const &,double)\n" - " DataUtils::Data::FindPeaks(Datafield const &,double,std::string const &)\n" - " DataUtils::Data::FindPeaks(Datafield const &,double)\n" - " DataUtils::Data::FindPeaks(Datafield const &)\n"); + " DataUtil::Data::FindPeaks(Datafield const &,double,std::string const &,double)\n" + " DataUtil::Data::FindPeaks(Datafield const &,double,std::string const &)\n" + " DataUtil::Data::FindPeaks(Datafield const &,double)\n" + " DataUtil::Data::FindPeaks(Datafield const &)\n"); return 0; } -- GitLab