From 884ef2c9bf25a36442d0bcbbda7497f012faf1be Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 3 Feb 2022 14:27:42 +0100 Subject: [PATCH] rename -> PoissonBackground --- ...iseBackground.cpp => PoissonBackground.cpp} | 14 +++++++------- ...onNoiseBackground.h => PoissonBackground.h} | 18 +++++++++--------- Core/Export/SimulationToPython.cpp | 6 +++--- Examples/fit52_Advanced/fit_along_slices.py | 2 +- GUI/Model/Item/BackgroundItems.cpp | 6 +++--- GUI/Model/Item/BackgroundItems.h | 2 +- GUI/Model/MakeItem/BackgroundItemCatalog.cpp | 4 ++-- GUI/View/FromDomain/FromDomain.cpp | 6 +++--- Wrap/Swig/libBornAgainCore.i | 4 ++-- .../ex02_AdvancedExamples/fit_along_slices.py | 2 +- 10 files changed, 32 insertions(+), 32 deletions(-) rename Core/Background/{PoissonNoiseBackground.cpp => PoissonBackground.cpp} (62%) rename Core/Background/{PoissonNoiseBackground.h => PoissonBackground.h} (60%) diff --git a/Core/Background/PoissonNoiseBackground.cpp b/Core/Background/PoissonBackground.cpp similarity index 62% rename from Core/Background/PoissonNoiseBackground.cpp rename to Core/Background/PoissonBackground.cpp index 92f8163d918..c0a69402ad8 100644 --- a/Core/Background/PoissonNoiseBackground.cpp +++ b/Core/Background/PoissonBackground.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file Core/Background/PoissonNoiseBackground.cpp -//! @brief Implements class PoissonNoiseBackground. +//! @file Core/Background/PoissonBackground.cpp +//! @brief Implements class PoissonBackground. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,20 +12,20 @@ // // ************************************************************************************************ -#include "Core/Background/PoissonNoiseBackground.h" +#include "Core/Background/PoissonBackground.h" #include "Base/Math/Functions.h" -PoissonNoiseBackground::PoissonNoiseBackground() +PoissonBackground::PoissonBackground() : IBackground({}) { } -PoissonNoiseBackground* PoissonNoiseBackground::clone() const +PoissonBackground* PoissonBackground::clone() const { - return new PoissonNoiseBackground; + return new PoissonBackground; } -double PoissonNoiseBackground::addBackground(double intensity) const +double PoissonBackground::addBackground(double intensity) const { return Math::GeneratePoissonRandom(intensity); } diff --git a/Core/Background/PoissonNoiseBackground.h b/Core/Background/PoissonBackground.h similarity index 60% rename from Core/Background/PoissonNoiseBackground.h rename to Core/Background/PoissonBackground.h index 25002bdbce7..ea8f6315f75 100644 --- a/Core/Background/PoissonNoiseBackground.h +++ b/Core/Background/PoissonBackground.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file Core/Background/PoissonNoiseBackground.h -//! @brief Defines class PoissonNoiseBackground. +//! @file Core/Background/PoissonBackground.h +//! @brief Defines class PoissonBackground. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_CORE_BACKGROUND_POISSONNOISEBACKGROUND_H -#define BORNAGAIN_CORE_BACKGROUND_POISSONNOISEBACKGROUND_H +#ifndef BORNAGAIN_CORE_BACKGROUND_POISSONBACKGROUND_H +#define BORNAGAIN_CORE_BACKGROUND_POISSONBACKGROUND_H #include "Core/Background/IBackground.h" @@ -21,14 +21,14 @@ //! //! @ingroup simulation -class PoissonNoiseBackground : public IBackground { +class PoissonBackground : public IBackground { public: - PoissonNoiseBackground(); - PoissonNoiseBackground* clone() const override; - std::string className() const final { return "PoissonNoiseBackground"; } + PoissonBackground(); + PoissonBackground* clone() const override; + std::string className() const final { return "PoissonBackground"; } // const auto tooltip = "class_tooltip"; double addBackground(double intensity) const override; }; -#endif // BORNAGAIN_CORE_BACKGROUND_POISSONNOISEBACKGROUND_H +#endif // BORNAGAIN_CORE_BACKGROUND_POISSONBACKGROUND_H diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index 92311368aad..e2101ed1e88 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -16,7 +16,7 @@ #include "Base/Py/PyFmt.h" #include "Base/Util/Algorithms.h" #include "Core/Background/ConstantBackground.h" -#include "Core/Background/PoissonNoiseBackground.h" +#include "Core/Background/PoissonBackground.h" #include "Core/Export/PyFmt2.h" #include "Core/Export/PyFmtLimits.h" #include "Core/Export/SampleToPython.h" @@ -401,8 +401,8 @@ std::string defineBackground(const ISimulation* simulation) << Py::Fmt::printScientificDouble(constant_bg->backgroundValue()) << ")\n"; result << indent() << "simulation.setBackground(background)\n"; } - } else if (dynamic_cast<const PoissonNoiseBackground*>(bg)) { - result << indent() << "background = ba.PoissonNoiseBackground()\n"; + } else if (dynamic_cast<const PoissonBackground*>(bg)) { + result << indent() << "background = ba.PoissonBackground()\n"; result << indent() << "simulation.setBackground(background)\n"; } return result.str(); diff --git a/Examples/fit52_Advanced/fit_along_slices.py b/Examples/fit52_Advanced/fit_along_slices.py index acb2281096a..5da829154d4 100755 --- a/Examples/fit52_Advanced/fit_along_slices.py +++ b/Examples/fit52_Advanced/fit_along_slices.py @@ -68,7 +68,7 @@ def create_real_data(): # retrieving simulated data in the form of numpy array simulation = get_simulation(params, add_masks=False) - simulation.setBackground(ba.PoissonNoiseBackground()) + simulation.setBackground(ba.PoissonBackground()) simulation.runSimulation() return simulation.result().array() diff --git a/GUI/Model/Item/BackgroundItems.cpp b/GUI/Model/Item/BackgroundItems.cpp index 3cf6d021701..99c3f2a03d3 100644 --- a/GUI/Model/Item/BackgroundItems.cpp +++ b/GUI/Model/Item/BackgroundItems.cpp @@ -14,7 +14,7 @@ #include "GUI/Model/Item/BackgroundItems.h" #include "Core/Background/ConstantBackground.h" -#include "Core/Background/PoissonNoiseBackground.h" +#include "Core/Background/PoissonBackground.h" #include "GUI/Model/Types/DoubleDescriptor.h" #include "GUI/Model/XML/Serializer.h" @@ -35,9 +35,9 @@ void ConstantBackgroundItem::serialize(Serializer& s) s.rw(m_backgroundValue); } -std::unique_ptr<IBackground> PoissonNoiseBackgroundItem::createBackground() const +std::unique_ptr<IBackground> PoissonBackgroundItem::createBackground() const { - return std::make_unique<PoissonNoiseBackground>(); + return std::make_unique<PoissonBackground>(); } std::unique_ptr<IBackground> NoBackgroundItem::createBackground() const diff --git a/GUI/Model/Item/BackgroundItems.h b/GUI/Model/Item/BackgroundItems.h index 4b3cca613bf..0df45095136 100644 --- a/GUI/Model/Item/BackgroundItems.h +++ b/GUI/Model/Item/BackgroundItems.h @@ -43,7 +43,7 @@ public: DOUBLE_PROPERTY(backgroundValue, BackgroundValue); }; -class PoissonNoiseBackgroundItem : public BackgroundItem { +class PoissonBackgroundItem : public BackgroundItem { public: std::unique_ptr<IBackground> createBackground() const override; }; diff --git a/GUI/Model/MakeItem/BackgroundItemCatalog.cpp b/GUI/Model/MakeItem/BackgroundItemCatalog.cpp index ac68f40da89..a86aba7d143 100644 --- a/GUI/Model/MakeItem/BackgroundItemCatalog.cpp +++ b/GUI/Model/MakeItem/BackgroundItemCatalog.cpp @@ -24,7 +24,7 @@ BackgroundItem* BackgroundItemCatalog::create(Type type) case Type::Constant: return new ConstantBackgroundItem(); case Type::Poission: - return new PoissonNoiseBackgroundItem(); + return new PoissonBackgroundItem(); } ASSERT(false); } @@ -53,7 +53,7 @@ BackgroundItemCatalog::Type BackgroundItemCatalog::type(const BackgroundItem* it return Type::None; if (dynamic_cast<const ConstantBackgroundItem*>(item)) return Type::Constant; - if (dynamic_cast<const PoissonNoiseBackgroundItem*>(item)) + if (dynamic_cast<const PoissonBackgroundItem*>(item)) return Type::Poission; ASSERT(false); diff --git a/GUI/View/FromDomain/FromDomain.cpp b/GUI/View/FromDomain/FromDomain.cpp index 60ec2aec1c6..ce51174f29c 100644 --- a/GUI/View/FromDomain/FromDomain.cpp +++ b/GUI/View/FromDomain/FromDomain.cpp @@ -15,7 +15,7 @@ #include "GUI/View/FromDomain/FromDomain.h" #include "Base/Const/Units.h" #include "Core/Background/ConstantBackground.h" -#include "Core/Background/PoissonNoiseBackground.h" +#include "Core/Background/PoissonBackground.h" #include "Core/Scan/AlphaScan.h" #include "Core/Scan/ScanResolution.h" #include "Core/Simulation/includeSimulations.h" @@ -743,8 +743,8 @@ void GUI::Transform::FromDomain::setBackground(InstrumentItem* instrument_item, auto* constant_bg_item = instrument_item->setBackgroundType<ConstantBackgroundItem>(); double value = p_constant_bg->backgroundValue(); constant_bg_item->setBackgroundValue(value); - } else if (dynamic_cast<const PoissonNoiseBackground*>(p_bg)) - instrument_item->setBackgroundType<PoissonNoiseBackgroundItem>(); + } else if (dynamic_cast<const PoissonBackground*>(p_bg)) + instrument_item->setBackgroundType<PoissonBackgroundItem>(); } void GUI::Transform::FromDomain::setFootprintFactor(const IFootprintFactor* footprint, diff --git a/Wrap/Swig/libBornAgainCore.i b/Wrap/Swig/libBornAgainCore.i index 1bb1c1c3f0f..9611ec8e3cd 100644 --- a/Wrap/Swig/libBornAgainCore.i +++ b/Wrap/Swig/libBornAgainCore.i @@ -60,7 +60,7 @@ #include "Sample/Scattering/ISampleNode.h" #include "Core/Background/ConstantBackground.h" -#include "Core/Background/PoissonNoiseBackground.h" +#include "Core/Background/PoissonBackground.h" #include "Core/Export/ExportToPython.h" #include "Core/Fitting/FitObjective.h" #include "Core/Fitting/IterationInfo.h" @@ -115,7 +115,7 @@ %include "Core/Background/IBackground.h" %include "Core/Background/ConstantBackground.h" -%include "Core/Background/PoissonNoiseBackground.h" +%include "Core/Background/PoissonBackground.h" %include "Core/Export/ExportToPython.h" diff --git a/hugo/static/files/python/fitting/ex02_AdvancedExamples/fit_along_slices.py b/hugo/static/files/python/fitting/ex02_AdvancedExamples/fit_along_slices.py index 29d734681f1..b2cbe0162eb 100644 --- a/hugo/static/files/python/fitting/ex02_AdvancedExamples/fit_along_slices.py +++ b/hugo/static/files/python/fitting/ex02_AdvancedExamples/fit_along_slices.py @@ -68,7 +68,7 @@ def create_real_data(): # retrieving simulated data in the form of numpy array simulation = get_simulation(params, add_masks=False) - simulation.setBackground(ba.PoissonNoiseBackground()) + simulation.setBackground(ba.PoissonBackground()) simulation.runSimulation() return simulation.result().array() -- GitLab