From 209ada2247d0759be23f9ae55c977f5662c110ff Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 10 Aug 2023 18:11:26 +0200 Subject: [PATCH] clang-tidy --- .clang-tidy | 7 +- Base/Axis/Coordinate.cpp | 6 +- Base/Axis/Coordinate.h | 2 +- Base/Axis/MakeScale.cpp | 34 +++--- Base/Axis/MakeScale.h | 26 ++-- Base/Axis/Scale.cpp | 6 +- Base/Axis/Scale.h | 6 +- Base/Math/Numeric.cpp | 1 + Base/Util/StringUtil.cpp | 2 +- CMakeLists.txt | 1 + Device/Data/DataUtil.cpp | 2 +- Device/Data/Datafield.cpp | 8 +- Device/Data/Datafield.h | 4 +- Device/Detector/FlatDetector.cpp | 2 +- Device/Detector/SphericalDetector.cpp | 3 - Device/IO/DiffUtil.cpp | 2 +- Device/IO/ParseUtil.cpp | 11 +- Device/IO/ReadReflectometry.cpp | 2 +- .../ConvolutionDetectorResolution.cpp | 4 +- Param/Distrib/Distributions.cpp | 6 +- Param/Node/INode.cpp | 2 +- Resample/Processed/ReSample.cpp | 4 +- Resample/Processed/ReSample.h | 2 +- Resample/Processed/Slicer.cpp | 17 +-- Resample/Slice/ProfileHelper.cpp | 10 +- Resample/Swig/MultiLayerFuncs.cpp | 2 +- Sample/HardParticle/HorizontalCylinder.cpp | 2 +- Sample/HardParticle/Sphere.cpp | 2 - Sample/HardParticle/TruncatedSphere.cpp | 4 +- Sample/HardParticle/TruncatedSpheroid.cpp | 4 +- Sample/Lattice/BakeLattice.cpp | 12 +- Sample/Material/IMaterialImpl.cpp | 6 +- Sample/Material/IMaterialImpl.h | 2 +- Sample/Material/Material.cpp | 4 +- Sample/Material/MaterialBySLDImpl.cpp | 4 +- Sample/Material/MaterialFactoryFuncs.cpp | 4 +- Sample/Material/MaterialUtil.cpp | 6 +- Sample/Material/RefractiveMaterialImpl.cpp | 4 +- Sample/Multilayer/MultiLayer.cpp | 2 +- Sim/Contrib/GISASSpecularContribution.cpp | 11 +- Sim/Export/PyFmt2.cpp | 3 - Sim/Export/SampleToPython.cpp | 2 - Sim/Export/SampleToPython.h | 2 +- Sim/Fitting/SimDataPair.cpp | 4 +- Sim/Fitting/SimDataPair.h | 2 +- Sim/Scan/AlphaScan.cpp | 4 +- Sim/Scan/LambdaScan.cpp | 4 +- Sim/Scan/QzScan.cpp | 4 +- Sim/Simulation/DepthprobeSimulation.cpp | 2 +- Sim/Simulation/ISimulation.cpp | 2 +- Tests/Unit/Device/Shape2DTest.cpp | 2 - Tests/Unit/Device/SphericalDetectorTest.cpp | 4 +- Tests/Unit/Numeric/FourierTransformTest.cpp | 2 - Tests/Unit/Numeric/MultiQTest.cpp | 2 - Tests/Unit/Resample/RTTest.cpp | 2 - Tests/Unit/Sample/CoreAndShellTest.cpp | 2 - Tests/Unit/Sample/Lattice2DTest.cpp | 2 - Tests/Unit/Sample/MultiLayerTest.cpp | 2 - Tests/Unit/Sample/ParticleCompositionTest.cpp | 2 - Tests/Unit/Sim/ParticleLayoutTest.cpp | 5 +- auto/Wrap/libBornAgainBase.py | 16 +-- auto/Wrap/libBornAgainBase_wrap.cpp | 113 ++++++++---------- auto/Wrap/libBornAgainDevice.py | 2 +- auto/Wrap/libBornAgainDevice_wrap.cpp | 65 ++++------ 64 files changed, 214 insertions(+), 275 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index cca76d22e64..7212210e12c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,7 +3,8 @@ # This is the BornAgain configuration for clang-tidy. # # To invoke clang-tidy, run -# cmake -DBORNAGAIN_TIDY=ON -DBORNAGAIN_PYTHON=OFF -DBORNAGAIN_GUI=OFF .. +# setclang +# cmake -DBA_TIDY=ON -DBORNAGAIN_PYTHON=OFF -DBA_GUI=OFF .. # make # # Below, we select all checks ('*'), then deselect quite a number of them. @@ -24,7 +25,7 @@ Checks: '*, -*-trailing-return*, -*-uppercase-literal-suffix, -*nodiscard, --abseil-string-find-str-contains, +-abseil-*, -altera-unroll-loops, -bugprone-branch-clone, -bugprone-easily-swappable-parameters, @@ -55,6 +56,7 @@ Checks: '*, -google-build-using-namespace, -google-default-arguments, -google-explicit-constructor, +-google-readability-avoid-underscore-in-googletest-name, -google-readability-casting, -google-readability-todo, -google-runtime-int, @@ -68,6 +70,7 @@ Checks: '*, -llvmlibc-restrict-system-libc-headers, -misc-no-recursion, -misc-throw-by-value-catch-by-reference, +-performance-faster-string-find, -performance-inefficient-string-concatenation, -performance-noexcept-move-constructor, -performance-no-automatic-move, diff --git a/Base/Axis/Coordinate.cpp b/Base/Axis/Coordinate.cpp index e98cc4e242f..809e16af343 100644 --- a/Base/Axis/Coordinate.cpp +++ b/Base/Axis/Coordinate.cpp @@ -38,9 +38,9 @@ std::pair<std::string, std::string> parse_label(const std::string& label) } // namespace -Coordinate::Coordinate(const std::string& name, const std::string& unit) - : m_name(name) - , m_unit(unit) +Coordinate::Coordinate(std::string name, std::string unit) + : m_name(std::move(name)) + , m_unit(std::move(unit)) { } diff --git a/Base/Axis/Coordinate.h b/Base/Axis/Coordinate.h index 71f05679a94..08323db8ed2 100644 --- a/Base/Axis/Coordinate.h +++ b/Base/Axis/Coordinate.h @@ -22,7 +22,7 @@ class Coordinate { public: Coordinate(const std::string& label); - Coordinate(const std::string& name, const std::string& unit); + Coordinate(std::string name, std::string unit); bool operator==(const Coordinate& other) const = default; diff --git a/Base/Axis/MakeScale.cpp b/Base/Axis/MakeScale.cpp index 460fcc6c06d..a65e063ffe2 100644 --- a/Base/Axis/MakeScale.cpp +++ b/Base/Axis/MakeScale.cpp @@ -16,37 +16,37 @@ #include "Base/Axis/Scale.h" #include "Base/Util/Assert.h" -Scale GenericScale(const std::string& name, const std::vector<double>& limits) +Scale GenericScale(std::string name, const std::vector<double>& limits) { std::vector<Bin1D> vec; ASSERT(!(limits.size() & 1)); // must be an even number for (size_t i = 0; i < limits.size(); i += 2) vec.emplace_back(Bin1D::FromTo(limits[i], limits[i + 1])); - return Scale(name, vec); + return {name, vec}; } -Scale* newGenericScale(const std::string& name, const std::vector<double>& limits) +Scale* newGenericScale(std::string name, const std::vector<double>& limits) { return new Scale(GenericScale(name, limits)); } -Scale ListScan(const std::string& name, const std::vector<double>& points) +Scale ListScan(std::string name, const std::vector<double>& points) { std::vector<Bin1D> vec; vec.reserve(points.size()); for (double p : points) vec.emplace_back(Bin1D::At(p)); - return Scale(name, vec); + return {name, vec}; } -Scale* newListScan(const std::string& name, const std::vector<double>& points) +Scale* newListScan(std::string name, const std::vector<double>& points) { return new Scale(ListScan(name, points)); } -Scale EquiDivision(const std::string& name, size_t N, double start, double end) +Scale EquiDivision(std::string name, size_t N, double start, double end) { ASSERT(N > 0); ASSERT(start <= end); @@ -57,28 +57,26 @@ Scale EquiDivision(const std::string& name, size_t N, double start, double end) (N - i - 1) * (start / N) + (i + 1) * (end / N))); ASSERT(vec.size() == N); - return Scale(name, vec); + return {name, vec}; } -Scale* newEquiDivision(const std::string& name, size_t N, double start, double end) +Scale* newEquiDivision(std::string name, size_t N, double start, double end) { return new Scale(EquiDivision(name, N, start, end)); } -std::shared_ptr<Scale> sharedEquiDivision(const std::string& name, size_t N, double start, - double end) +std::shared_ptr<Scale> sharedEquiDivision(std::string name, size_t N, double start, double end) { return std::shared_ptr<Scale>(newEquiDivision(name, N, start, end)); } -std::unique_ptr<Scale> uniqueEquiDivision(const std::string& name, size_t N, double start, - double end) +std::unique_ptr<Scale> uniqueEquiDivision(std::string name, size_t N, double start, double end) { return std::unique_ptr<Scale>(newEquiDivision(name, N, start, end)); } -Scale EquiScan(const std::string& name, size_t N, double start, double end) +Scale EquiScan(std::string name, size_t N, double start, double end) { ASSERT(N); std::vector<Bin1D> vec; @@ -93,20 +91,20 @@ Scale EquiScan(const std::string& name, size_t N, double start, double end) ASSERT(vec.size() == N); } - return Scale(name, vec); + return {name, vec}; } -Scale* newEquiScan(const std::string& name, size_t N, double start, double end) +Scale* newEquiScan(std::string name, size_t N, double start, double end) { return new Scale(EquiScan(name, N, start, end)); } -std::shared_ptr<Scale> sharedEquiScan(const std::string& name, size_t N, double start, double end) +std::shared_ptr<Scale> sharedEquiScan(std::string name, size_t N, double start, double end) { return std::shared_ptr<Scale>(newEquiDivision(name, N, start, end)); } -std::unique_ptr<Scale> uniqueEquiScan(const std::string& name, size_t N, double start, double end) +std::unique_ptr<Scale> uniqueEquiScan(std::string name, size_t N, double start, double end) { return std::unique_ptr<Scale>(newEquiDivision(name, N, start, end)); } diff --git a/Base/Axis/MakeScale.h b/Base/Axis/MakeScale.h index 830b13aff22..2f5f72139d8 100644 --- a/Base/Axis/MakeScale.h +++ b/Base/Axis/MakeScale.h @@ -21,32 +21,30 @@ class Scale; -Scale GenericScale(const std::string& name, const std::vector<double>& limits); +Scale GenericScale(std::string name, const std::vector<double>& limits); #ifndef SWIG -Scale* newGenericScale(const std::string& name, const std::vector<double>& limits); +Scale* newGenericScale(std::string name, const std::vector<double>& limits); #endif // SWIG -Scale ListScan(const std::string& name, const std::vector<double>& points); +Scale ListScan(std::string name, const std::vector<double>& points); #ifndef SWIG -Scale* newListScan(const std::string& name, const std::vector<double>& points); +Scale* newListScan(std::string name, const std::vector<double>& points); #endif // SWIG //! Returns axis with fixed bin size. -Scale EquiDivision(const std::string& name, size_t N, double start, double end); +Scale EquiDivision(std::string name, size_t N, double start, double end); #ifndef SWIG -Scale* newEquiDivision(const std::string& name, size_t N, double start, double end); -std::shared_ptr<Scale> sharedEquiDivision(const std::string& name, size_t N, double start, - double end); -std::unique_ptr<Scale> uniqueEquiDivision(const std::string& name, size_t N, double start, - double end); +Scale* newEquiDivision(std::string name, size_t N, double start, double end); +std::shared_ptr<Scale> sharedEquiDivision(std::string name, size_t N, double start, double end); +std::unique_ptr<Scale> uniqueEquiDivision(std::string name, size_t N, double start, double end); #endif // SWIG //! Returns axis with equidistant points (zero bin width). -Scale EquiScan(const std::string& name, size_t N, double start, double end); +Scale EquiScan(std::string name, size_t N, double start, double end); #ifndef SWIG -Scale* newEquiScan(const std::string& name, size_t N, double start, double end); -std::shared_ptr<Scale> sharedEquiScan(const std::string& name, size_t N, double start, double end); -std::unique_ptr<Scale> uniqueEquiScan(const std::string& name, size_t N, double start, double end); +Scale* newEquiScan(std::string name, size_t N, double start, double end); +std::shared_ptr<Scale> sharedEquiScan(std::string name, size_t N, double start, double end); +std::unique_ptr<Scale> uniqueEquiScan(std::string name, size_t N, double start, double end); #endif // SWIG #endif // BORNAGAIN_BASE_AXIS_MAKESCALE_H diff --git a/Base/Axis/Scale.cpp b/Base/Axis/Scale.cpp index fc239405f60..25575d914c2 100644 --- a/Base/Axis/Scale.cpp +++ b/Base/Axis/Scale.cpp @@ -19,9 +19,9 @@ #include <numbers> using std::numbers::pi; -Scale::Scale(const Coordinate& coord, const std::vector<Bin1D>& bins) +Scale::Scale(const Coordinate& coord, std::vector<Bin1D> bins) : m_coord(coord) - , m_bins(bins) + , m_bins(std::move(bins)) { ASSERT(size() > 0); for (size_t i = 0; i < size() - 1; ++i) { @@ -200,7 +200,7 @@ Scale Scale::plottableScale() const double bma = b.upperBound() * 180 / pi; outvector.emplace_back(Bin1D::FromTo(bmi, bma)); } - return Scale(outname, outvector); + return {outname, outvector}; } return *this; } diff --git a/Base/Axis/Scale.h b/Base/Axis/Scale.h index 296a3dab4ac..8516866e035 100644 --- a/Base/Axis/Scale.h +++ b/Base/Axis/Scale.h @@ -25,7 +25,7 @@ class Scale { public: - Scale(const Coordinate& coord, const std::vector<Bin1D>& bins); + Scale(const Coordinate& coord, std::vector<Bin1D> bins); Scale* clone() const { return new Scale(*this); } //! Returns the label of the axis @@ -71,9 +71,9 @@ public: Scale clipped(double lower, double upper) const; Scale clipped(std::pair<double, double> bounds) const; - bool operator==(const Scale& right) const; + bool operator==(const Scale& other) const; - friend std::ostream& operator<<(std::ostream& ostr, const Scale& m); + friend std::ostream& operator<<(std::ostream& ostr, const Scale& ax); std::string unit() const; diff --git a/Base/Math/Numeric.cpp b/Base/Math/Numeric.cpp index 1cfb2c801bb..f481b337bbe 100644 --- a/Base/Math/Numeric.cpp +++ b/Base/Math/Numeric.cpp @@ -18,6 +18,7 @@ #include <cstdlib> #include <limits> +//! For tests only. void check_scalar(double a, double b, int ulp) { if (!Numeric::almostEqual(a, b, ulp)) diff --git a/Base/Util/StringUtil.cpp b/Base/Util/StringUtil.cpp index 01e741d7c8a..c140fb7932e 100644 --- a/Base/Util/StringUtil.cpp +++ b/Base/Util/StringUtil.cpp @@ -143,7 +143,7 @@ std::vector<int> Base::String::expandNumberList(const std::string& pattern) for (const std::string& word : split(trim(pattern), ",")) { std::vector<std::string> parts = split(trim(word), "-"); - if (parts.size() < 1) + if (parts.empty()) throw std::runtime_error("invalid number list"); if (parts.size() > 2) throw std::runtime_error("invalid number list"); diff --git a/CMakeLists.txt b/CMakeLists.txt index aa1d0b54b95..7a5780d25ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ if(BA_GUI AND NOT BORNAGAIN_PYTHON AND NOT BA_TIDY) " (except with BA_TIDY)") endif() + ### Generator type (Release|Debug) # Show info about generator type; set CMAKE_BUILD_TYPE if not given diff --git a/Device/Data/DataUtil.cpp b/Device/Data/DataUtil.cpp index c51da04e041..342ed40a419 100644 --- a/Device/Data/DataUtil.cpp +++ b/Device/Data/DataUtil.cpp @@ -63,7 +63,7 @@ DataUtil::Data::invertAxis(int axis, const std::vector<std::vector<double>>& ori std::vector<std::vector<double>> DataUtil::Data::transpose(const std::vector<std::vector<double>>& original) { - ASSERT(original.size() > 0); + ASSERT(!original.empty()); size_t orig_rows = original.size(); size_t orig_cols = original.front().size(); diff --git a/Device/Data/Datafield.cpp b/Device/Data/Datafield.cpp index 240d66f7e89..965b5a64484 100644 --- a/Device/Data/Datafield.cpp +++ b/Device/Data/Datafield.cpp @@ -18,9 +18,9 @@ #include "Base/Util/Assert.h" #include <algorithm> -Datafield::Datafield(const std::string& title, const Frame* frame, - const std::vector<double>& values, const std::vector<double>& errSigmas) - : m_title(title) +Datafield::Datafield(std::string title, const Frame* frame, const std::vector<double>& values, + const std::vector<double>& errSigmas) + : m_title(std::move(title)) , m_frame(frame) , m_values(values.empty() ? std::vector<double>(frame->size(), 0.) : values) , m_errSigmas(errSigmas) @@ -42,7 +42,7 @@ Datafield::Datafield(std::vector<const Scale*>&& axes, const std::vector<double> { } -Datafield::Datafield(Datafield&&) = default; +Datafield::Datafield(Datafield&&) noexcept = default; Datafield::Datafield(const Datafield& other) : Datafield(other.title(), other.m_frame ? other.m_frame->clone() : nullptr, other.m_values, diff --git a/Device/Data/Datafield.h b/Device/Data/Datafield.h index 02230408e26..6ed1721dc61 100644 --- a/Device/Data/Datafield.h +++ b/Device/Data/Datafield.h @@ -30,7 +30,7 @@ class Frame; class Datafield { public: - Datafield(const std::string& title, const Frame* frame, const std::vector<double>& values = {}, + Datafield(std::string title, const Frame* frame, const std::vector<double>& values = {}, const std::vector<double>& errSigmas = {}); //! Constructor that takes ownership of supplied frame and initializes values and errorbars @@ -42,7 +42,7 @@ public: const std::vector<double>& errSigmas = {}); Datafield(const Datafield&); - Datafield(Datafield&&); + Datafield(Datafield&&) noexcept; virtual ~Datafield(); Datafield& operator=(Datafield&& other) noexcept; diff --git a/Device/Detector/FlatDetector.cpp b/Device/Detector/FlatDetector.cpp index 793d3d6a7eb..dcc3ac616a2 100644 --- a/Device/Detector/FlatDetector.cpp +++ b/Device/Detector/FlatDetector.cpp @@ -217,5 +217,5 @@ void FlatDetector::initUandV() Frame FlatDetector::scatteringCoords() const { - return Frame(axesClippedToRegionOfInterest()); + return {axesClippedToRegionOfInterest()}; } diff --git a/Device/Detector/SphericalDetector.cpp b/Device/Detector/SphericalDetector.cpp index 079a6be7a4c..519200c6631 100644 --- a/Device/Detector/SphericalDetector.cpp +++ b/Device/Detector/SphericalDetector.cpp @@ -21,9 +21,6 @@ #include "Base/Util/Assert.h" #include "Device/Beam/Beam.h" #include "Device/Resolution/IDetectorResolution.h" -#include <numbers> - -using std::numbers::pi; SphericalDetector::SphericalDetector(const Frame& frame) : IDetector(frame) diff --git a/Device/IO/DiffUtil.cpp b/Device/IO/DiffUtil.cpp index faa7a2acde3..c93f8e5f948 100644 --- a/Device/IO/DiffUtil.cpp +++ b/Device/IO/DiffUtil.cpp @@ -40,7 +40,7 @@ Datafield DiffUtil::relativeDifferenceField(const Datafield& dat, const Datafiel std::vector<double> out(dat.size()); for (size_t i = 0; i < dat.size(); ++i) out[i] = Numeric::relativeDifference(dat[i], ref[i]); - return Datafield(dat.frame().clone(), out); + return {dat.frame().clone(), out}; } //! Returns sum of relative differences between each pair of elements: diff --git a/Device/IO/ParseUtil.cpp b/Device/IO/ParseUtil.cpp index 1ef188b48eb..5dbf01ad4ad 100644 --- a/Device/IO/ParseUtil.cpp +++ b/Device/IO/ParseUtil.cpp @@ -52,7 +52,7 @@ std::vector<double> parse_x_list(std::string text, const std::string& type) throw std::runtime_error("Reading " + type + ": cannot read entry '" + e + "'"); result.push_back(x); } - if (!result.size()) + if (result.empty()) throw std::runtime_error("Reading " + type + ": found empty list"); return result; } @@ -79,15 +79,14 @@ Scale* Util::Parse::parseScale(std::istream& input_stream) && Base::String::to_double(arr[2], &xma))) throw std::runtime_error("Reading EquiDivision: cannot read parameters"); return newEquiDivision(name, nbins, xmi, xma); - - } else if (type == "ListScan" || type == "DiscreteAxis" /* for compatibility with pre-21 */) { + } + if (type == "ListScan" || type == "DiscreteAxis" /* for compatibility with pre-21 */) return newListScan(name, parse_x_list(body, type)); - } else if (type == "GenericScale" || type == "Scale" /* for compatibility with pre-21 */) { + if (type == "GenericScale" || type == "Scale" /* for compatibility with pre-21 */) return newGenericScale(name, parse_x_list(body, type)); - } else - throw std::runtime_error("Unknown axis type '" + type + "'"); + throw std::runtime_error("Unknown axis type '" + type + "'"); } //! Fills output data raw buffer from input stream diff --git a/Device/IO/ReadReflectometry.cpp b/Device/IO/ReadReflectometry.cpp index 2ccb4c4a8a4..bec650f4890 100644 --- a/Device/IO/ReadReflectometry.cpp +++ b/Device/IO/ReadReflectometry.cpp @@ -85,7 +85,7 @@ Datafield* Util::RW::readMotofit(std::istream& s) throw std::runtime_error("Missing header line 'Number of data points'"); // Blank line - if (!ok || trim(line) != "") + if (!ok || !trim(line).empty()) throw std::runtime_error("Missing blank line after header"); // Tab header line diff --git a/Device/Resolution/ConvolutionDetectorResolution.cpp b/Device/Resolution/ConvolutionDetectorResolution.cpp index 261dfdae701..bfea137c855 100644 --- a/Device/Resolution/ConvolutionDetectorResolution.cpp +++ b/Device/Resolution/ConvolutionDetectorResolution.cpp @@ -37,9 +37,9 @@ ConvolutionDetectorResolution::~ConvolutionDetectorResolution() = default; ConvolutionDetectorResolution::ConvolutionDetectorResolution( const ConvolutionDetectorResolution& other) + : m_rank(other.m_rank) + , m_res_function_1d(other.m_res_function_1d) { - m_rank = other.m_rank; - m_res_function_1d = other.m_res_function_1d; if (other.m_res_function_2d) setResolutionFunction(*other.m_res_function_2d); } diff --git a/Param/Distrib/Distributions.cpp b/Param/Distrib/Distributions.cpp index 984e500577d..016a235d97c 100644 --- a/Param/Distrib/Distributions.cpp +++ b/Param/Distrib/Distributions.cpp @@ -478,11 +478,11 @@ std::string DistributionTrapezoid::validate() const { std::vector<std::string> errs; if (m_left < 0.0) - errs.push_back("parameters violate condition leftWidth < 0"); + errs.emplace_back("parameters violate condition leftWidth < 0"); if (m_middle < 0.0) - errs.push_back("parameters violate condition middleWidth < 0"); + errs.emplace_back("parameters violate condition middleWidth < 0"); if (m_right < 0.0) - errs.push_back("parameters violate condition rightWidth < 0"); + errs.emplace_back("parameters violate condition rightWidth < 0"); if (!errs.empty()) return jointError(errs); m_validated = true; diff --git a/Param/Node/INode.cpp b/Param/Node/INode.cpp index e2b8cb2699b..da46caf2333 100644 --- a/Param/Node/INode.cpp +++ b/Param/Node/INode.cpp @@ -68,6 +68,6 @@ std::string INode::jointError(const std::vector<std::string> errs) const void INode::validateOrThrow() const { const std::string err = validate(); - if (err != "") + if (!err.empty()) throw std::runtime_error(err); } diff --git a/Resample/Processed/ReSample.cpp b/Resample/Processed/ReSample.cpp index 8c686021d88..69700a38f29 100644 --- a/Resample/Processed/ReSample.cpp +++ b/Resample/Processed/ReSample.cpp @@ -353,11 +353,11 @@ ReSample ReSample::make(const MultiLayer& sample) //... ReSample::ReSample(const MultiLayer& sample, bool polarized, - OwningVector<const ReLayout>&& relayouts, const SliceStack& refined_stack) + OwningVector<const ReLayout>&& relayouts, SliceStack refined_stack) : m_sample(sample) , m_polarized(polarized) , m_relayouts(std::move(relayouts)) - , m_stack(refined_stack) + , m_stack(std::move(refined_stack)) { } diff --git a/Resample/Processed/ReSample.h b/Resample/Processed/ReSample.h index 27c286bd4d7..f0be50801f2 100644 --- a/Resample/Processed/ReSample.h +++ b/Resample/Processed/ReSample.h @@ -61,7 +61,7 @@ public: private: ReSample(const MultiLayer& sample, bool polarized, OwningVector<const ReLayout>&& layouts, - const SliceStack& refined_stack); + SliceStack refined_stack); const MultiLayer& m_sample; const bool m_polarized; const OwningVector<const ReLayout> m_relayouts; diff --git a/Resample/Processed/Slicer.cpp b/Resample/Processed/Slicer.cpp index f69769edb21..2148db6cf82 100644 --- a/Resample/Processed/Slicer.cpp +++ b/Resample/Processed/Slicer.cpp @@ -116,8 +116,8 @@ IFormFactor* doSlice(const IFormFactor* ff, double dz_bottom, double dz_top) if (const auto* f = dynamic_cast<const TruncatedSpheroid*>(ff)) { return new TruncatedSpheroid(f->radius(), f->untruncated_height() - dz_bottom, f->heightFlattening(), dz_top + f->removedTop()); - } else - throw std::runtime_error("Slicing of " + ff->className() + " not supported"); + } + throw std::runtime_error("Slicing of " + ff->className() + " not supported"); } ReParticle* createParticleSlice(const IFormFactor* ff, ZLimits limits, const R3& position, @@ -216,8 +216,9 @@ OwningVector<IReParticle> Compute::Slicing::particlesInSlice(const IParticle* pa OwningVector<IReParticle> result; result.emplace_back(particleSlice.release()); return result; + } - } else if (const auto* p = dynamic_cast<const CoreAndShell*>(particle)) { + if (const auto* p = dynamic_cast<const CoreAndShell*>(particle)) { const Particle* core = p->coreParticle(); const Particle* shell = p->shellParticle(); ASSERT(core && shell); @@ -261,11 +262,12 @@ OwningVector<IReParticle> Compute::Slicing::particlesInSlice(const IParticle* pa result.emplace_back(sliced_core); result.emplace_back(sliced_shell); return result; + } - } else if (dynamic_cast<const Compound*>(particle)) { + if (dynamic_cast<const Compound*>(particle)) throw std::runtime_error("Compound does not yet support slicing"); - } else if (const auto* p = dynamic_cast<const Mesocrystal*>(particle)) { + if (const auto* p = dynamic_cast<const Mesocrystal*>(particle)) { const Crystal* crystal = &p->particleStructure(); const IFormFactor* meso_formfactor = p->outerShape(); ASSERT(crystal && meso_formfactor); @@ -302,7 +304,6 @@ OwningVector<IReParticle> Compute::Slicing::particlesInSlice(const IParticle* pa OwningVector<IReParticle> result; result.emplace_back(mc.release()); return result; - - } else - ASSERT(false); + } + ASSERT(false); } diff --git a/Resample/Slice/ProfileHelper.cpp b/Resample/Slice/ProfileHelper.cpp index 69f4cd42c32..b385e380a3b 100644 --- a/Resample/Slice/ProfileHelper.cpp +++ b/Resample/Slice/ProfileHelper.cpp @@ -46,15 +46,13 @@ complex_t quantity(const Material& mat, std::string q) { if (q == SLD) return mat.refractiveIndex_or_SLD(); - else if (q == X) + if (q == X) return mat.magnetization().x(); - else if (q == Y) + if (q == Y) return mat.magnetization().y(); - else if (q == Z) + if (q == Z) return mat.magnetization().z(); - else - ASSERT(false); - return {}; + ASSERT(false); } } // namespace diff --git a/Resample/Swig/MultiLayerFuncs.cpp b/Resample/Swig/MultiLayerFuncs.cpp index d85449155e4..f996e5c0589 100644 --- a/Resample/Swig/MultiLayerFuncs.cpp +++ b/Resample/Swig/MultiLayerFuncs.cpp @@ -24,7 +24,7 @@ ProfileHelper helper(const MultiLayer& sample) SimulationOptions options; options.setUseAvgMaterials(true); const ReSample resample = ReSample::make(sample, options); - return ProfileHelper(resample.averageSlices()); + return {resample.averageSlices()}; } } // namespace diff --git a/Sample/HardParticle/HorizontalCylinder.cpp b/Sample/HardParticle/HorizontalCylinder.cpp index 55472fa3935..0f4227661fd 100644 --- a/Sample/HardParticle/HorizontalCylinder.cpp +++ b/Sample/HardParticle/HorizontalCylinder.cpp @@ -80,7 +80,7 @@ std::string HorizontalCylinder::validate() const if (m_slice_top > m_radius) errs.push_back("slice_top=" + std::to_string(m_slice_top) + "<R"); if (m_slice_bottom >= m_slice_top) - errs.push_back("parameters violate condition bottom<top"); + errs.emplace_back("parameters violate condition bottom<top"); if (!errs.empty()) return jointError(errs); diff --git a/Sample/HardParticle/Sphere.cpp b/Sample/HardParticle/Sphere.cpp index e453b99bcfe..4cfccb7dc99 100644 --- a/Sample/HardParticle/Sphere.cpp +++ b/Sample/HardParticle/Sphere.cpp @@ -18,8 +18,6 @@ #include "Sample/HardParticle/TruncatedSphere.h" #include "Sample/LibFF/SomeFormFactors.h" #include "Sample/Scattering/Rotations.h" -#include <numbers> -using std::numbers::pi; Sphere::Sphere(const std::vector<double> P, bool position_at_center) : IFormFactor(P) diff --git a/Sample/HardParticle/TruncatedSphere.cpp b/Sample/HardParticle/TruncatedSphere.cpp index 81ada1780bc..72b7e441372 100644 --- a/Sample/HardParticle/TruncatedSphere.cpp +++ b/Sample/HardParticle/TruncatedSphere.cpp @@ -64,9 +64,9 @@ std::string TruncatedSphere::validate() const requestGt0(errs, m_untruncated_height, "untruncated_height"); requestGe0(errs, m_dh, "dh"); if (m_untruncated_height > 2. * m_radius) - errs.push_back("parameters violate condition H>2R"); + errs.emplace_back("parameters violate condition H>2R"); if (m_dh > m_untruncated_height) - errs.push_back("parameters violate condition dH<=H"); + errs.emplace_back("parameters violate condition dH<=H"); if (!errs.empty()) return jointError(errs); diff --git a/Sample/HardParticle/TruncatedSpheroid.cpp b/Sample/HardParticle/TruncatedSpheroid.cpp index b75e76e6d6a..594ab349c7f 100644 --- a/Sample/HardParticle/TruncatedSpheroid.cpp +++ b/Sample/HardParticle/TruncatedSpheroid.cpp @@ -67,9 +67,9 @@ std::string TruncatedSpheroid::validate() const requestGt0(errs, m_fp, "height_flattening"); requestGe0(errs, m_dh, "dh"); if (m_untruncated_height > 2 * m_radius * m_fp) - errs.push_back("parameters violate condition H>2R*flattening"); + errs.emplace_back("parameters violate condition H>2R*flattening"); if (m_dh > m_untruncated_height) - errs.push_back("parameters violate condition dH<=H"); + errs.emplace_back("parameters violate condition dH<=H"); if (!errs.empty()) return jointError(errs); diff --git a/Sample/Lattice/BakeLattice.cpp b/Sample/Lattice/BakeLattice.cpp index 230aea34cb5..c644341c7e7 100644 --- a/Sample/Lattice/BakeLattice.cpp +++ b/Sample/Lattice/BakeLattice.cpp @@ -20,7 +20,7 @@ Lattice3D bake::CubicLattice(double a) R3 a1(a, 0.0, 0.0); R3 a2(0.0, a, 0.0); R3 a3(0.0, 0.0, a); - return Lattice3D(a1, a2, a3); + return {a1, a2, a3}; } Lattice3D bake::FCCLattice(double a) @@ -29,7 +29,7 @@ Lattice3D bake::FCCLattice(double a) R3 a1(0.0, b, b); R3 a2(b, 0.0, b); R3 a3(b, b, 0.0); - return Lattice3D(a1, a2, a3); + return {a1, a2, a3}; } Lattice3D bake::HexagonalLattice(double a, double c) @@ -37,7 +37,7 @@ Lattice3D bake::HexagonalLattice(double a, double c) R3 a1(a, 0.0, 0.0); R3 a2(-a / 2.0, std::sqrt(3.0) * a / 2.0, 0.0); R3 a3(0.0, 0.0, c); - return Lattice3D(a1, a2, a3); + return {a1, a2, a3}; } Lattice3D bake::HCPLattice(double a, double c) @@ -45,7 +45,7 @@ Lattice3D bake::HCPLattice(double a, double c) R3 a1(a, 0.0, 0.0); R3 a2(-a / 2.0, std::sqrt(3.0) * a / 2.0, 0); R3 a3(a / 2.0, a / std::sqrt(3.0) / 2.0, c / 2.0); - return Lattice3D(a1, a2, a3); + return {a1, a2, a3}; } Lattice3D bake::TetragonalLattice(double a, double c) @@ -53,7 +53,7 @@ Lattice3D bake::TetragonalLattice(double a, double c) R3 a1(a, 0.0, 0.0); R3 a2(0.0, a, 0.0); R3 a3(0.0, 0.0, c); - return Lattice3D(a1, a2, a3); + return {a1, a2, a3}; } Lattice3D bake::BCTLattice(double a, double c) @@ -61,5 +61,5 @@ Lattice3D bake::BCTLattice(double a, double c) R3 a1(a, 0.0, 0.0); R3 a2(0.0, a, 0.0); R3 a3(a / 2.0, a / 2.0, c / 2.0); - return Lattice3D(a1, a2, a3); + return {a1, a2, a3}; } diff --git a/Sample/Material/IMaterialImpl.cpp b/Sample/Material/IMaterialImpl.cpp index 06bf3882589..bd91c353712 100644 --- a/Sample/Material/IMaterialImpl.cpp +++ b/Sample/Material/IMaterialImpl.cpp @@ -30,7 +30,7 @@ constexpr double magnetization_prefactor = (gamma_n * r_e / 2.0 / mu_B) * 1e-18; C3 OrthogonalToBaseVector(C3 base, const R3 vector) { if (base.mag2() == 0.0) - return C3(); + return {}; C3 projection = (base.dot(vector) / base.mag2()) * base; return vector.complex() - projection; } @@ -38,8 +38,8 @@ C3 OrthogonalToBaseVector(C3 base, const R3 vector) } // namespace -IMaterialImpl::IMaterialImpl(const std::string& name, R3 magnetization) - : m_name(name) +IMaterialImpl::IMaterialImpl(std::string name, R3 magnetization) + : m_name(std::move(name)) , m_magnetization(magnetization) { } diff --git a/Sample/Material/IMaterialImpl.h b/Sample/Material/IMaterialImpl.h index 8916fcfd1bb..051ca170e81 100644 --- a/Sample/Material/IMaterialImpl.h +++ b/Sample/Material/IMaterialImpl.h @@ -31,7 +31,7 @@ enum class MATERIAL_TYPES { InvalidMaterialType = -1, RefractiveMaterial = 0, Ma class IMaterialImpl { public: //! Constructs basic material with name and magnetization - IMaterialImpl(const std::string& name, R3 magnetization); + IMaterialImpl(std::string name, R3 magnetization); virtual ~IMaterialImpl() = default; diff --git a/Sample/Material/Material.cpp b/Sample/Material/Material.cpp index 1fcc53f6e5b..b026e6e6c73 100644 --- a/Sample/Material/Material.cpp +++ b/Sample/Material/Material.cpp @@ -42,7 +42,7 @@ Material& Material::operator=(const Material& other) Material Material::inverted() const { std::unique_ptr<IMaterialImpl> material_impl(m_material_impl->inverted()); - return Material(std::move(material_impl)); + return {std::move(material_impl)}; } complex_t Material::refractiveIndex(double wavelength) const @@ -108,7 +108,7 @@ SpinMatrix Material::polarizedSubtrSLD(const WavevectorInfo& wavevectors) const Material Material::rotatedMaterial(const RotMatrix& transform) const // TODO param:=rotation { std::unique_ptr<IMaterialImpl> material_impl(m_material_impl->rotatedMaterial(transform)); - return Material(std::move(material_impl)); + return {std::move(material_impl)}; } std::ostream& operator<<(std::ostream& ostr, const Material& m) diff --git a/Sample/Material/MaterialBySLDImpl.cpp b/Sample/Material/MaterialBySLDImpl.cpp index 2da5694c933..c50e716d181 100644 --- a/Sample/Material/MaterialBySLDImpl.cpp +++ b/Sample/Material/MaterialBySLDImpl.cpp @@ -61,7 +61,7 @@ complex_t MaterialBySLDImpl::refractiveIndex2(double wavelength) const //! Returns underlying material SLD in AA^-2 complex_t MaterialBySLDImpl::refractiveIndex_or_SLD() const { - return complex_t(m_sld_real * square_angstroms, m_sld_imag * square_angstroms); + return {m_sld_real * square_angstroms, m_sld_imag * square_angstroms}; } //! Returns (\f$ \pi/\lambda^2 \f$ - sld), sld (in \f$nm^{-2}\f$) being the scattering length @@ -86,5 +86,5 @@ std::string MaterialBySLDImpl::print() const //! Returns the scattering length density in \f$ nm^{-2} \f$ complex_t MaterialBySLDImpl::sld() const { - return complex_t(m_sld_real, -m_sld_imag); + return {m_sld_real, -m_sld_imag}; } diff --git a/Sample/Material/MaterialFactoryFuncs.cpp b/Sample/Material/MaterialFactoryFuncs.cpp index 0e506faec87..075ecd73144 100644 --- a/Sample/Material/MaterialFactoryFuncs.cpp +++ b/Sample/Material/MaterialFactoryFuncs.cpp @@ -28,7 +28,7 @@ Material RefractiveMaterial(const std::string& name, double delta, double beta, { std::unique_ptr<RefractiveMaterialImpl> mat_impl( new RefractiveMaterialImpl(name, delta, beta, magnetization)); - return Material(std::move(mat_impl)); + return {std::move(mat_impl)}; } Material Vacuum() @@ -42,7 +42,7 @@ Material MaterialBySLD(const std::string& name, double sld_real, double sld_imag constexpr double inv_sq_angstroms = 1.0 / (Units::angstrom * Units::angstrom); std::unique_ptr<MaterialBySLDImpl> mat_impl(new MaterialBySLDImpl( name, sld_real * inv_sq_angstroms, sld_imag * inv_sq_angstroms, magnetization)); - return Material(std::move(mat_impl)); + return {std::move(mat_impl)}; } Material MaterialBySLD() diff --git a/Sample/Material/MaterialUtil.cpp b/Sample/Material/MaterialUtil.cpp index 3721e9ab25c..59b9f11d09e 100644 --- a/Sample/Material/MaterialUtil.cpp +++ b/Sample/Material/MaterialUtil.cpp @@ -119,10 +119,10 @@ Material MaterialUtil::averagedMaterial(const std::string& name, const std::vect if (type == MATERIAL_TYPES::RefractiveMaterial) { avgeData = std::conj(1.0 - std::sqrt(1.0 + avgeData)); return RefractiveMaterial(name, avgeData.real(), avgeData.imag(), avgeMagn); - } else if (type == MATERIAL_TYPES::MaterialBySLD) { + } + if (type == MATERIAL_TYPES::MaterialBySLD) return MaterialBySLD(name, avgeData.real(), avgeData.imag(), avgeMagn); - } else - ASSERT(false); + ASSERT(false); } // Tested by Tests/Unit/Sim/Sample/MaterialTest.cpp diff --git a/Sample/Material/RefractiveMaterialImpl.cpp b/Sample/Material/RefractiveMaterialImpl.cpp index 85436c1fb3b..1a51ec9f052 100644 --- a/Sample/Material/RefractiveMaterialImpl.cpp +++ b/Sample/Material/RefractiveMaterialImpl.cpp @@ -35,7 +35,7 @@ RefractiveMaterialImpl* RefractiveMaterialImpl::clone() const complex_t RefractiveMaterialImpl::refractiveIndex(double) const { - return complex_t(1.0 - m_delta, m_beta); + return {1.0 - m_delta, m_beta}; } complex_t RefractiveMaterialImpl::refractiveIndex2(double) const @@ -46,7 +46,7 @@ complex_t RefractiveMaterialImpl::refractiveIndex2(double) const complex_t RefractiveMaterialImpl::refractiveIndex_or_SLD() const { - return complex_t(m_delta, m_beta); + return {m_delta, m_beta}; } complex_t RefractiveMaterialImpl::scalarSubtrSLD(double lambda0) const diff --git a/Sample/Multilayer/MultiLayer.cpp b/Sample/Multilayer/MultiLayer.cpp index 4cd70779bd9..a08bd90a98c 100644 --- a/Sample/Multilayer/MultiLayer.cpp +++ b/Sample/Multilayer/MultiLayer.cpp @@ -147,7 +147,7 @@ std::string MultiLayer::validate() const std::vector<std::string> errs; if (MaterialUtil::checkMaterialTypes(containedMaterials()) == MATERIAL_TYPES::InvalidMaterialType) - errs.push_back("Sample contains incompatible material definitions"); + errs.emplace_back("Sample contains incompatible material definitions"); for (size_t i = 0; i < m_layers.size(); ++i) { std::string err = m_layers[i]->validate(); diff --git a/Sim/Contrib/GISASSpecularContribution.cpp b/Sim/Contrib/GISASSpecularContribution.cpp index fd42495e602..fa78a1d78af 100644 --- a/Sim/Contrib/GISASSpecularContribution.cpp +++ b/Sim/Contrib/GISASSpecularContribution.cpp @@ -44,12 +44,11 @@ double Compute::gisasSpecularContribution(const ReSample& re_sample, const Diffu const SpinMatrix& anaMatrix = ele.analyzer(); return Compute::magneticR(R, polMatrix, anaMatrix) * geom_factor; + } - } else { - const auto* flux = dynamic_cast<const ScalarFlux*>(ele.fluxIn(0)); - ASSERT(flux); + const auto* flux = dynamic_cast<const ScalarFlux*>(ele.fluxIn(0)); + ASSERT(flux); - const complex_t R = flux->getScalarR(); - return Compute::scalarR(R) * geom_factor; - } + const complex_t R = flux->getScalarR(); + return Compute::scalarR(R) * geom_factor; } diff --git a/Sim/Export/PyFmt2.cpp b/Sim/Export/PyFmt2.cpp index d2bd4cfc788..b8a6aef0f20 100644 --- a/Sim/Export/PyFmt2.cpp +++ b/Sim/Export/PyFmt2.cpp @@ -27,9 +27,6 @@ #include "Param/Distrib/Distributions.h" #include "Param/Distrib/ParameterDistribution.h" #include <iomanip> -#include <numbers> - -using std::numbers::pi; //! Returns fixed Python code snippet that defines the function "simulate". diff --git a/Sim/Export/SampleToPython.cpp b/Sim/Export/SampleToPython.cpp index 0f3dd72697c..af326692eea 100644 --- a/Sim/Export/SampleToPython.cpp +++ b/Sim/Export/SampleToPython.cpp @@ -557,5 +557,3 @@ std::string SampleToPython::sampleCode(const MultiLayer& sample) } SampleToPython::SampleToPython() = default; - -SampleToPython::~SampleToPython() = default; diff --git a/Sim/Export/SampleToPython.h b/Sim/Export/SampleToPython.h index e0c5363fe17..e68c5225746 100644 --- a/Sim/Export/SampleToPython.h +++ b/Sim/Export/SampleToPython.h @@ -28,7 +28,7 @@ class MultiLayer; class SampleToPython { public: SampleToPython(); - ~SampleToPython(); + ~SampleToPython() = default; std::string sampleCode(const MultiLayer& sample); }; diff --git a/Sim/Fitting/SimDataPair.cpp b/Sim/Fitting/SimDataPair.cpp index d076e322361..fda76323f78 100644 --- a/Sim/Fitting/SimDataPair.cpp +++ b/Sim/Fitting/SimDataPair.cpp @@ -68,7 +68,7 @@ Datafield convertData(const ScatteringSimulation& simulation, const Datafield& d throw std::runtime_error( "FitObject::init_dataset: Detector and experimental data have different shape"); - return Datafield(*roi_data); + return {*roi_data}; } } // namespace @@ -100,7 +100,7 @@ SimDataPair::SimDataPair(simulation_builder_t builder, const Datafield& raw_data validate(); } -SimDataPair::SimDataPair(SimDataPair&& other) = default; +SimDataPair::SimDataPair(SimDataPair&& other) noexcept = default; SimDataPair::~SimDataPair() = default; diff --git a/Sim/Fitting/SimDataPair.h b/Sim/Fitting/SimDataPair.h index 6399c9f0d40..dcc9731d5c3 100644 --- a/Sim/Fitting/SimDataPair.h +++ b/Sim/Fitting/SimDataPair.h @@ -33,7 +33,7 @@ public: SimDataPair(simulation_builder_t builder, const Datafield& raw_data, std::unique_ptr<Datafield>&& raw_stdv, std::unique_ptr<Datafield>&& user_weights); - SimDataPair(SimDataPair&& other); + SimDataPair(SimDataPair&& other) noexcept; ~SimDataPair(); diff --git a/Sim/Scan/AlphaScan.cpp b/Sim/Scan/AlphaScan.cpp index 293740ba0bd..ec14f22f892 100644 --- a/Sim/Scan/AlphaScan.cpp +++ b/Sim/Scan/AlphaScan.cpp @@ -72,9 +72,9 @@ AlphaScan* AlphaScan::clone() const result->m_alpha_distrib.reset(m_alpha_distrib->clone()); if (m_beamPolarization) - result->m_beamPolarization.reset(new R3(*m_beamPolarization)); + result->m_beamPolarization = std::make_unique<R3>(*m_beamPolarization); if (m_polAnalyzer) - result->m_polAnalyzer.reset(new PolFilter(*m_polAnalyzer)); + result->m_polAnalyzer = std::make_unique<PolFilter>(*m_polAnalyzer); return result; } diff --git a/Sim/Scan/LambdaScan.cpp b/Sim/Scan/LambdaScan.cpp index 145cde63ba0..c89de389cb4 100644 --- a/Sim/Scan/LambdaScan.cpp +++ b/Sim/Scan/LambdaScan.cpp @@ -41,8 +41,8 @@ LambdaScan::LambdaScan(double alpha_i, Scale* lambdaScale) "of acceptable range."); } -LambdaScan::LambdaScan(double alpha_i, std::vector<double> lambdaList) - : LambdaScan(alpha_i, newListScan("qs", std::move(lambdaList))) +LambdaScan::LambdaScan(double alpha_i, std::vector<double> lambdaScale) + : LambdaScan(alpha_i, newListScan("qs", std::move(lambdaScale))) { } diff --git a/Sim/Scan/QzScan.cpp b/Sim/Scan/QzScan.cpp index 2d2d4efb78c..adc62841ae0 100644 --- a/Sim/Scan/QzScan.cpp +++ b/Sim/Scan/QzScan.cpp @@ -65,9 +65,9 @@ QzScan* QzScan::clone() const result->setOffset(m_offset); // TODO merge with same code in AlphaScan if (m_beamPolarization) - result->m_beamPolarization.reset(new R3(*m_beamPolarization)); + result->m_beamPolarization = std::make_unique<R3>(*m_beamPolarization); if (m_polAnalyzer) - result->m_polAnalyzer.reset(new PolFilter(*m_polAnalyzer)); + result->m_polAnalyzer = std::make_unique<PolFilter>(*m_polAnalyzer); return result; } diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp index 0f253678ebf..61b84d5ee00 100644 --- a/Sim/Simulation/DepthprobeSimulation.cpp +++ b/Sim/Simulation/DepthprobeSimulation.cpp @@ -53,7 +53,7 @@ DepthprobeSimulation::~DepthprobeSimulation() = default; Frame DepthprobeSimulation::simCoordSystem() const { - return Frame(m_scan->coordinateAxis()->clone(), m_z_axis->clone()); + return {m_scan->coordinateAxis()->clone(), m_z_axis->clone()}; } std::vector<const INode*> DepthprobeSimulation::nodeChildren() const diff --git a/Sim/Simulation/ISimulation.cpp b/Sim/Simulation/ISimulation.cpp index 5b152a378fa..aa1088ab268 100644 --- a/Sim/Simulation/ISimulation.cpp +++ b/Sim/Simulation/ISimulation.cpp @@ -245,7 +245,7 @@ void ISimulation::runSingleSimulation(const ReSample& re_sample, size_t batch_st } } catch (const std::exception& ex) { mutex.lock(); - failure_messages.push_back(ex.what()); + failure_messages.emplace_back(ex.what()); mutex.unlock(); } })); diff --git a/Tests/Unit/Device/Shape2DTest.cpp b/Tests/Unit/Device/Shape2DTest.cpp index e7d3668a200..c3c1a35904b 100644 --- a/Tests/Unit/Device/Shape2DTest.cpp +++ b/Tests/Unit/Device/Shape2DTest.cpp @@ -1,7 +1,5 @@ #include "Base/Axis/Bin.h" #include "Base/Const/Units.h" -#include <numbers> -using std::numbers::pi; #include "Device/Mask/Ellipse.h" #include "Device/Mask/Line.h" #include "Device/Mask/Rectangle.h" diff --git a/Tests/Unit/Device/SphericalDetectorTest.cpp b/Tests/Unit/Device/SphericalDetectorTest.cpp index f322d2e6704..bff6dbea498 100644 --- a/Tests/Unit/Device/SphericalDetectorTest.cpp +++ b/Tests/Unit/Device/SphericalDetectorTest.cpp @@ -16,8 +16,8 @@ // Construction of the detector with axes. TEST(SphericalDetectorTest, constructionWithAxes) { - auto axis0 = newEquiDivision("axis0", 10, 0.0, 10.0); - auto axis1 = newEquiDivision("axis1", 20, 0.0, 20.0); + auto* axis0 = newEquiDivision("axis0", 10, 0.0, 10.0); + auto* axis1 = newEquiDivision("axis1", 20, 0.0, 20.0); SphericalDetector detector(Frame(axis0->clone(), axis1->clone())); // checking dimension and axes diff --git a/Tests/Unit/Numeric/FourierTransformTest.cpp b/Tests/Unit/Numeric/FourierTransformTest.cpp index ad63441a4d4..f09306bda8d 100644 --- a/Tests/Unit/Numeric/FourierTransformTest.cpp +++ b/Tests/Unit/Numeric/FourierTransformTest.cpp @@ -1,6 +1,4 @@ #include "Base/Math/FourierTransform.h" -#include <numbers> -using std::numbers::pi; #include "Device/Data/Datafield.h" #include "Tests/GTestWrapper/google_test.h" diff --git a/Tests/Unit/Numeric/MultiQTest.cpp b/Tests/Unit/Numeric/MultiQTest.cpp index 3f97a7e8a89..f4067562bac 100644 --- a/Tests/Unit/Numeric/MultiQTest.cpp +++ b/Tests/Unit/Numeric/MultiQTest.cpp @@ -1,8 +1,6 @@ #include "Tests/Unit/Numeric/MultiQTest.h" #include "Tests/GTestWrapper/google_test.h" -using ::testing::Combine; -using ::testing::Values; using ::testing::internal::ParamGenerator; namespace formfactorTest { diff --git a/Tests/Unit/Resample/RTTest.cpp b/Tests/Unit/Resample/RTTest.cpp index 7a9aa30e0f0..60fcee5de6d 100644 --- a/Tests/Unit/Resample/RTTest.cpp +++ b/Tests/Unit/Resample/RTTest.cpp @@ -1,5 +1,3 @@ -#include <numbers> -using std::numbers::pi; #include "Resample/Flux/ScalarFlux.h" #include "Resample/Processed/ReSample.h" #include "Resample/Specular/ComputeFluxScalar.h" diff --git a/Tests/Unit/Sample/CoreAndShellTest.cpp b/Tests/Unit/Sample/CoreAndShellTest.cpp index 173844f7eba..970f50eb48d 100644 --- a/Tests/Unit/Sample/CoreAndShellTest.cpp +++ b/Tests/Unit/Sample/CoreAndShellTest.cpp @@ -1,7 +1,5 @@ #include "Sample/Particle/CoreAndShell.h" #include "Base/Const/Units.h" -#include <numbers> -using std::numbers::pi; #include "Sample/HardParticle/HardParticles.h" #include "Sample/Material/MaterialFactoryFuncs.h" #include "Sample/Particle/Particle.h" diff --git a/Tests/Unit/Sample/Lattice2DTest.cpp b/Tests/Unit/Sample/Lattice2DTest.cpp index 3bb65f5355c..2c70b46aaf7 100644 --- a/Tests/Unit/Sample/Lattice2DTest.cpp +++ b/Tests/Unit/Sample/Lattice2DTest.cpp @@ -1,6 +1,4 @@ #include "Sample/Lattice/Lattice2D.h" -#include <numbers> -using std::numbers::pi; #include "Tests/GTestWrapper/google_test.h" TEST(Lattice2DTest, basicLatticeClone) diff --git a/Tests/Unit/Sample/MultiLayerTest.cpp b/Tests/Unit/Sample/MultiLayerTest.cpp index fa3b7c9255f..3b4e85bacf7 100644 --- a/Tests/Unit/Sample/MultiLayerTest.cpp +++ b/Tests/Unit/Sample/MultiLayerTest.cpp @@ -6,8 +6,6 @@ #include "Sample/Material/MaterialFactoryFuncs.h" #include "Sample/Multilayer/Layer.h" #include "Tests/GTestWrapper/google_test.h" -#include <numbers> -using std::numbers::pi; class MultiLayerTest : public ::testing::Test { protected: diff --git a/Tests/Unit/Sample/ParticleCompositionTest.cpp b/Tests/Unit/Sample/ParticleCompositionTest.cpp index 66225c96187..948a653aa1d 100644 --- a/Tests/Unit/Sample/ParticleCompositionTest.cpp +++ b/Tests/Unit/Sample/ParticleCompositionTest.cpp @@ -1,5 +1,3 @@ -#include <numbers> -using std::numbers::pi; #include "Sample/HardParticle/Sphere.h" #include "Sample/Material/MaterialFactoryFuncs.h" #include "Sample/Particle/Compound.h" diff --git a/Tests/Unit/Sim/ParticleLayoutTest.cpp b/Tests/Unit/Sim/ParticleLayoutTest.cpp index 6a1ee06e095..4bb04eb9862 100644 --- a/Tests/Unit/Sim/ParticleLayoutTest.cpp +++ b/Tests/Unit/Sim/ParticleLayoutTest.cpp @@ -9,10 +9,7 @@ #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" -class ParticleLayoutTest : public ::testing::Test { -protected: - ~ParticleLayoutTest() override = default; -}; +class ParticleLayoutTest : public ::testing::Test {}; TEST_F(ParticleLayoutTest, ParticleLayoutInitial) { diff --git a/auto/Wrap/libBornAgainBase.py b/auto/Wrap/libBornAgainBase.py index 8d82259c11e..988a0ee8675 100644 --- a/auto/Wrap/libBornAgainBase.py +++ b/auto/Wrap/libBornAgainBase.py @@ -1855,7 +1855,7 @@ class Scale(object): __repr__ = _swig_repr def __init__(self, coord, bins): - r"""__init__(Scale self, Coordinate const & coord, std::vector< Bin1D,std::allocator< Bin1D > > const & bins) -> Scale""" + r"""__init__(Scale self, Coordinate const & coord, std::vector< Bin1D,std::allocator< Bin1D > > bins) -> Scale""" _libBornAgainBase.Scale_swiginit(self, _libBornAgainBase.new_Scale(coord, bins)) def clone(self): @@ -1933,9 +1933,9 @@ class Scale(object): """ return _libBornAgainBase.Scale_clipped(self, *args) - def __eq__(self, right): - r"""__eq__(Scale self, Scale right) -> bool""" - return _libBornAgainBase.Scale___eq__(self, right) + def __eq__(self, other): + r"""__eq__(Scale self, Scale other) -> bool""" + return _libBornAgainBase.Scale___eq__(self, other) def unit(self): r"""unit(Scale self) -> std::string""" @@ -1954,19 +1954,19 @@ class Scale(object): _libBornAgainBase.Scale_swigregister(Scale) def GenericScale(name, limits): - r"""GenericScale(std::string const & name, vdouble1d_t limits) -> Scale""" + r"""GenericScale(std::string name, vdouble1d_t limits) -> Scale""" return _libBornAgainBase.GenericScale(name, limits) def ListScan(name, points): - r"""ListScan(std::string const & name, vdouble1d_t points) -> Scale""" + r"""ListScan(std::string name, vdouble1d_t points) -> Scale""" return _libBornAgainBase.ListScan(name, points) def EquiDivision(name, N, start, end): - r"""EquiDivision(std::string const & name, size_t N, double start, double end) -> Scale""" + r"""EquiDivision(std::string name, size_t N, double start, double end) -> Scale""" return _libBornAgainBase.EquiDivision(name, N, start, end) def EquiScan(name, N, start, end): - r"""EquiScan(std::string const & name, size_t N, double start, double end) -> Scale""" + r"""EquiScan(std::string name, size_t N, double start, double end) -> Scale""" return _libBornAgainBase.EquiScan(name, N, start, end) class Frame(ICloneable): r"""Proxy of C++ Frame class.""" diff --git a/auto/Wrap/libBornAgainBase_wrap.cpp b/auto/Wrap/libBornAgainBase_wrap.cpp index d2c5a188dc2..c3847bfa04c 100644 --- a/auto/Wrap/libBornAgainBase_wrap.cpp +++ b/auto/Wrap/libBornAgainBase_wrap.cpp @@ -25785,10 +25785,10 @@ SWIGINTERN PyObject *Bin1D_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject SWIGINTERN PyObject *_wrap_new_Scale(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Coordinate *arg1 = 0 ; - std::vector< Bin1D,std::allocator< Bin1D > > *arg2 = 0 ; + SwigValueWrapper< std::vector< Bin1D,std::allocator< Bin1D > > > arg2 ; void *argp1 = 0 ; int res1 = 0 ; - void *argp2 = 0 ; + void *argp2 ; int res2 = 0 ; PyObject *swig_obj[2] ; Scale *result = 0 ; @@ -25802,17 +25802,22 @@ SWIGINTERN PyObject *_wrap_new_Scale(PyObject *self, PyObject *args) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Scale" "', argument " "1"" of type '" "Coordinate const &""'"); } arg1 = reinterpret_cast< Coordinate * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__vectorT_Bin1D_std__allocatorT_Bin1D_t_t, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Scale" "', argument " "2"" of type '" "std::vector< Bin1D,std::allocator< Bin1D > > const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Scale" "', argument " "2"" of type '" "std::vector< Bin1D,std::allocator< Bin1D > > const &""'"); + { + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__vectorT_Bin1D_std__allocatorT_Bin1D_t_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Scale" "', argument " "2"" of type '" "std::vector< Bin1D,std::allocator< Bin1D > >""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Scale" "', argument " "2"" of type '" "std::vector< Bin1D,std::allocator< Bin1D > >""'"); + } else { + std::vector< Bin1D,std::allocator< Bin1D > > * temp = reinterpret_cast< std::vector< Bin1D,std::allocator< Bin1D > > * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } } - arg2 = reinterpret_cast< std::vector< Bin1D,std::allocator< Bin1D > > * >(argp2); { try { - result = (Scale *)new Scale((Coordinate const &)*arg1,(std::vector< Bin1D,std::allocator< Bin1D > > const &)*arg2); + result = (Scale *)new Scale((Coordinate const &)*arg1,arg2); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -26760,9 +26765,8 @@ SWIGINTERN PyObject *Scale_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *ar SWIGINTERN PyObject *_wrap_GenericScale(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - std::string *arg1 = 0 ; + std::string arg1 ; std::vector< double,std::allocator< double > > *arg2 = 0 ; - int res1 = SWIG_OLDOBJ ; int res2 = SWIG_OLDOBJ ; PyObject *swig_obj[2] ; SwigValueWrapper< Scale > result; @@ -26770,14 +26774,12 @@ SWIGINTERN PyObject *_wrap_GenericScale(PyObject *self, PyObject *args) { if (!SWIG_Python_UnpackTuple(args, "GenericScale", 2, 2, swig_obj)) SWIG_fail; { std::string *ptr = (std::string *)0; - res1 = SWIG_AsPtr_std_string(swig_obj[0], &ptr); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GenericScale" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!ptr) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "GenericScale" "', argument " "1"" of type '" "std::string const &""'"); + int res = SWIG_AsPtr_std_string(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "GenericScale" "', argument " "1"" of type '" "std::string""'"); } - arg1 = ptr; + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; } { std::vector< double,std::allocator< double > > *ptr = (std::vector< double,std::allocator< double > > *)0; @@ -26792,7 +26794,7 @@ SWIGINTERN PyObject *_wrap_GenericScale(PyObject *self, PyObject *args) { } { try { - result = GenericScale((std::string const &)*arg1,(std::vector< double,std::allocator< double > > const &)*arg2); + result = GenericScale(SWIG_STD_MOVE(arg1),(std::vector< double,std::allocator< double > > const &)*arg2); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -26802,11 +26804,9 @@ SWIGINTERN PyObject *_wrap_GenericScale(PyObject *self, PyObject *args) { } } resultobj = SWIG_NewPointerObj((new Scale(result)), SWIGTYPE_p_Scale, SWIG_POINTER_OWN | 0 ); - if (SWIG_IsNewObj(res1)) delete arg1; if (SWIG_IsNewObj(res2)) delete arg2; return resultobj; fail: - if (SWIG_IsNewObj(res1)) delete arg1; if (SWIG_IsNewObj(res2)) delete arg2; return NULL; } @@ -26814,9 +26814,8 @@ fail: SWIGINTERN PyObject *_wrap_ListScan(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - std::string *arg1 = 0 ; + std::string arg1 ; std::vector< double,std::allocator< double > > *arg2 = 0 ; - int res1 = SWIG_OLDOBJ ; int res2 = SWIG_OLDOBJ ; PyObject *swig_obj[2] ; SwigValueWrapper< Scale > result; @@ -26824,14 +26823,12 @@ SWIGINTERN PyObject *_wrap_ListScan(PyObject *self, PyObject *args) { if (!SWIG_Python_UnpackTuple(args, "ListScan", 2, 2, swig_obj)) SWIG_fail; { std::string *ptr = (std::string *)0; - res1 = SWIG_AsPtr_std_string(swig_obj[0], &ptr); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ListScan" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!ptr) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ListScan" "', argument " "1"" of type '" "std::string const &""'"); + int res = SWIG_AsPtr_std_string(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "ListScan" "', argument " "1"" of type '" "std::string""'"); } - arg1 = ptr; + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; } { std::vector< double,std::allocator< double > > *ptr = (std::vector< double,std::allocator< double > > *)0; @@ -26846,7 +26843,7 @@ SWIGINTERN PyObject *_wrap_ListScan(PyObject *self, PyObject *args) { } { try { - result = ListScan((std::string const &)*arg1,(std::vector< double,std::allocator< double > > const &)*arg2); + result = ListScan(SWIG_STD_MOVE(arg1),(std::vector< double,std::allocator< double > > const &)*arg2); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -26856,11 +26853,9 @@ SWIGINTERN PyObject *_wrap_ListScan(PyObject *self, PyObject *args) { } } resultobj = SWIG_NewPointerObj((new Scale(result)), SWIGTYPE_p_Scale, SWIG_POINTER_OWN | 0 ); - if (SWIG_IsNewObj(res1)) delete arg1; if (SWIG_IsNewObj(res2)) delete arg2; return resultobj; fail: - if (SWIG_IsNewObj(res1)) delete arg1; if (SWIG_IsNewObj(res2)) delete arg2; return NULL; } @@ -26868,11 +26863,10 @@ fail: SWIGINTERN PyObject *_wrap_EquiDivision(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - std::string *arg1 = 0 ; + std::string arg1 ; size_t arg2 ; double arg3 ; double arg4 ; - int res1 = SWIG_OLDOBJ ; size_t val2 ; int ecode2 = 0 ; double val3 ; @@ -26885,14 +26879,12 @@ SWIGINTERN PyObject *_wrap_EquiDivision(PyObject *self, PyObject *args) { if (!SWIG_Python_UnpackTuple(args, "EquiDivision", 4, 4, swig_obj)) SWIG_fail; { std::string *ptr = (std::string *)0; - res1 = SWIG_AsPtr_std_string(swig_obj[0], &ptr); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "EquiDivision" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!ptr) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "EquiDivision" "', argument " "1"" of type '" "std::string const &""'"); + int res = SWIG_AsPtr_std_string(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "EquiDivision" "', argument " "1"" of type '" "std::string""'"); } - arg1 = ptr; + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; } ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { @@ -26911,7 +26903,7 @@ SWIGINTERN PyObject *_wrap_EquiDivision(PyObject *self, PyObject *args) { arg4 = static_cast< double >(val4); { try { - result = EquiDivision((std::string const &)*arg1,SWIG_STD_MOVE(arg2),arg3,arg4); + result = EquiDivision(SWIG_STD_MOVE(arg1),SWIG_STD_MOVE(arg2),arg3,arg4); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -26921,21 +26913,18 @@ SWIGINTERN PyObject *_wrap_EquiDivision(PyObject *self, PyObject *args) { } } resultobj = SWIG_NewPointerObj((new Scale(result)), SWIGTYPE_p_Scale, SWIG_POINTER_OWN | 0 ); - if (SWIG_IsNewObj(res1)) delete arg1; return resultobj; fail: - if (SWIG_IsNewObj(res1)) delete arg1; return NULL; } SWIGINTERN PyObject *_wrap_EquiScan(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - std::string *arg1 = 0 ; + std::string arg1 ; size_t arg2 ; double arg3 ; double arg4 ; - int res1 = SWIG_OLDOBJ ; size_t val2 ; int ecode2 = 0 ; double val3 ; @@ -26948,14 +26937,12 @@ SWIGINTERN PyObject *_wrap_EquiScan(PyObject *self, PyObject *args) { if (!SWIG_Python_UnpackTuple(args, "EquiScan", 4, 4, swig_obj)) SWIG_fail; { std::string *ptr = (std::string *)0; - res1 = SWIG_AsPtr_std_string(swig_obj[0], &ptr); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "EquiScan" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!ptr) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "EquiScan" "', argument " "1"" of type '" "std::string const &""'"); + int res = SWIG_AsPtr_std_string(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "EquiScan" "', argument " "1"" of type '" "std::string""'"); } - arg1 = ptr; + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; } ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { @@ -26974,7 +26961,7 @@ SWIGINTERN PyObject *_wrap_EquiScan(PyObject *self, PyObject *args) { arg4 = static_cast< double >(val4); { try { - result = EquiScan((std::string const &)*arg1,SWIG_STD_MOVE(arg2),arg3,arg4); + result = EquiScan(SWIG_STD_MOVE(arg1),SWIG_STD_MOVE(arg2),arg3,arg4); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -26984,10 +26971,8 @@ SWIGINTERN PyObject *_wrap_EquiScan(PyObject *self, PyObject *args) { } } resultobj = SWIG_NewPointerObj((new Scale(result)), SWIGTYPE_p_Scale, SWIG_POINTER_OWN | 0 ); - if (SWIG_IsNewObj(res1)) delete arg1; return resultobj; fail: - if (SWIG_IsNewObj(res1)) delete arg1; return NULL; } @@ -30335,7 +30320,7 @@ static PyMethodDef SwigMethods[] = { { "Bin1D_clipped_or_nil", _wrap_Bin1D_clipped_or_nil, METH_VARARGS, "Bin1D_clipped_or_nil(Bin1D self, double lower, double upper) -> std::optional< Bin1D >"}, { "delete_Bin1D", _wrap_delete_Bin1D, METH_O, "delete_Bin1D(Bin1D self)"}, { "Bin1D_swigregister", Bin1D_swigregister, METH_O, NULL}, - { "new_Scale", _wrap_new_Scale, METH_VARARGS, "new_Scale(Coordinate const & coord, std::vector< Bin1D,std::allocator< Bin1D > > const & bins) -> Scale"}, + { "new_Scale", _wrap_new_Scale, METH_VARARGS, "new_Scale(Coordinate const & coord, std::vector< Bin1D,std::allocator< Bin1D > > bins) -> Scale"}, { "Scale_clone", _wrap_Scale_clone, METH_O, "Scale_clone(Scale self) -> Scale"}, { "Scale_axisLabel", _wrap_Scale_axisLabel, METH_O, "Scale_axisLabel(Scale self) -> std::string"}, { "Scale_size", _wrap_Scale_size, METH_O, "Scale_size(Scale self) -> size_t"}, @@ -30357,17 +30342,17 @@ static PyMethodDef SwigMethods[] = { "Scale_clipped(Scale self, double lower, double upper) -> Scale\n" "Scale_clipped(Scale self, pvacuum_double_t bounds) -> Scale\n" ""}, - { "Scale___eq__", _wrap_Scale___eq__, METH_VARARGS, "Scale___eq__(Scale self, Scale right) -> bool"}, + { "Scale___eq__", _wrap_Scale___eq__, METH_VARARGS, "Scale___eq__(Scale self, Scale other) -> bool"}, { "Scale_unit", _wrap_Scale_unit, METH_O, "Scale_unit(Scale self) -> std::string"}, { "Scale_plottableScale", _wrap_Scale_plottableScale, METH_O, "Scale_plottableScale(Scale self) -> Scale"}, { "Scale_rescaledScale", _wrap_Scale_rescaledScale, METH_VARARGS, "Scale_rescaledScale(Scale self, std::string const & unit) -> Scale"}, { "delete_Scale", _wrap_delete_Scale, METH_O, "delete_Scale(Scale self)"}, { "Scale_swigregister", Scale_swigregister, METH_O, NULL}, { "Scale_swiginit", Scale_swiginit, METH_VARARGS, NULL}, - { "GenericScale", _wrap_GenericScale, METH_VARARGS, "GenericScale(std::string const & name, vdouble1d_t limits) -> Scale"}, - { "ListScan", _wrap_ListScan, METH_VARARGS, "ListScan(std::string const & name, vdouble1d_t points) -> Scale"}, - { "EquiDivision", _wrap_EquiDivision, METH_VARARGS, "EquiDivision(std::string const & name, size_t N, double start, double end) -> Scale"}, - { "EquiScan", _wrap_EquiScan, METH_VARARGS, "EquiScan(std::string const & name, size_t N, double start, double end) -> Scale"}, + { "GenericScale", _wrap_GenericScale, METH_VARARGS, "GenericScale(std::string name, vdouble1d_t limits) -> Scale"}, + { "ListScan", _wrap_ListScan, METH_VARARGS, "ListScan(std::string name, vdouble1d_t points) -> Scale"}, + { "EquiDivision", _wrap_EquiDivision, METH_VARARGS, "EquiDivision(std::string name, size_t N, double start, double end) -> Scale"}, + { "EquiScan", _wrap_EquiScan, METH_VARARGS, "EquiScan(std::string name, size_t N, double start, double end) -> Scale"}, { "new_Frame", _wrap_new_Frame, METH_VARARGS, "\n" "Frame(std::vector< Scale const *,std::allocator< Scale const * > > && axes)\n" "Frame(Scale const *&& ax0)\n" diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index f297cc4aebc..c7171461e37 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -2064,7 +2064,7 @@ class Datafield(object): def __init__(self, *args): r""" - __init__(Datafield self, std::string const & title, Frame frame, vdouble1d_t values={}, vdouble1d_t errSigmas={}) -> Datafield + __init__(Datafield self, std::string title, Frame frame, vdouble1d_t values={}, vdouble1d_t errSigmas={}) -> Datafield __init__(Datafield self, Frame frame, vdouble1d_t values={}, vdouble1d_t errSigmas={}) -> Datafield __init__(Datafield self, std::vector< Scale const *,std::allocator< Scale const * > > && axes, vdouble1d_t values={}, vdouble1d_t errSigmas={}) -> Datafield __init__(Datafield self, Datafield arg2) -> Datafield diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index a2b4dc3efc3..088a26b55fb 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -28894,11 +28894,10 @@ fail: SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; - std::string *arg1 = 0 ; + std::string arg1 ; Frame *arg2 = (Frame *) 0 ; std::vector< double,std::allocator< double > > *arg3 = 0 ; std::vector< double,std::allocator< double > > *arg4 = 0 ; - int res1 = SWIG_OLDOBJ ; void *argp2 = 0 ; int res2 = 0 ; int res3 = SWIG_OLDOBJ ; @@ -28908,14 +28907,12 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_0(PyObject *self, Py_ssize_t nobj if ((nobjs < 4) || (nobjs > 4)) SWIG_fail; { std::string *ptr = (std::string *)0; - res1 = SWIG_AsPtr_std_string(swig_obj[0], &ptr); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!ptr) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string const &""'"); + int res = SWIG_AsPtr_std_string(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string""'"); } - arg1 = ptr; + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; } res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Frame, 0 | 0 ); if (!SWIG_IsOK(res2)) { @@ -28946,7 +28943,7 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_0(PyObject *self, Py_ssize_t nobj } { try { - result = (Datafield *)new Datafield((std::string const &)*arg1,(Frame const *)arg2,(std::vector< double,std::allocator< double > > const &)*arg3,(std::vector< double,std::allocator< double > > const &)*arg4); + result = (Datafield *)new Datafield(arg1,(Frame const *)arg2,(std::vector< double,std::allocator< double > > const &)*arg3,(std::vector< double,std::allocator< double > > const &)*arg4); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -28956,12 +28953,10 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_0(PyObject *self, Py_ssize_t nobj } } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, SWIG_POINTER_NEW | 0 ); - if (SWIG_IsNewObj(res1)) delete arg1; if (SWIG_IsNewObj(res3)) delete arg3; if (SWIG_IsNewObj(res4)) delete arg4; return resultobj; fail: - if (SWIG_IsNewObj(res1)) delete arg1; if (SWIG_IsNewObj(res3)) delete arg3; if (SWIG_IsNewObj(res4)) delete arg4; return NULL; @@ -28970,10 +28965,9 @@ fail: SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; - std::string *arg1 = 0 ; + std::string arg1 ; Frame *arg2 = (Frame *) 0 ; std::vector< double,std::allocator< double > > *arg3 = 0 ; - int res1 = SWIG_OLDOBJ ; void *argp2 = 0 ; int res2 = 0 ; int res3 = SWIG_OLDOBJ ; @@ -28982,14 +28976,12 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_1(PyObject *self, Py_ssize_t nobj if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; { std::string *ptr = (std::string *)0; - res1 = SWIG_AsPtr_std_string(swig_obj[0], &ptr); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!ptr) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string const &""'"); + int res = SWIG_AsPtr_std_string(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string""'"); } - arg1 = ptr; + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; } res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Frame, 0 | 0 ); if (!SWIG_IsOK(res2)) { @@ -29009,7 +29001,7 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_1(PyObject *self, Py_ssize_t nobj } { try { - result = (Datafield *)new Datafield((std::string const &)*arg1,(Frame const *)arg2,(std::vector< double,std::allocator< double > > const &)*arg3); + result = (Datafield *)new Datafield(arg1,(Frame const *)arg2,(std::vector< double,std::allocator< double > > const &)*arg3); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -29019,11 +29011,9 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_1(PyObject *self, Py_ssize_t nobj } } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, SWIG_POINTER_NEW | 0 ); - if (SWIG_IsNewObj(res1)) delete arg1; if (SWIG_IsNewObj(res3)) delete arg3; return resultobj; fail: - if (SWIG_IsNewObj(res1)) delete arg1; if (SWIG_IsNewObj(res3)) delete arg3; return NULL; } @@ -29031,9 +29021,8 @@ fail: SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; - std::string *arg1 = 0 ; + std::string arg1 ; Frame *arg2 = (Frame *) 0 ; - int res1 = SWIG_OLDOBJ ; void *argp2 = 0 ; int res2 = 0 ; Datafield *result = 0 ; @@ -29041,14 +29030,12 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_2(PyObject *self, Py_ssize_t nobj if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; { std::string *ptr = (std::string *)0; - res1 = SWIG_AsPtr_std_string(swig_obj[0], &ptr); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!ptr) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string const &""'"); + int res = SWIG_AsPtr_std_string(swig_obj[0], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "new_Datafield" "', argument " "1"" of type '" "std::string""'"); } - arg1 = ptr; + arg1 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; } res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Frame, 0 | 0 ); if (!SWIG_IsOK(res2)) { @@ -29057,7 +29044,7 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_2(PyObject *self, Py_ssize_t nobj arg2 = reinterpret_cast< Frame * >(argp2); { try { - result = (Datafield *)new Datafield((std::string const &)*arg1,(Frame const *)arg2); + result = (Datafield *)new Datafield(arg1,(Frame const *)arg2); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -29067,10 +29054,8 @@ SWIGINTERN PyObject *_wrap_new_Datafield__SWIG_2(PyObject *self, Py_ssize_t nobj } } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Datafield, SWIG_POINTER_NEW | 0 ); - if (SWIG_IsNewObj(res1)) delete arg1; return resultobj; fail: - if (SWIG_IsNewObj(res1)) delete arg1; return NULL; } @@ -29610,9 +29595,9 @@ SWIGINTERN PyObject *_wrap_new_Datafield(PyObject *self, PyObject *args) { fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_Datafield'.\n" " Possible C/C++ prototypes are:\n" - " Datafield::Datafield(std::string const &,Frame const *,std::vector< double,std::allocator< double > > const &,std::vector< double,std::allocator< double > > const &)\n" - " Datafield::Datafield(std::string const &,Frame const *,std::vector< double,std::allocator< double > > const &)\n" - " Datafield::Datafield(std::string const &,Frame const *)\n" + " Datafield::Datafield(std::string,Frame const *,std::vector< double,std::allocator< double > > const &,std::vector< double,std::allocator< double > > const &)\n" + " Datafield::Datafield(std::string,Frame const *,std::vector< double,std::allocator< double > > const &)\n" + " Datafield::Datafield(std::string,Frame const *)\n" " Datafield::Datafield(Frame const *,std::vector< double,std::allocator< double > > const &,std::vector< double,std::allocator< double > > const &)\n" " Datafield::Datafield(Frame const *,std::vector< double,std::allocator< double > > const &)\n" " Datafield::Datafield(Frame const *)\n" @@ -40988,7 +40973,7 @@ static PyMethodDef SwigMethods[] = { ""}, { "FindPeaks", _wrap_FindPeaks, METH_VARARGS, "FindPeaks(Datafield data, double sigma=2, std::string const & option={}, double threshold=0.05) -> vector_pvacuum_double_t"}, { "new_Datafield", _wrap_new_Datafield, METH_VARARGS, "\n" - "Datafield(std::string const & title, Frame frame, vdouble1d_t values={}, vdouble1d_t errSigmas={})\n" + "Datafield(std::string title, Frame frame, vdouble1d_t values={}, vdouble1d_t errSigmas={})\n" "Datafield(Frame frame, vdouble1d_t values={}, vdouble1d_t errSigmas={})\n" "Datafield(std::vector< Scale const *,std::allocator< Scale const * > > && axes, vdouble1d_t values={}, vdouble1d_t errSigmas={})\n" "Datafield(Datafield arg1)\n" -- GitLab