From 779bb601a9ec0dae51a33a6a54ebb3c53e8d4c05 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Wed, 25 Nov 2020 08:59:11 +0100 Subject: [PATCH] clang-format --- Core/Export/SampleToPython.cpp | 11 +++--- Core/Export/SimulationToPython.cpp | 37 +++++++++----------- Sample/Processed/MultiLayerFuncs.h | 2 +- Tests/Functional/Core/Std/Check.cpp | 4 +-- Tests/Functional/Python/PyEmbedded/Tests.cpp | 4 +-- 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp index d87d939b08e..ff4fda2b0ff 100644 --- a/Core/Export/SampleToPython.cpp +++ b/Core/Export/SampleToPython.cpp @@ -85,12 +85,11 @@ SampleToPython::SampleToPython() = default; SampleToPython::~SampleToPython() = default; std::string SampleToPython::defineGetSample() const { - return "def get_sample():\n" + defineMaterials() + defineLayers() - + defineFormFactors() + defineParticles() + defineCoreShellParticles() - + defineParticleCompositions() + defineLattices2D() + defineLattices3D() - + defineCrystals() + defineMesoCrystals() + defineParticleDistributions() - + defineInterferenceFunctions() + defineParticleLayouts() + defineRoughnesses() - + addLayoutsToLayers() + defineMultiLayers() + "\n\n"; + return "def get_sample():\n" + defineMaterials() + defineLayers() + defineFormFactors() + + defineParticles() + defineCoreShellParticles() + defineParticleCompositions() + + defineLattices2D() + defineLattices3D() + defineCrystals() + defineMesoCrystals() + + defineParticleDistributions() + defineInterferenceFunctions() + defineParticleLayouts() + + defineRoughnesses() + addLayoutsToLayers() + defineMultiLayers() + "\n\n"; } const std::map<MATERIAL_TYPES, std::string> factory_names{ diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index b3990f84f9d..fabd2e7ace3 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -55,12 +55,12 @@ bool isDefaultDirection(const kvector_t direction) { } 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"; + " sample = get_sample()\n" + " simulation = get_simulation()\n" + " simulation.setSample(sample)\n" + " simulation.runSimulation()\n" + " return simulation.result()\n" + "\n\n"; } // namespace @@ -156,8 +156,8 @@ std::string SimulationToPython::defineDetector(const ISimulation* simulation) co result << ")\n"; } else if (const auto* const det = dynamic_cast<const RectangularDetector*>(detector)) { result << "\n"; - result << indent() << "detector = ba.RectangularDetector(" << det->getNbinsX() - << ", " << pyfmt::printDouble(det->getWidth()) << ", " << det->getNbinsY() << ", " + result << indent() << "detector = ba.RectangularDetector(" << det->getNbinsX() << ", " + << pyfmt::printDouble(det->getWidth()) << ", " << det->getNbinsY() << ", " << pyfmt::printDouble(det->getHeight()) << ")\n"; if (det->getDetectorArrangment() == RectangularDetector::GENERIC) { result << indent() << "detector.setPosition(" @@ -260,9 +260,9 @@ std::string SimulationToPython::defineGISASBeam(const GISASSimulation& simulatio std::ostringstream result; const Beam& beam = simulation.instrument().beam(); - result << indent() << "simulation.setBeamParameters(" - << pyfmt::printNm(beam.getWavelength()) << ", " << pyfmt::printDegrees(beam.getAlpha()) - << ", " << pyfmt::printDegrees(beam.getPhi()) << ")\n"; + result << indent() << "simulation.setBeamParameters(" << pyfmt::printNm(beam.getWavelength()) + << ", " << pyfmt::printDegrees(beam.getAlpha()) << ", " + << pyfmt::printDegrees(beam.getPhi()) << ")\n"; result << defineBeamPolarization(beam); result << defineBeamIntensity(beam); @@ -277,8 +277,8 @@ std::string SimulationToPython::defineOffSpecBeam(const OffSpecSimulation& simul const std::string axidef = indent() + "alpha_i_axis = "; result << axidef << simulation.beamAxis()->pyString("rad", axidef.size()) << "\n"; - result << indent() << "simulation.setBeamParameters(" - << pyfmt::printNm(beam.getWavelength()) << ", " + result << indent() << "simulation.setBeamParameters(" << pyfmt::printNm(beam.getWavelength()) + << ", " << "alpha_i_axis, " << pyfmt::printDegrees(beam.getPhi()) << ")\n"; result << defineBeamPolarization(beam); @@ -309,8 +309,7 @@ std::string SimulationToPython::defineBeamPolarization(const Beam& beam) const { << pyfmt::printDouble(bloch_vector.x()) << ", " << pyfmt::printDouble(bloch_vector.y()) << ", " << pyfmt::printDouble(bloch_vector.z()) << ")\n"; - result << indent() << "simulation.setBeamPolarization(" << beam_polarization - << ")\n"; + result << indent() << "simulation.setBeamPolarization(" << beam_polarization << ")\n"; } return result.str(); } @@ -343,9 +342,8 @@ std::string SimulationToPython::defineParameterDistributions(const ISimulation* << pyfmt2::printDistribution(*distributions[i].getDistribution(), mainParUnits) << "\n"; - result << indent() << "simulation.addParameterDistribution(\"" << main_par_name - << "\", " << distr << ", " << nbr_samples << ", " - << pyfmt::printDouble(sigma_factor) + result << indent() << "simulation.addParameterDistribution(\"" << main_par_name << "\", " + << distr << ", " << nbr_samples << ", " << pyfmt::printDouble(sigma_factor) << pyfmt::printRealLimitsArg(distributions[i].getLimits(), mainParUnits) << ")\n"; } return result.str(); @@ -362,8 +360,7 @@ std::string SimulationToPython::defineMasks(const ISimulation* simulation) const for (size_t i_mask = 0; i_mask < detectorMask->numberOfMasks(); ++i_mask) { bool mask_value(false); const IShape2D* shape = detectorMask->getMaskShape(i_mask, mask_value); - result << pyfmt2::representShape2D(indent(), shape, mask_value, - printFunc(detector)); + result << pyfmt2::representShape2D(indent(), shape, mask_value, printFunc(detector)); } result << "\n"; } diff --git a/Sample/Processed/MultiLayerFuncs.h b/Sample/Processed/MultiLayerFuncs.h index 2581f6483dd..b21d06092c6 100644 --- a/Sample/Processed/MultiLayerFuncs.h +++ b/Sample/Processed/MultiLayerFuncs.h @@ -25,7 +25,7 @@ class MultiLayer; //! Calculate average material profile for given multilayer std::vector<complex_t> materialProfileSLD(const MultiLayer& multilayer, int n_points, double z_min, - double z_max); + double z_max); //! Get default z limits for generating a material profile std::pair<double, double> defaultMaterialProfileLimits(const MultiLayer& multilayer); diff --git a/Tests/Functional/Core/Std/Check.cpp b/Tests/Functional/Core/Std/Check.cpp index 0a8a056b840..5071c320efd 100644 --- a/Tests/Functional/Core/Std/Check.cpp +++ b/Tests/Functional/Core/Std/Check.cpp @@ -35,8 +35,8 @@ bool checkSimulation(const std::string& name, const ISimulation& direct_simulati // Load reference if available. ASSERT(name != ""); try { - const std::string refPath = FileSystemUtils::jointPath( - BATesting::ReferenceDir_Std(), name + ".int.gz"); + const std::string refPath = + FileSystemUtils::jointPath(BATesting::ReferenceDir_Std(), name + ".int.gz"); std::cout << "- reference: " << refPath << "\n"; reference.reset(IntensityDataIOFactory::readOutputData(refPath)); } catch (const std::exception&) { diff --git a/Tests/Functional/Python/PyEmbedded/Tests.cpp b/Tests/Functional/Python/PyEmbedded/Tests.cpp index 96923699561..978d3c8582c 100644 --- a/Tests/Functional/Python/PyEmbedded/Tests.cpp +++ b/Tests/Functional/Python/PyEmbedded/Tests.cpp @@ -367,8 +367,8 @@ TEST_F(PyEmbedded, ExportToPythonAndBack) { std::stringstream snippet; snippet << pyfmt::scriptPreamble() << code; - auto multilayer = PyImport::createFromPython(snippet.str(), "get_sample", - BABuild::buildLibDir()); + auto multilayer = + PyImport::createFromPython(snippet.str(), "get_sample", BABuild::buildLibDir()); auto new_code = ExportToPython::generateSampleCode(*multilayer); EXPECT_TRUE(code == new_code); -- GitLab