diff --git a/.clang-tidy b/.clang-tidy index 7e4a658b407d3ef9ee7436b4fcbdc078ae2b73ef..cca76d22e646f94bc91fa5d71a367baded34e253 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -25,7 +25,10 @@ Checks: '*, -*-uppercase-literal-suffix, -*nodiscard, -abseil-string-find-str-contains, +-altera-unroll-loops, -bugprone-branch-clone, +-bugprone-easily-swappable-parameters, +-bugprone-implicit-widening-of-multiplication-result, -bugprone-suspicious-include, -cert-err58-cpp, -cert-err61-cpp, @@ -69,10 +72,10 @@ Checks: '*, -performance-noexcept-move-constructor, -performance-no-automatic-move, -performance-unnecessary-value-param, +-readability-identifier-length, -readability-misleading-indentation, -readability-use-anyofallof, - -SectionComment_To_be_manually_checked_from_time_to_time, -readability-isolate-declaration, @@ -107,6 +110,7 @@ Checks: '*, -SectionComment_Temporarily_disabled_checks__We_need_to_investigate_them_one_by_one, +-altera-id-dependent-backward-branch, -bugprone-copy-constructor-init, -bugprone-exception-escape, -bugprone-misplaced-widening-cast, @@ -117,7 +121,7 @@ Checks: '*, -google-runtime-references, -misc-non-private-member-variables-in-classes, -modernize-loop-convert, - +-readability-function-cognitive-complexity, -SectionComment_Automizable__To_be_kept_satisfied, *-use-auto, diff --git a/Base/Axis/Frame.cpp b/Base/Axis/Frame.cpp index d5103bf99bf2a716934afd606fb641a6b379f74e..4e0a931ecefe1a69ca9ec869b2e06bdf4df02ec1 100644 --- a/Base/Axis/Frame.cpp +++ b/Base/Axis/Frame.cpp @@ -19,8 +19,8 @@ Frame::Frame(const std::vector<const IAxis*>& axes) : m_axes(axes) + , m_size(1) { - m_size = 1; for (size_t k = 0; k < rank(); ++k) { ASSERT(axis(k).size() > 0); m_size *= axis(k).size(); @@ -55,9 +55,9 @@ std::vector<int> Frame::allIndices(size_t i_flat) const size_t Frame::projectedIndex(size_t i_flat, size_t k_axis) const { - if (rank() == 1) { + if (rank() == 1) return i_flat; - } else if (rank() == 2) { + if (rank() == 2) { if (k_axis == 0) return (i_flat / m_axes[1]->size()) % m_axes[0]->size(); if (k_axis == 1) @@ -65,15 +65,6 @@ size_t Frame::projectedIndex(size_t i_flat, size_t k_axis) const ASSERT(0); } ASSERT(0); - /* // generic code for rank>2 currently unused - size_t remainder(i_flat); - for (int k = rank() - 1; k >= 0; --k) { - size_t result = remainder % m_axes[k]->size(); - if (k_axis == k) - return result; - remainder /= m_axes[k]->size(); - } - */ } size_t Frame::toGlobalIndex(const std::vector<unsigned>& axes_indices) const diff --git a/Base/Axis/FrameUtil.cpp b/Base/Axis/FrameUtil.cpp index 1393b8fb618ee69a6ae1f6b0b10ecb48a8a71b4b..778025e2998d225f89724c08a0f4fa716f7c6b58 100644 --- a/Base/Axis/FrameUtil.cpp +++ b/Base/Axis/FrameUtil.cpp @@ -50,14 +50,14 @@ double FramUtil::coordinateFromBinf(double value, const IAxis& axis) return result; } -void FramUtil::coordinatesToBinf(double& x, double& y, const Frame& data) +void FramUtil::coordinatesToBinf(double& x, double& y, const Frame& frame) { - x = coordinateToBinf(x, data.xAxis()); - y = coordinateToBinf(y, data.yAxis()); + x = coordinateToBinf(x, frame.xAxis()); + y = coordinateToBinf(y, frame.yAxis()); } -void FramUtil::coordinatesFromBinf(double& x, double& y, const Frame& data) +void FramUtil::coordinatesFromBinf(double& x, double& y, const Frame& frame) { - x = coordinateFromBinf(x, data.xAxis()); - y = coordinateFromBinf(y, data.yAxis()); + x = coordinateFromBinf(x, frame.xAxis()); + y = coordinateFromBinf(y, frame.yAxis()); } diff --git a/Base/Axis/PointwiseAxis.cpp b/Base/Axis/PointwiseAxis.cpp index 41a6af82d298f7975f65e20d64db06f43500e8d9..61438dee0268b59fa99286dc4fae709fa72862c0 100644 --- a/Base/Axis/PointwiseAxis.cpp +++ b/Base/Axis/PointwiseAxis.cpp @@ -30,7 +30,7 @@ PointwiseAxis* PointwiseAxis::clone() const Bin1D PointwiseAxis::bin(size_t index) const { checkIndex(index); - return Bin1D(minary(index), maxary(index)); + return {minary(index), maxary(index)}; } double PointwiseAxis::min() const diff --git a/Base/Element/DepthProbeElement.cpp b/Base/Element/DepthProbeElement.cpp index 319b49c0b80c3961fe0b2ee7665280efced5d3a0..12fc043ca37fe0fe382840cef5fed405a27a7ebc 100644 --- a/Base/Element/DepthProbeElement.cpp +++ b/Base/Element/DepthProbeElement.cpp @@ -32,7 +32,7 @@ DepthProbeElement::DepthProbeElement(double wavelength, double alpha_i, const IA m_intensities.resize(z_positions->size(), 0.0); } -DepthProbeElement::DepthProbeElement(DepthProbeElement&& other) +DepthProbeElement::DepthProbeElement(DepthProbeElement&& other) noexcept : IElement(PolMatrices()) , m_wavelength(other.m_wavelength) , m_alpha_i(other.m_alpha_i) diff --git a/Base/Element/DepthProbeElement.h b/Base/Element/DepthProbeElement.h index 20799ac3bfa18baa9d9492dcc855ed2f5de29ad7..5dff03d6ffb38aa0ddbf29e8b6b78f4f132c13dc 100644 --- a/Base/Element/DepthProbeElement.h +++ b/Base/Element/DepthProbeElement.h @@ -27,9 +27,9 @@ class IAxis; class DepthProbeElement : public IElement { public: DepthProbeElement(double wavelength, double alpha_i, const IAxis* z_positions, - bool calculationFlag); + bool calculation_flag); DepthProbeElement(const DepthProbeElement& other) = delete; - DepthProbeElement(DepthProbeElement&& other); + DepthProbeElement(DepthProbeElement&& other) noexcept; ~DepthProbeElement(); diff --git a/Base/Vector/WavevectorInfo.cpp b/Base/Vector/WavevectorInfo.cpp index 289e46f2925a863e2458f4bf35f7058c0e4b3e3e..9bc24656c3dac02e240c333c76f9812e9622e4cd 100644 --- a/Base/Vector/WavevectorInfo.cpp +++ b/Base/Vector/WavevectorInfo.cpp @@ -35,6 +35,5 @@ WavevectorInfo WavevectorInfo::makeZeroQ() WavevectorInfo WavevectorInfo::transformed(const RotMatrix& transform) const { - return WavevectorInfo(transform.transformed(m_ki), transform.transformed(m_kf), - m_vacuum_wavelength); + return {transform.transformed(m_ki), transform.transformed(m_kf), m_vacuum_wavelength}; } diff --git a/Device/Beam/Beam.cpp b/Device/Beam/Beam.cpp index f150bc539ebd5b3101cb7263d9416d3ca533876f..305fc82d26a53494154f889bc129080a924a6c25 100644 --- a/Device/Beam/Beam.cpp +++ b/Device/Beam/Beam.cpp @@ -31,7 +31,7 @@ Beam::Beam(double intensity, double wavelength, const Direction& direction) Beam Beam::horizontalBeam() { - return Beam(1.0, 1.0, {0, 0}); + return {1.0, 1.0, {0, 0}}; } Beam::~Beam() = default; diff --git a/Device/Data/DataUtils.cpp b/Device/Data/DataUtils.cpp index ecfe6437a2fd8fd91a4fa19ceca039e6d9f32be4..43946694f13acd1eadb451f5a63aa6f1a1056e1f 100644 --- a/Device/Data/DataUtils.cpp +++ b/Device/Data/DataUtils.cpp @@ -139,12 +139,12 @@ Datafield* DataUtils::Data::importArrayToDatafield(const std::vector<std::vector return DataUtils::Array::createPField2D(vec).release(); } -std::vector<std::pair<double, double>> DataUtils::Data::FindPeaks(const Datafield& field, +std::vector<std::pair<double, double>> DataUtils::Data::FindPeaks(const Datafield& data, double sigma, const std::string& option, double threshold) { - std::vector<std::vector<double>> arr = DataUtils::Array::createVector2D(field); + std::vector<std::vector<double>> arr = DataUtils::Array::createVector2D(data); tspectrum::Spectrum2D spec; auto peaks = spec.find_peaks(arr, sigma, option, threshold); @@ -156,10 +156,10 @@ std::vector<std::pair<double, double>> DataUtils::Data::FindPeaks(const Datafiel double col_value = p.second; auto xaxis_index = static_cast<size_t>(col_value); - size_t yaxis_index = field.yAxis().size() - 1 - static_cast<size_t>(row_value); + size_t yaxis_index = data.yAxis().size() - 1 - static_cast<size_t>(row_value); - Bin1D xbin = field.xAxis().bin(xaxis_index); - Bin1D ybin = field.yAxis().bin(yaxis_index); + Bin1D xbin = data.xAxis().bin(xaxis_index); + Bin1D ybin = data.yAxis().bin(yaxis_index); double dx = col_value - static_cast<size_t>(col_value); double dy = -1.0 * (row_value - static_cast<size_t>(row_value)); diff --git a/Device/Data/DataUtils.h b/Device/Data/DataUtils.h index e598ac9f50646fda52b88158cdcb6434b41692d1..d65b987f8b8826ab9f737671e9bbc4358869bc76 100644 --- a/Device/Data/DataUtils.h +++ b/Device/Data/DataUtils.h @@ -32,7 +32,7 @@ Datafield* importArrayToDatafield(const std::vector<double>& vec); Datafield* importArrayToDatafield(const std::vector<std::vector<double>>& vec); //! Returns vector of peak center coordinates, for peaks in given histogram. -std::vector<std::pair<double, double>> FindPeaks(const Datafield& hist, double sigma = 2, +std::vector<std::pair<double, double>> FindPeaks(const Datafield& data, double sigma = 2, const std::string& option = {}, double threshold = 0.05); diff --git a/Device/Data/Datafield.cpp b/Device/Data/Datafield.cpp index ab4bfbe494bc17713f3db383ff1496ec4a92c7b5..98e06cf14b17e737fb7b5fbe5e5e9f18a14bbf09 100644 --- a/Device/Data/Datafield.cpp +++ b/Device/Data/Datafield.cpp @@ -40,7 +40,7 @@ Datafield::Datafield(const Frame* frame, const std::vector<double>& values, , m_errSigmas(errSigmas) { ASSERT(m_values.size() == m_frame->size()); - ASSERT(m_errSigmas.size() == 0 || m_errSigmas.size() == m_values.size()); + ASSERT(m_errSigmas.empty() || m_errSigmas.size() == m_values.size()); } Datafield::Datafield(const std::vector<const IAxis*>& axes) @@ -59,11 +59,11 @@ Datafield::Datafield(const std::vector<const IAxis*>& axes, const std::vector<do { } -Datafield::~Datafield() {} +Datafield::~Datafield() = default; Datafield* Datafield::clone() const { - Datafield* data = new Datafield(m_frame->cloned_axes(), m_values, m_errSigmas); + auto* data = new Datafield(m_frame->cloned_axes(), m_values, m_errSigmas); return data; } @@ -79,7 +79,7 @@ double Datafield::valAt(size_t i) const bool Datafield::hasErrorSigmas() const { - return m_errSigmas.size() > 0; + return !m_errSigmas.empty(); } const std::vector<double>& Datafield::errorSigmas() const diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp index 4b93c91063b322178a46c20a78bc287f96652f64..afd334e50ed7247415931634c45f49ac83649674 100644 --- a/Device/Detector/IDetector.cpp +++ b/Device/Detector/IDetector.cpp @@ -40,7 +40,7 @@ inline size_t ycoord(size_t index, size_t sizeY) } // namespace -IDetector::IDetector() {} +IDetector::IDetector() = default; IDetector::IDetector(const IDetector& other) : INode() @@ -301,15 +301,13 @@ size_t IDetector::detectorIndexToRegionOfInterestIndex(const size_t detectorInde /* -- IDetector::RoiOfAxis ----------------------------------------------------------- */ IDetector::RoiOfAxis::RoiOfAxis(const IAxis& axis, double _lower, double _upper) + : lower(_lower) + , upper(_upper) + , lowerIndex(axis.findClosestIndex(lower)) + , upperIndex(axis.findClosestIndex(upper)) + , roiSize(upperIndex - lowerIndex + 1) + , detectorSize(axis.size()) { - lower = _lower; - upper = _upper; - - lowerIndex = axis.findClosestIndex(lower); - upperIndex = axis.findClosestIndex(upper); - - detectorSize = axis.size(); - roiSize = upperIndex - lowerIndex + 1; } /* -- from IDetector2D -- */ diff --git a/Device/Histo/SimulationResult.cpp b/Device/Histo/SimulationResult.cpp index 9e0368af47d10469d7a6025f12b2a17ac0185472..fd0fb2201913f196e94fd47057afe0e2daabd776 100644 --- a/Device/Histo/SimulationResult.cpp +++ b/Device/Histo/SimulationResult.cpp @@ -44,13 +44,13 @@ SimulationResult::SimulationResult(const SimulationResult& other) m_coordsys.reset(other.m_coordsys->clone()); } -SimulationResult::SimulationResult(SimulationResult&& other) +SimulationResult::SimulationResult(SimulationResult&& other) noexcept : m_data(std::move(other.m_data)) , m_coordsys(std::move(other.m_coordsys)) { } -SimulationResult& SimulationResult::operator=(SimulationResult&& other) +SimulationResult& SimulationResult::operator=(SimulationResult&& other) noexcept { m_data = std::move(other.m_data); m_coordsys = std::move(other.m_coordsys); @@ -121,7 +121,7 @@ std::vector<double> SimulationResult::convertedBinCenters(size_t i_axis, Coords if (i_axis >= m_coordsys->rank()) throw std::runtime_error( "Error in SimulationResult::axis: no axis corresponds to passed index."); - auto axis = m_coordsys->createConvertedAxis(i_axis, units); + auto* axis = m_coordsys->createConvertedAxis(i_axis, units); // TODO memory leak return axis->binCenters(); } diff --git a/Device/Histo/SimulationResult.h b/Device/Histo/SimulationResult.h index 5f856f28fc4c51c50e5e59b66e45c758b7335142..967b27a4e3782cbc47533ae2237c0ee2e249f73c 100644 --- a/Device/Histo/SimulationResult.h +++ b/Device/Histo/SimulationResult.h @@ -36,9 +36,9 @@ public: ~SimulationResult(); SimulationResult(const SimulationResult& other); - SimulationResult(SimulationResult&& other); + SimulationResult(SimulationResult&& other) noexcept; - SimulationResult& operator=(SimulationResult&& other); + SimulationResult& operator=(SimulationResult&& other) noexcept; std::vector<double> flatVector(Coords units = Coords::UNDEFINED) const; Datafield* datafield(Coords units = Coords::UNDEFINED) const; diff --git a/Device/IO/DataFormatUtils.cpp b/Device/IO/DataFormatUtils.cpp index 8c1011181f27d724e0b58527131a24d3e8b1d220..52a47a92718806db76222ea793e83ba0ad0179b5 100644 --- a/Device/IO/DataFormatUtils.cpp +++ b/Device/IO/DataFormatUtils.cpp @@ -201,7 +201,7 @@ void DataUtils::Format::fillDatafield(Datafield* data, std::istream& input_strea for (auto value : buffer) data->errorSigmas().push_back(value); } - if (data->errorSigmas().size() > 0 && data->errorSigmas().size() != data->size()) + if (!data->errorSigmas().empty() && data->errorSigmas().size() != data->size()) throw std::runtime_error("Error while parsing data, num errorbars != num values"); } diff --git a/Device/IO/IOFactory.cpp b/Device/IO/IOFactory.cpp index 7e918664b5b60ae32d9614e72c90d5b3831af188..e37da20177db8a760aff529370ecdeaa42fa1ab5 100644 --- a/Device/IO/IOFactory.cpp +++ b/Device/IO/IOFactory.cpp @@ -146,7 +146,7 @@ bool IOFactory::fileTypeMatchesLoaderSelector(const std::string& fileName, Loade void IOFactory::writeSimulationResult(const SimulationResult& result, const std::string& file_name) { - auto data = result.datafield(); + const auto* data = result.datafield(); writeDatafield(*data, file_name); // TODO delete ptr } diff --git a/Device/Mask/DetectorMask.h b/Device/Mask/DetectorMask.h index 51f7013c7ee6c930a8b6aa92aaa12159dc19a832..2a4136fe1dd95170716ab913e0a80b1bbac76f91 100644 --- a/Device/Mask/DetectorMask.h +++ b/Device/Mask/DetectorMask.h @@ -51,7 +51,7 @@ public: //! @param mask_value The value of mask void addMask(const IShape2D& shape, bool mask_value); - bool isMasked(size_t index) const; + bool isMasked(size_t i_flat) const; //! Returns true if has masks bool hasMasks() const; diff --git a/Resample/Element/DiffuseElement.cpp b/Resample/Element/DiffuseElement.cpp index 2db0c3fa8cb551e6b6be3b2111faf969f5bf0500..31a3b732481986763ceba1759008d2a73bc92887 100644 --- a/Resample/Element/DiffuseElement.cpp +++ b/Resample/Element/DiffuseElement.cpp @@ -37,7 +37,7 @@ DiffuseElement::DiffuseElement(double wavelength, double alpha_i, double phi_i, { } -DiffuseElement::DiffuseElement(DiffuseElement&& other) +DiffuseElement::DiffuseElement(DiffuseElement&& other) noexcept : IElement(other.m_polMatrices) , m_wavelength(other.m_wavelength) , m_alpha_i(other.m_alpha_i) @@ -124,7 +124,7 @@ double DiffuseElement::getPhi(double x, double y) const WavevectorInfo DiffuseElement::wavevectorInfo() const { - return WavevectorInfo(getKi(), meanKf(), wavelength()); + return {getKi(), meanKf(), wavelength()}; } double DiffuseElement::integrationFactor(double x, double y) const diff --git a/Resample/Element/DiffuseElement.h b/Resample/Element/DiffuseElement.h index 8f896417410b9574f8c75af062937e362343b9ee..32bde2ebb690033fefadedfbedd465e06d24327d 100644 --- a/Resample/Element/DiffuseElement.h +++ b/Resample/Element/DiffuseElement.h @@ -38,7 +38,7 @@ public: const SpinMatrix& analyzer, bool isSpecular_, const Fluxes* fluxes_in = nullptr, const Fluxes* fluxes_out = nullptr); DiffuseElement(const DiffuseElement&) = delete; - DiffuseElement(DiffuseElement&&); + DiffuseElement(DiffuseElement&&) noexcept; ~DiffuseElement(); void setFluxes(const Fluxes* fluxes_in, const Fluxes* fluxes_out); diff --git a/Resample/Element/SpecularElement.cpp b/Resample/Element/SpecularElement.cpp index d992677ef7a95d56be1864a64bf387a2777989ba..f2effd587e87a0bd6d65bbe7aef29c85889cf08e 100644 --- a/Resample/Element/SpecularElement.cpp +++ b/Resample/Element/SpecularElement.cpp @@ -19,19 +19,17 @@ SpecularElement SpecularElement::FromQzScan(double kz, const PolMatrices& polMatrices, bool computable) { - return SpecularElement(computable, polMatrices, [kz](const SliceStack& slices) { - return Compute::Kz::computeKzFromSLDs(slices, kz); - }); + return {computable, polMatrices, + [kz](const SliceStack& slices) { return Compute::Kz::computeKzFromSLDs(slices, kz); }}; } SpecularElement SpecularElement::FromAlphaScan(double wavelength, double alpha, const PolMatrices& polMatrices, bool computable) { - return SpecularElement( - computable, polMatrices, - [k = vecOfLambdaAlphaPhi(wavelength, alpha, 0.0)](const SliceStack& slices) { - return Compute::Kz::computeKzFromRefIndices(slices, k); - }); + return {computable, polMatrices, + [k = vecOfLambdaAlphaPhi(wavelength, alpha, 0.0)](const SliceStack& slices) { + return Compute::Kz::computeKzFromRefIndices(slices, k); + }}; } SpecularElement::SpecularElement(bool computable, const PolMatrices& polMatrices, @@ -43,7 +41,7 @@ SpecularElement::SpecularElement(bool computable, const PolMatrices& polMatrices { } -SpecularElement::SpecularElement(SpecularElement&& other) = default; +SpecularElement::SpecularElement(SpecularElement&& other) noexcept = default; SpecularElement::~SpecularElement() = default; diff --git a/Resample/Element/SpecularElement.h b/Resample/Element/SpecularElement.h index 03406a8896e520ccb60eea48cbf5a2abb777c288..bab5c0e2d38cd2901d4ef417ab308ca790f67ef4 100644 --- a/Resample/Element/SpecularElement.h +++ b/Resample/Element/SpecularElement.h @@ -37,7 +37,7 @@ public: const PolMatrices& polMatrices, bool computable); SpecularElement(const SpecularElement& other) = delete; - SpecularElement(SpecularElement&& other); + SpecularElement(SpecularElement&& other) noexcept; ~SpecularElement(); diff --git a/Resample/Flux/MatrixFlux.cpp b/Resample/Flux/MatrixFlux.cpp index 7222628a2ee144297525afaf7f2c91a1508871c4..c327ba1dfb4a66db9f45fe30aa753b5532a115ca 100644 --- a/Resample/Flux/MatrixFlux.cpp +++ b/Resample/Flux/MatrixFlux.cpp @@ -135,7 +135,7 @@ SpinMatrix MatrixFlux::computeInverseP() const const complex_t beta = m_lambda.v - m_lambda.u; if (std::abs(alpha * alpha - beta * beta) == 0.) - return SpinMatrix(); + return {}; SpinMatrix result = pMatrixHelper(-1.); result *= 2. / (alpha * alpha - beta * beta); @@ -143,7 +143,7 @@ SpinMatrix MatrixFlux::computeInverseP() const return result; } -SpinMatrix MatrixFlux::computeDeltaMatrix(double thickness) +SpinMatrix MatrixFlux::computeDeltaMatrix(double thickness) const { const complex_t alpha = 0.5 * thickness * (m_lambda.v + m_lambda.u); diff --git a/Resample/Flux/MatrixFlux.h b/Resample/Flux/MatrixFlux.h index aefe82d966eddba19e8d93d9662438c55d117b83..43434131b83285cd67903a88c492c2bd1f77e3eb 100644 --- a/Resample/Flux/MatrixFlux.h +++ b/Resample/Flux/MatrixFlux.h @@ -48,7 +48,7 @@ public: SpinMatrix computeP() const; SpinMatrix computeInverseP() const; - SpinMatrix computeDeltaMatrix(double thickness); + SpinMatrix computeDeltaMatrix(double thickness) const; SpinMatrix getReflectionMatrix() const { return m_R; }; diff --git a/Resample/Particle/ReMesocrystal.cpp b/Resample/Particle/ReMesocrystal.cpp index e73ad406a6def17a7d2786d1c483786c83558306..8d53a5b138fa9fe7f6e6ddc8b872c4d1dcbd1861 100644 --- a/Resample/Particle/ReMesocrystal.cpp +++ b/Resample/Particle/ReMesocrystal.cpp @@ -31,7 +31,7 @@ ReMesocrystal::ReMesocrystal(const std::optional<size_t>& i_layer, const Lattice calculateLargestReciprocalDistance(); } -ReMesocrystal::~ReMesocrystal() {} +ReMesocrystal::~ReMesocrystal() = default; ReMesocrystal* ReMesocrystal::clone() const { diff --git a/Resample/Processed/ReSample.cpp b/Resample/Processed/ReSample.cpp index 891ad2918f6a381fd2a9cc5ae6071d75cd739b42..37e101e1a5a5e8e04c084918965885cc7d89faed 100644 --- a/Resample/Processed/ReSample.cpp +++ b/Resample/Processed/ReSample.cpp @@ -282,7 +282,7 @@ ReLayout makeReLayout(const ParticleLayout& layout, const SliceStack& slices, do const auto* iff = layout.interferenceFunction(); - return ReLayout(surface_density, std::move(coherentParticles), iff ? iff->clone() : nullptr); + return {surface_density, std::move(coherentParticles), iff ? iff->clone() : nullptr}; } //! Returns collection of all ReLayout%s, for use in ReSample constructor. @@ -324,7 +324,7 @@ ReSample ReSample::make(const MultiLayer& sample, const SimulationOptions& optio const SliceStack stack2 = options.useAvgMaterials() ? setAvgeMaterials(stack1, layouts) : stack1; - return ReSample(sample, polarized, std::move(layouts), stack2); + return {sample, polarized, std::move(layouts), stack2}; } ReSample::ReSample(const MultiLayer& sample, bool polarized, std::vector<ReLayout>&& layouts, diff --git a/Resample/Processed/Slicer.cpp b/Resample/Processed/Slicer.cpp index 9b14649766c33bcbffb9ea17792aa295634fdd1d..6c22c0558d36f5d369ff152c446ab01b75be55a0 100644 --- a/Resample/Processed/Slicer.cpp +++ b/Resample/Processed/Slicer.cpp @@ -101,28 +101,28 @@ ReParticle* createParticleSlice(const IFormFactor* ff, ZLimits limits, const R3& if (const auto* f = dynamic_cast<const Pyramid2*>(ff)) { const SlicingEffects effects = computeSlicingEffects(limits, translation, f->height()); double dbase_edge = 2 * effects.dz_bottom * Math::cot(f->alpha()); - auto slicedff = new Pyramid2(f->length() - dbase_edge, f->width() - dbase_edge, - f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); + auto* slicedff = new Pyramid2(f->length() - dbase_edge, f->width() - dbase_edge, + f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Box*>(ff)) { const SlicingEffects effects = computeSlicingEffects(limits, translation, f->height()); - auto slicedff = + auto* slicedff = new Box(f->length(), f->width(), f->height() - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Cone*>(ff)) { const SlicingEffects effects = computeSlicingEffects(limits, translation, f->height()); double dradius = effects.dz_bottom * Math::cot(f->alpha()); - auto slicedff = new Cone(f->radius() - dradius, - f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); + auto* slicedff = new Cone(f->radius() - dradius, + f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Pyramid6*>(ff)) { const SlicingEffects effects = computeSlicingEffects(limits, translation, f->height()); double dbase_edge = effects.dz_bottom * Math::cot(f->alpha()); - auto slicedff = new Pyramid6(f->baseEdge() - dbase_edge, - f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); + auto* slicedff = new Pyramid6(f->baseEdge() - dbase_edge, + f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Bipyramid4*>(ff)) { @@ -130,38 +130,40 @@ ReParticle* createParticleSlice(const IFormFactor* ff, ZLimits limits, const R3& computeSlicingEffects(limits, translation, f->height() * (1 + f->heightRatio())); if (effects.dz_bottom > f->height()) { double dbase_edge = 2 * (effects.dz_bottom - f->height()) * Math::cot(f->alpha()); - auto slicedff = new Pyramid4(f->length() - dbase_edge, - f->height() * (1 + f->heightRatio()) - effects.dz_bottom - - effects.dz_top, - f->alpha()); + auto* slicedff = new Pyramid4(f->length() - dbase_edge, + f->height() * (1 + f->heightRatio()) - effects.dz_bottom + - effects.dz_top, + f->alpha()); return createTransformedFormFactor(slicedff, effects.position, rot); } if (effects.dz_top > f->heightRatio() * f->height()) { double dbase_edge = 2 * (f->height() - effects.dz_bottom) * Math::cot(f->alpha()); - auto slicedff = new Pyramid4(f->length() - dbase_edge, - f->height() * (1 + f->heightRatio()) - effects.dz_bottom - - effects.dz_top, - M_PI - f->alpha()); + auto* slicedff = new Pyramid4(f->length() - dbase_edge, + f->height() * (1 + f->heightRatio()) - effects.dz_bottom + - effects.dz_top, + M_PI - f->alpha()); return createTransformedFormFactor(slicedff, effects.position, rot); } - auto slicedff = new Bipyramid4(f->length(), f->height() - effects.dz_bottom, - f->heightRatio() * f->height() - effects.dz_top, f->alpha()); + auto* slicedff = + new Bipyramid4(f->length(), f->height() - effects.dz_bottom, + f->heightRatio() * f->height() - effects.dz_top, f->alpha()); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Cylinder*>(ff)) { auto effects = computeSlicingEffects(limits, translation, f->height()); - auto slicedff = new Cylinder(f->radius(), f->height() - effects.dz_bottom - effects.dz_top); + auto* slicedff = + new Cylinder(f->radius(), f->height() - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const EllipsoidalCylinder*>(ff)) { auto effects = computeSlicingEffects(limits, translation, f->height()); - auto slicedff = new EllipsoidalCylinder(f->radiusX(), f->radiusY(), - f->height() - effects.dz_bottom - effects.dz_top); + auto* slicedff = new EllipsoidalCylinder(f->radiusX(), f->radiusY(), + f->height() - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const HorizontalCylinder*>(ff)) { auto effects = computeSlicingEffects(limits, translation, 2 * f->radius()); - auto slicedff = + auto* slicedff = new HorizontalCylinder(f->radius(), f->length(), -f->radius() + effects.dz_bottom, f->radius() - effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); @@ -174,63 +176,65 @@ ReParticle* createParticleSlice(const IFormFactor* ff, ZLimits limits, const R3& } const double h = 2 * f->radius(); auto effects = computeSlicingEffects(limits, translation, h); - auto slicedff = new TruncatedSphere(f->radius(), h - effects.dz_bottom, effects.dz_top); + auto* slicedff = new TruncatedSphere(f->radius(), h - effects.dz_bottom, effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, nullptr); } else if (const auto* f = dynamic_cast<const Spheroid*>(ff)) { double flattening = f->height() / (2.0 * f->radius()); auto effects = computeSlicingEffects(limits, translation, f->height()); - auto slicedff = new TruncatedSpheroid(f->radius(), f->height() - effects.dz_bottom, - flattening, effects.dz_top); + auto* slicedff = new TruncatedSpheroid(f->radius(), f->height() - effects.dz_bottom, + flattening, effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const LongBoxGauss*>(ff)) { auto effects = computeSlicingEffects(limits, translation, f->height()); - auto slicedff = new LongBoxGauss(f->length(), f->width(), - f->height() - effects.dz_bottom - effects.dz_top); + auto* slicedff = new LongBoxGauss(f->length(), f->width(), + f->height() - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const LongBoxLorentz*>(ff)) { auto effects = computeSlicingEffects(limits, translation, f->height()); - auto slicedff = new LongBoxLorentz(f->length(), f->width(), - f->height() - effects.dz_bottom - effects.dz_top); + auto* slicedff = new LongBoxLorentz(f->length(), f->width(), + f->height() - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Prism3*>(ff)) { auto effects = computeSlicingEffects(limits, translation, f->height()); - auto slicedff = new Prism3(f->baseEdge(), f->height() - effects.dz_bottom - effects.dz_top); + auto* slicedff = + new Prism3(f->baseEdge(), f->height() - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Prism6*>(ff)) { auto effects = computeSlicingEffects(limits, translation, f->height()); - auto slicedff = new Prism6(f->baseEdge(), f->height() - effects.dz_bottom - effects.dz_top); + auto* slicedff = + new Prism6(f->baseEdge(), f->height() - effects.dz_bottom - effects.dz_top); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Pyramid4*>(ff)) { auto effects = computeSlicingEffects(limits, translation, f->height()); double dbaseEdge = 2 * effects.dz_bottom * Math::cot(f->alpha()); - auto slicedff = new Pyramid4(f->baseEdge() - dbaseEdge, - f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); + auto* slicedff = new Pyramid4(f->baseEdge() - dbaseEdge, + f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const Pyramid3*>(ff)) { auto effects = computeSlicingEffects(limits, translation, f->height()); double dbaseEdge = 2 * sqrt(3) * effects.dz_bottom * Math::cot(f->alpha()); - auto slicedff = new Pyramid3(f->baseEdge() - dbaseEdge, - f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); + auto* slicedff = new Pyramid3(f->baseEdge() - dbaseEdge, + f->height() - effects.dz_bottom - effects.dz_top, f->alpha()); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const TruncatedSphere*>(ff)) { double height = f->height() - f->removedTop(); auto effects = computeSlicingEffects(limits, translation, height); - auto slicedff = new TruncatedSphere(f->radius(), f->height() - effects.dz_bottom, - effects.dz_top + f->removedTop()); + auto* slicedff = new TruncatedSphere(f->radius(), f->height() - effects.dz_bottom, + effects.dz_top + f->removedTop()); return createTransformedFormFactor(slicedff, effects.position, rot); } else if (const auto* f = dynamic_cast<const TruncatedSpheroid*>(ff)) { double height = f->height() - f->removedTop(); auto effects = computeSlicingEffects(limits, translation, height); - auto slicedff = + auto* slicedff = new TruncatedSpheroid(f->radius(), f->height() - effects.dz_bottom, f->heightFlattening(), effects.dz_top + f->removedTop()); return createTransformedFormFactor(slicedff, effects.position, rot); @@ -400,7 +404,7 @@ Span Compute::Slicing::zSpan(const IParticle* particle) } else if (const auto* p = dynamic_cast<const Compound*>(particle)) { const auto subparticles = p->decompose(); - ASSERT(subparticles.size() > 0); + ASSERT(!subparticles.empty()); Span result = zSpan(subparticles[0]); for (const auto* subparticle : subparticles) // TODO why no rotation and translation as for CoreAndShell ?? diff --git a/Resample/Specular/ComputeFluxMagnetic.cpp b/Resample/Specular/ComputeFluxMagnetic.cpp index e15980dcd9d95dc0b375e7d5d3d10d1332547026..e98fc34364ec04c7bc52137c4c70a660e457e4e7 100644 --- a/Resample/Specular/ComputeFluxMagnetic.cpp +++ b/Resample/Specular/ComputeFluxMagnetic.cpp @@ -196,7 +196,7 @@ SpinMatrix Compute::SpecularMagnetic::topLayerR(const SliceStack& slices, ASSERT(slices.size() == kzs.size()); const auto N = slices.size(); if (N == 1) - return SpinMatrix(); + return {}; if (kzs[0] == 0.) return -SpinMatrix::One(); diff --git a/Sim/Fitting/FitStatus.cpp b/Sim/Fitting/FitStatus.cpp index 5caedc9f76ec356ffdda6ef3371b1ad424f6a59b..20248aad6a18fa154040eafdaceac4121d164a8b 100644 --- a/Sim/Fitting/FitStatus.cpp +++ b/Sim/Fitting/FitStatus.cpp @@ -78,7 +78,7 @@ mumufit::MinimizerResult FitStatus::minimizerResult() const throw std::runtime_error("FitStatus::minimizerResult() -> Minimizer result wasn't set. " "Make sure that FitObjective::finalize() was called."); - return mumufit::MinimizerResult(*m_minimizer_result); + return {*m_minimizer_result}; } void FitStatus::finalize(const mumufit::MinimizerResult& result) diff --git a/Tests/Functional/Consistence/ConsistenceTests.cpp b/Tests/Functional/Consistence/ConsistenceTests.cpp index 0d878d7ad71cb6a246b0631d571926c3de2c8ecc..c464df7bbcbda87d46f1557cbc82d797c0c87967 100644 --- a/Tests/Functional/Consistence/ConsistenceTests.cpp +++ b/Tests/Functional/Consistence/ConsistenceTests.cpp @@ -58,7 +58,7 @@ TEST_F(Consistence, PolarizedScalarSpinFlip) auto* sample = ExemplarySamples::createPlainMultiLayerBySLD(); auto simulation = test::makeSimulation::BasicYPolarizedSpecular(*sample, "PM", false); const SimulationResult result = simulation->simulate(); - auto data = result.datafield(); + auto* data = result.datafield(); for (auto r : data->flatVector()) EXPECT_EQ(r, 0); } @@ -68,7 +68,7 @@ TEST_F(Consistence, PolarizedScalarSpinFlipParticles) auto* sample = ExemplarySamples::createCylindersAndPrisms(); auto simulation = test::makeSimulation::MiniZPolarizedGISAS(*sample, "PM"); const SimulationResult result = simulation->simulate(); - auto data = result.datafield(); + auto* data = result.datafield(); for (auto r : data->flatVector()) EXPECT_EQ(r, 0); } diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index 97ea1d4b4887ba1b7728b5273efba8693f3320f1..c480fcafc38c197c01927e7d478e4b369510189f 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -2178,7 +2178,7 @@ def importArrayToDatafield(*args): return _libBornAgainDevice.importArrayToDatafield(*args) def FindPeaks(*args): - r"""FindPeaks(Datafield hist, double sigma=2, std::string const & option={}, double threshold=0.05) -> vector_pvacuum_double_t""" + r"""FindPeaks(Datafield data, double sigma=2, std::string const & option={}, double threshold=0.05) -> vector_pvacuum_double_t""" return _libBornAgainDevice.FindPeaks(*args) class Beam(libBornAgainParam.INode): r"""Proxy of C++ Beam class.""" @@ -2715,9 +2715,9 @@ class DetectorMask(object): r"""addMask(DetectorMask self, IShape2D shape, bool mask_value)""" return _libBornAgainDevice.DetectorMask_addMask(self, shape, mask_value) - def isMasked(self, index): - r"""isMasked(DetectorMask self, size_t index) -> bool""" - return _libBornAgainDevice.DetectorMask_isMasked(self, index) + def isMasked(self, i_flat): + r"""isMasked(DetectorMask self, size_t i_flat) -> bool""" + return _libBornAgainDevice.DetectorMask_isMasked(self, i_flat) def hasMasks(self): r"""hasMasks(DetectorMask self) -> bool""" diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index 68e56e1740d15131f47ad1414cbcbae12caaff19..8322ee06ce1521a1b13b9f78c572f02242e06380 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -38332,7 +38332,7 @@ static PyMethodDef SwigMethods[] = { "importArrayToDatafield(vdouble1d_t vec) -> Datafield\n" "importArrayToDatafield(vdouble2d_t vec) -> Datafield\n" ""}, - { "FindPeaks", _wrap_FindPeaks, METH_VARARGS, "FindPeaks(Datafield hist, double sigma=2, std::string const & option={}, double threshold=0.05) -> vector_pvacuum_double_t"}, + { "FindPeaks", _wrap_FindPeaks, METH_VARARGS, "FindPeaks(Datafield data, double sigma=2, std::string const & option={}, double threshold=0.05) -> vector_pvacuum_double_t"}, { "new_Beam", _wrap_new_Beam, METH_VARARGS, "new_Beam(double intensity, double wavelength, Direction const & direction) -> Beam"}, { "delete_Beam", _wrap_delete_Beam, METH_O, "delete_Beam(Beam self)"}, { "Beam_clone", _wrap_Beam_clone, METH_O, "Beam_clone(Beam self) -> Beam"}, @@ -38495,7 +38495,7 @@ static PyMethodDef SwigMethods[] = { "new_DetectorMask(DetectorMask other) -> DetectorMask\n" ""}, { "DetectorMask_addMask", _wrap_DetectorMask_addMask, METH_VARARGS, "DetectorMask_addMask(DetectorMask self, IShape2D shape, bool mask_value)"}, - { "DetectorMask_isMasked", _wrap_DetectorMask_isMasked, METH_VARARGS, "DetectorMask_isMasked(DetectorMask self, size_t index) -> bool"}, + { "DetectorMask_isMasked", _wrap_DetectorMask_isMasked, METH_VARARGS, "DetectorMask_isMasked(DetectorMask self, size_t i_flat) -> bool"}, { "DetectorMask_hasMasks", _wrap_DetectorMask_hasMasks, METH_O, "DetectorMask_hasMasks(DetectorMask self) -> bool"}, { "DetectorMask_numberOfMaskedChannels", _wrap_DetectorMask_numberOfMaskedChannels, METH_O, "DetectorMask_numberOfMaskedChannels(DetectorMask self) -> int"}, { "DetectorMask_numberOfMasks", _wrap_DetectorMask_numberOfMasks, METH_O, "DetectorMask_numberOfMasks(DetectorMask self) -> size_t"}, diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py index 46854e53619c40f74a3f73dfaeea6cb902a07306..1b6a9b78fc23f3358f7a9b4b1e5e0a4d1c64bc57 100644 --- a/auto/Wrap/libBornAgainSim.py +++ b/auto/Wrap/libBornAgainSim.py @@ -3367,7 +3367,7 @@ class SimulationBuilderWrapper(PyBuilderCallback): def create_par_dict(self, pars): """ - Convertion of ba.Parameters to Python dictionary + Conversion of ba.Parameters to Python dictionary """ pars_dict = dict() for index, p in enumerate(pars):