diff --git a/Base/Utils/PyFmt.cpp b/Base/Utils/PyFmt.cpp index 3305797a1ce4bd0a14b86e2f9b1307b073364205..32afe9740ae7a2de7b5196bc1ac0f08438037e37 100644 --- a/Base/Utils/PyFmt.cpp +++ b/Base/Utils/PyFmt.cpp @@ -28,10 +28,6 @@ std::string scriptPreamble() { return result; } -std::string getSampleFunctionName() { - return "get_sample"; -} - std::string printBool(double value) { return value ? "True" : "False"; } diff --git a/Base/Utils/PyFmt.h b/Base/Utils/PyFmt.h index 5dc8f17e09e1b8d3c4fdd857d8f763005f262d04..ffa4069bd19aa3baa544c9a7b80671f846cf05a0 100644 --- a/Base/Utils/PyFmt.h +++ b/Base/Utils/PyFmt.h @@ -25,7 +25,6 @@ class RealLimits; namespace pyfmt { std::string scriptPreamble(); -std::string getSampleFunctionName(); std::string printInt(int value); std::string printBool(double value); diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp index 4dd93ef4ad02dfa4e643cf71a61881631e7f11c6..d87d939b08e54442ccac110b352e932f79de23ae 100644 --- a/Core/Export/SampleToPython.cpp +++ b/Core/Export/SampleToPython.cpp @@ -85,7 +85,7 @@ SampleToPython::SampleToPython() = default; SampleToPython::~SampleToPython() = default; std::string SampleToPython::defineGetSample() const { - return "def " + pyfmt::getSampleFunctionName() + "():\n" + defineMaterials() + defineLayers() + return "def get_sample():\n" + defineMaterials() + defineLayers() + defineFormFactors() + defineParticles() + defineCoreShellParticles() + defineParticleCompositions() + defineLattices2D() + defineLattices3D() + defineCrystals() + defineMesoCrystals() + defineParticleDistributions() diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index 21faf8c194f855a088483d347575abf698d8a295..b3990f84f9df5db03895436a19c9782457550a29 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -38,16 +38,6 @@ using pyfmt::indent; namespace { -const std::string defineSimulate = "def run_simulation():\n" - " sample = " - + pyfmt::getSampleFunctionName() - + "()\n" - " simulation = get_simulation()\n" - " simulation.setSample(sample)\n" - " simulation.runSimulation()\n" - " return simulation.result()\n" - "\n\n"; - //! Returns a function that converts a coordinate to a Python code snippet with appropiate unit std::function<std::string(double)> printFunc(const IDetector* detector) { if (detector->defaultAxesUnits() == Axes::Units::MM) @@ -64,6 +54,14 @@ bool isDefaultDirection(const kvector_t direction) { && algo::almostEqual(direction.z(), 0.0); } +const std::string defineSimulate = "def run_simulation():\n" + " sample = get_sample()\n" + " simulation = get_simulation()\n" + " simulation.setSample(sample)\n" + " simulation.runSimulation()\n" + " return simulation.result()\n" + "\n\n"; + } // namespace //! Returns a Python script that sets up a simulation and runs it if invoked as main program. diff --git a/Tests/Functional/Python/PyEmbedded/Tests.cpp b/Tests/Functional/Python/PyEmbedded/Tests.cpp index 2ce7b659551ef829e6bb8b3a9f9d7ceaf5ab248a..9692369956155ab0393437b71bfab11fefa96d2a 100644 --- a/Tests/Functional/Python/PyEmbedded/Tests.cpp +++ b/Tests/Functional/Python/PyEmbedded/Tests.cpp @@ -367,7 +367,7 @@ TEST_F(PyEmbedded, ExportToPythonAndBack) { std::stringstream snippet; snippet << pyfmt::scriptPreamble() << code; - auto multilayer = PyImport::createFromPython(snippet.str(), pyfmt::getSampleFunctionName(), + auto multilayer = PyImport::createFromPython(snippet.str(), "get_sample", BABuild::buildLibDir()); auto new_code = ExportToPython::generateSampleCode(*multilayer); @@ -375,7 +375,7 @@ TEST_F(PyEmbedded, ExportToPythonAndBack) { } //! Retrieves list of functions from the imported script and checks, that there is -//! one function in a dictioonary with name "get_simulation". +//! one function in a dictionary with name "get_simulation". TEST_F(PyEmbedded, ModuleFunctionsList) { // compile our function diff --git a/auto/Wrap/doxygenBase.i b/auto/Wrap/doxygenBase.i index e7af05b5a5dc508e8ea370bb7f1d0295f5bc17c7..08b65977e12d4c8eac1908f9fc298706ab3812ba 100644 --- a/auto/Wrap/doxygenBase.i +++ b/auto/Wrap/doxygenBase.i @@ -1219,7 +1219,7 @@ Creates a new clipped axis. "; -// File: namespace_0D16.xml +// File: namespace_0d16.xml // File: namespacealgo.xml @@ -1461,9 +1461,6 @@ Returns string representing python stack trace. %feature("docstring") pyfmt::scriptPreamble "std::string pyfmt::scriptPreamble() "; -%feature("docstring") pyfmt::getSampleFunctionName "std::string pyfmt::getSampleFunctionName() -"; - %feature("docstring") pyfmt::printBool "std::string pyfmt::printBool(double value) ";