diff --git a/Core/PyIO/PyEmbeddedUtils.cpp b/Base/Utils/PyEmbeddedUtils.cpp similarity index 97% rename from Core/PyIO/PyEmbeddedUtils.cpp rename to Base/Utils/PyEmbeddedUtils.cpp index 2331dd58d842454462ccb4fd1e1c11f214d5a8da..1c7088d3f90a3523ad8b04f246aa553232686aa2 100644 --- a/Core/PyIO/PyEmbeddedUtils.cpp +++ b/Base/Utils/PyEmbeddedUtils.cpp @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file Core/PyIO/PyEmbeddedUtils.cpp +//! @file Base/Utils/PyEmbeddedUtils.cpp //! @brief IOmplements various functions from PyEmbeddedUtils namespace //! //! @homepage http://www.bornagainproject.org @@ -14,10 +14,9 @@ #ifdef BORNAGAIN_PYTHON -#include "Core/PyIO/PyEmbeddedUtils.h" +#include "Base/Utils/PyEmbeddedUtils.h" #include "Base/Utils/PythonCore.h" #include "Base/Utils/SysUtils.h" -#include "Core/PyIO/PythonFormatting.h" #include <iostream> #include <sstream> #include <stdexcept> diff --git a/Core/PyIO/PyEmbeddedUtils.h b/Base/Utils/PyEmbeddedUtils.h similarity index 97% rename from Core/PyIO/PyEmbeddedUtils.h rename to Base/Utils/PyEmbeddedUtils.h index c29778da8257f91fc8a8145ad059ab2861e81ea9..b612a0f27064a86d40fe92f23b081376edae33ad 100644 --- a/Core/PyIO/PyEmbeddedUtils.h +++ b/Base/Utils/PyEmbeddedUtils.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file Core/PyIO/PyEmbeddedUtils.h +//! @file Base/Utils/PyEmbeddedUtils.h //! @brief Defines PyEmbeddedUtils namespace //! //! @homepage http://www.bornagainproject.org diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp index 25753cd63e070d5b74ba46c76ae9c432e6c502a9..1953fe6423ec7d1c70a5b71e12b37ab972f738cb 100644 --- a/Core/Export/SampleToPython.cpp +++ b/Core/Export/SampleToPython.cpp @@ -32,7 +32,7 @@ #include "Core/Particle/ParticleComposition.h" #include "Core/Particle/ParticleCoreShell.h" #include "Core/Particle/ParticleDistribution.h" -#include "Core/PyIO/PythonFormatting.h" +#include "Core/Instrument/PyFmt2.h" #include "Core/Scattering/IFormFactor.h" #include <iomanip> #include <map> diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index 10b849408939c038ad4cf79648ed79e423ac2a74..588a1357bc15edcdcdcb80e889285cd09464e81d 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -29,7 +29,7 @@ #include "Core/Parametrization/ParameterUtils.h" #include "Base/Utils/PyFmt.h" #include "Core/Parametrization/PyFmtLimits.h" -#include "Core/PyIO/PythonFormatting.h" +#include "Core/Instrument/PyFmt2.h" #include "Core/Simulation/GISASSimulation.h" #include "Core/Simulation/OffSpecSimulation.h" #include "Core/Simulation/SpecularSimulation.h" diff --git a/Core/Instrument/AngularSpecScan.cpp b/Core/Instrument/AngularSpecScan.cpp index 52056f39fb7eb9a548a3a4f354122326d7949bec..5992cd3c801e16c19275b6af2e52221be9cec401 100644 --- a/Core/Instrument/AngularSpecScan.cpp +++ b/Core/Instrument/AngularSpecScan.cpp @@ -21,7 +21,7 @@ #include "Core/Parametrization/ParameterSample.h" #include "Base/Utils/PyFmt.h" #include "Core/Parametrization/RangedDistributions.h" -#include "Core/PyIO/PythonFormatting.h" +#include "Core/Instrument/PyFmt2.h" #include "Fit/Tools/RealLimits.h" namespace diff --git a/Core/PyIO/PythonFormatting.cpp b/Core/Instrument/PyFmt2.cpp similarity index 98% rename from Core/PyIO/PythonFormatting.cpp rename to Core/Instrument/PyFmt2.cpp index 978616d8e418ef1e25e450dc38f0f6e88f42ccac..cc631765fc8a96d69a6c03ecce85c4842f11c175 100644 --- a/Core/PyIO/PythonFormatting.cpp +++ b/Core/Instrument/PyFmt2.cpp @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file Core/PyIO/PythonFormatting.cpp +//! @file Core/Instrument/PyFmt2.cpp //! @brief Implements functions from namespace pyfmt2. //! //! @homepage http://www.bornagainproject.org @@ -12,7 +12,7 @@ // // ************************************************************************** // -#include "Core/PyIO/PythonFormatting.h" +#include "Core/Instrument/PyFmt2.h" #include "Base/Const/MathConstants.h" #include "Base/Const/Units.h" #include "Base/Utils/Algorithms.h" diff --git a/Core/PyIO/PythonFormatting.h b/Core/Instrument/PyFmt2.h similarity index 97% rename from Core/PyIO/PythonFormatting.h rename to Core/Instrument/PyFmt2.h index c0897c498f8ee0c42cfc225a385c5b484bf7ff16..857b125e7ff1f160e42e9d73f630c75617316b4f 100644 --- a/Core/PyIO/PythonFormatting.h +++ b/Core/Instrument/PyFmt2.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file Core/PyIO/PythonFormatting.h +//! @file Core/Instrument/PyFmt2.h //! @brief Defines namespace pyfmt2. //! //! @homepage http://www.bornagainproject.org diff --git a/Core/Instrument/QSpecScan.cpp b/Core/Instrument/QSpecScan.cpp index ef011cacfafa32816012ab9c9ba696afed1a14a8..916f2219fd57bb3a7a30f1daa912124ded28bba6 100644 --- a/Core/Instrument/QSpecScan.cpp +++ b/Core/Instrument/QSpecScan.cpp @@ -20,7 +20,7 @@ #include "Core/Parametrization/ParameterSample.h" #include "Base/Utils/PyFmt.h" #include "Core/Parametrization/RangedDistributions.h" -#include "Core/PyIO/PythonFormatting.h" +#include "Core/Instrument/PyFmt2.h" #include "Fit/Tools/RealLimits.h" namespace diff --git a/Core/PyIO/PyImport.cpp b/Core/Multilayer/PyImport.cpp similarity index 96% rename from Core/PyIO/PyImport.cpp rename to Core/Multilayer/PyImport.cpp index 32e7d9a941a10a1ec8c63329f5b374cc22ceb7c7..2732487f77094f7933d0b5288b40dd66326dc9fa 100644 --- a/Core/PyIO/PyImport.cpp +++ b/Core/Multilayer/PyImport.cpp @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file Core/PyIO/PyImport.cpp +//! @file Core/Multilayer/PyImport.cpp //! @brief Implements PyImport namespace //! //! @homepage http://www.bornagainproject.org @@ -14,10 +14,10 @@ #ifdef BORNAGAIN_PYTHON -#include "Core/PyIO/PyImport.h" +#include "Core/Multilayer/PyImport.h" #include "Base/Utils/PythonCore.h" #include "Core/Multilayer/MultiLayer.h" -#include "Core/PyIO/PyEmbeddedUtils.h" +#include "Base/Utils/PyEmbeddedUtils.h" namespace { diff --git a/Core/PyIO/PyImport.h b/Core/Multilayer/PyImport.h similarity index 97% rename from Core/PyIO/PyImport.h rename to Core/Multilayer/PyImport.h index a2222bddf9aa976768d320554fffa92ce5f5dedd..cb67d597ffc5f5cb81c9ae28a3a50303f44f02e4 100644 --- a/Core/PyIO/PyImport.h +++ b/Core/Multilayer/PyImport.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file Core/PyIO/PyImport.h +//! @file Core/Multilayer/PyImport.h //! @brief Defines PyImport namespace //! //! @homepage http://www.bornagainproject.org diff --git a/GUI/coregui/mainwindow/PyImportAssistant.cpp b/GUI/coregui/mainwindow/PyImportAssistant.cpp index eb17fd5c863f0d519596f9ebf8028b5eae26a09d..11202ece0f8f6f5bda3e3ea56e7afc829db36c96 100644 --- a/GUI/coregui/mainwindow/PyImportAssistant.cpp +++ b/GUI/coregui/mainwindow/PyImportAssistant.cpp @@ -18,7 +18,7 @@ #include "BABuild.h" #include "Base/Utils/SysUtils.h" #include "Core/Multilayer/MultiLayer.h" -#include "Core/PyIO/PyImport.h" +#include "Core/Multilayer/PyImport.h" #include "GUI/coregui/Models/GUIObjectBuilder.h" #include "GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.h" #include "GUI/coregui/Views/InfoWidgets/DetailedMessageBox.h" diff --git a/Tests/Functional/Python/PyEmbedded/Tests.cpp b/Tests/Functional/Python/PyEmbedded/Tests.cpp index 9e1af07a32fbc3f25132f0e15ad34d8ce7728656..5bab1394b377136c49697ddf6a79b1a699935bc9 100644 --- a/Tests/Functional/Python/PyEmbedded/Tests.cpp +++ b/Tests/Functional/Python/PyEmbedded/Tests.cpp @@ -18,8 +18,8 @@ #include "Core/Export/ExportToPython.h" #include "Core/Multilayer/MultiLayer.h" #include "Base/Utils/PyFmt.h" -#include "Core/PyIO/PyEmbeddedUtils.h" -#include "Core/PyIO/PyImport.h" +#include "Base/Utils/PyEmbeddedUtils.h" +#include "Core/Multilayer/PyImport.h" #include "Core/StandardSamples/SampleBuilderFactory.h" #include "Tests/GTestWrapper/google_test.h" #include <iostream> diff --git a/Tests/UnitTests/Core/ExportToPython/PythonFormattingTest.cpp b/Tests/UnitTests/Core/ExportToPython/PythonFormattingTest.cpp index 432e402007ac9da76ed51d4826339b7677a45332..86974d806714b4037214eee99b30fe45243b37b5 100644 --- a/Tests/UnitTests/Core/ExportToPython/PythonFormattingTest.cpp +++ b/Tests/UnitTests/Core/ExportToPython/PythonFormattingTest.cpp @@ -1,4 +1,4 @@ -#include "Core/PyIO/PythonFormatting.h" +#include "Core/Instrument/PyFmt2.h" #include "Base/Const/Units.h" #include "Core/Axis/FixedBinAxis.h" #include "Core/Axis/PointwiseAxis.h" diff --git a/auto/Wrap/doxygenBase.i b/auto/Wrap/doxygenBase.i index 08dab96b0283d23078573f8a8e6aed957de0d2b6..a2d83ce0c03e9ff74a45321e21988443ca33e636 100644 --- a/auto/Wrap/doxygenBase.i +++ b/auto/Wrap/doxygenBase.i @@ -834,6 +834,41 @@ convolution of two real vectors of equal size "; +// File: namespacePyEmbeddedUtils.xml +%feature("docstring") PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(PyObject *obj) + +Converts PyObject into string, if possible, or throws exception. +"; + +%feature("docstring") PyEmbeddedUtils::toVectorString "std::vector< std::string > PyEmbeddedUtils::toVectorString(PyObject *obj) + +Converts PyObject into vector of strings, if possible, or throws exception. +"; + +%feature("docstring") PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(char *c) + +Converts char to string. In the case of nullptr will return an empty string. +"; + +%feature("docstring") PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(wchar_t *c) +"; + +%feature("docstring") PyEmbeddedUtils::import_bornagain "void PyEmbeddedUtils::import_bornagain(const std::string &path=\"\") + +Imports BornAgain from given location. If path is empty, tries to rely on PYTHONPATH. +"; + +%feature("docstring") PyEmbeddedUtils::pythonRuntimeInfo "std::string PyEmbeddedUtils::pythonRuntimeInfo() + +Returns multi-line string representing PATH, PYTHONPATH, sys.path and other info. +"; + +%feature("docstring") PyEmbeddedUtils::pythonStackTrace "std::string PyEmbeddedUtils::pythonStackTrace() + +Returns string representing python stack trace. +"; + + // File: namespacepyfmt.xml %feature("docstring") pyfmt::scriptPreamble "std::string pyfmt::scriptPreamble() "; @@ -883,6 +918,36 @@ Returns a string of blanks with given width. By default the width equals standar "; +// File: namespacepyfmt2.xml +%feature("docstring") pyfmt2::representShape2D "std::string pyfmt2::representShape2D(const std::string &indent, const IShape2D *ishape, bool mask_value, std::function< std::string(double)> printValueFunc) + +Returns fixed Python code snippet that defines the function \"runSimulation\". +"; + +%feature("docstring") pyfmt2::valueTimesUnit "std::string pyfmt2::valueTimesUnit(const RealParameter *par) + +Returns parameter value, followed by its unit multiplicator (like \"* nm\"). +"; + +%feature("docstring") pyfmt2::argumentList "std::string pyfmt2::argumentList(const IParameterized *ip) + +Returns comma-separated list of parameter values, including unit multiplicator (like \"* nm\"). +"; + +%feature("docstring") pyfmt2::printDistribution "std::string pyfmt2::printDistribution(const IDistribution1D &par_distr, const std::string &units) + +Prints distribution with constructor parameters in given units. ba.DistributionGaussian(2.0*deg, 0.02*deg) +"; + +%feature("docstring") pyfmt2::printParameterDistribution "std::string pyfmt2::printParameterDistribution(const ParameterDistribution &par_distr, const std::string &distVarName, const std::string &units) +"; + +%feature("docstring") pyfmt2::printAxis "std::string pyfmt2::printAxis(const IAxis &axis, const std::string &units, size_t offset) + +Prints python-script definition for given axis. offset is used for alignment and indentation in multiple-line definitions +"; + + // File: namespaceSysUtils.xml %feature("docstring") SysUtils::getCurrentDateAndTime "std::string SysUtils::getCurrentDateAndTime() "; @@ -983,12 +1048,24 @@ Template function to create an integrator object // File: Precomputed_8h.xml +// File: PyEmbeddedUtils_8cpp.xml + + +// File: PyEmbeddedUtils_8h.xml + + // File: PyFmt_8cpp.xml // File: PyFmt_8h.xml +// File: PyFmt2_8cpp.xml + + +// File: PyFmt2_8h.xml + + // File: PyObject_8h.xml diff --git a/auto/Wrap/doxygenCore.i b/auto/Wrap/doxygenCore.i index 59d2b287fef2edd5b4c73ff23aa3fda3c5ee07a9..d83811fc3c157492ff768d02df63d13e5c703c7a 100644 --- a/auto/Wrap/doxygenCore.i +++ b/auto/Wrap/doxygenCore.i @@ -16021,10 +16021,7 @@ C++ includes: ZLimits.h // File: namespace_0d270.xml -// File: namespace_0d284.xml - - -// File: namespace_0d315.xml +// File: namespace_0d286.xml // File: namespace_0d317.xml @@ -16033,34 +16030,34 @@ C++ includes: ZLimits.h // File: namespace_0d319.xml -// File: namespace_0d341.xml +// File: namespace_0d321.xml -// File: namespace_0d345.xml +// File: namespace_0d343.xml -// File: namespace_0d349.xml +// File: namespace_0d347.xml -// File: namespace_0d365.xml +// File: namespace_0d351.xml -// File: namespace_0d374.xml +// File: namespace_0d367.xml -// File: namespace_0d378.xml +// File: namespace_0d376.xml -// File: namespace_0d388.xml +// File: namespace_0d380.xml // File: namespace_0d390.xml -// File: namespace_0d396.xml +// File: namespace_0d392.xml -// File: namespace_0d398.xml +// File: namespace_0d394.xml // File: namespace_0d4.xml @@ -16078,70 +16075,73 @@ C++ includes: ZLimits.h // File: namespace_0d406.xml +// File: namespace_0d408.xml + + // File: namespace_0d410.xml -// File: namespace_0d412.xml +// File: namespace_0d414.xml -// File: namespace_0d422.xml +// File: namespace_0d416.xml -// File: namespace_0d435.xml +// File: namespace_0d426.xml -// File: namespace_0d444.xml +// File: namespace_0d439.xml -// File: namespace_0d450.xml +// File: namespace_0d448.xml -// File: namespace_0d466.xml +// File: namespace_0d452.xml -// File: namespace_0d492.xml +// File: namespace_0d468.xml -// File: namespace_0d499.xml +// File: namespace_0d495.xml -// File: namespace_0d501.xml +// File: namespace_0d497.xml -// File: namespace_0d509.xml +// File: namespace_0d505.xml -// File: namespace_0d521.xml +// File: namespace_0d517.xml -// File: namespace_0d544.xml +// File: namespace_0d540.xml -// File: namespace_0d552.xml +// File: namespace_0d548.xml -// File: namespace_0d558.xml +// File: namespace_0d554.xml -// File: namespace_0d560.xml +// File: namespace_0d556.xml -// File: namespace_0d571.xml +// File: namespace_0d567.xml -// File: namespace_0d583.xml +// File: namespace_0d579.xml -// File: namespace_0d589.xml +// File: namespace_0d585.xml -// File: namespace_0d593.xml +// File: namespace_0d589.xml -// File: namespace_0d611.xml +// File: namespace_0d607.xml -// File: namespace_0d630.xml +// File: namespace_0d626.xml // File: namespace_0d78.xml @@ -16560,72 +16560,7 @@ for importing 2D array of doubles from python into OutputData "; -// File: namespacePyEmbeddedUtils.xml -%feature("docstring") PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(PyObject *obj) - -Converts PyObject into string, if possible, or throws exception. -"; - -%feature("docstring") PyEmbeddedUtils::toVectorString "std::vector< std::string > PyEmbeddedUtils::toVectorString(PyObject *obj) - -Converts PyObject into vector of strings, if possible, or throws exception. -"; - -%feature("docstring") PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(char *c) - -Converts char to string. In the case of nullptr will return an empty string. -"; - -%feature("docstring") PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(wchar_t *c) -"; - -%feature("docstring") PyEmbeddedUtils::import_bornagain "void PyEmbeddedUtils::import_bornagain(const std::string &path=\"\") - -Imports BornAgain from given location. If path is empty, tries to rely on PYTHONPATH. -"; - -%feature("docstring") PyEmbeddedUtils::pythonRuntimeInfo "std::string PyEmbeddedUtils::pythonRuntimeInfo() - -Returns multi-line string representing PATH, PYTHONPATH, sys.path and other info. -"; - -%feature("docstring") PyEmbeddedUtils::pythonStackTrace "std::string PyEmbeddedUtils::pythonStackTrace() - -Returns string representing python stack trace. -"; - - // File: namespacepyfmt.xml -%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) -"; - -%feature("docstring") pyfmt::printDouble "std::string pyfmt::printDouble(double input) -"; - -%feature("docstring") pyfmt::printNm "std::string pyfmt::printNm(double input) -"; - -%feature("docstring") pyfmt::printNm2 "std::string pyfmt::printNm2(double input) -"; - -%feature("docstring") pyfmt::printScientificDouble "std::string pyfmt::printScientificDouble(double input) -"; - -%feature("docstring") pyfmt::printDegrees "std::string pyfmt::printDegrees(double input) -"; - -%feature("docstring") pyfmt::printValue "std::string pyfmt::printValue(double value, const std::string &units) -"; - -%feature("docstring") pyfmt::printString "std::string pyfmt::printString(const std::string &value) -"; - %feature("docstring") pyfmt::printRealLimits "std::string pyfmt::printRealLimits(const RealLimits &limits, const std::string &units) "; @@ -16634,27 +16569,6 @@ Returns string representing python stack trace. Prints RealLimits in the form of argument (in the context of ParameterDistribution and similar). Default RealLimits will not be printed, any other will be printed as \", ba.RealLimits.limited(1*deg, 2*deg)\" "; -%feature("docstring") pyfmt::isSquare "bool pyfmt::isSquare(double length1, double length2, double angle) - -Prints ParameterDistribution. distVarName is a string representing IDistribution1D variable, e.g. \"distr_1\" - -ba.ParameterDistribution(\"/Particle/Height\", distr_1, 10, 0.0, ba.RealLimits.limited(1*nm,2*nm)) -"; - -%feature("docstring") pyfmt::isHexagonal "bool pyfmt::isHexagonal(double length1, double length2, double angle) -"; - -%feature("docstring") pyfmt::printKvector "std::string pyfmt::printKvector(const kvector_t value) -"; - -%feature("docstring") pyfmt::indent "std::string pyfmt::indent(size_t width) - -Returns a string of blanks with given width. By default the width equals standard offset in python files. -"; - -%feature("docstring") pyfmt::printInt "std::string pyfmt::printInt(int value) -"; - // File: namespacepyfmt2.xml %feature("docstring") pyfmt2::representShape2D "std::string pyfmt2::representShape2D(const std::string &indent, const IShape2D *ishape, bool mask_value, std::function< std::string(double)> printValueFunc) @@ -17852,6 +17766,12 @@ Generate z values (equidistant) for use in MaterialProfile. // File: PyArrayImportUtils_8h.xml +// File: PyFmt2_8cpp.xml + + +// File: PyFmt2_8h.xml + + // File: QSpecScan_8cpp.xml @@ -18244,6 +18164,12 @@ magnetization (in A/m) // File: MultiLayerUtils_8h.xml +// File: PyImport_8cpp.xml + + +// File: PyImport_8h.xml + + // File: RoughnessModels_8cpp.xml @@ -18426,12 +18352,6 @@ magnetization (in A/m) // File: ParameterUtils_8h.xml -// File: PyFmt_8cpp.xml - - -// File: PyFmt_8h.xml - - // File: PyFmtLimits_8cpp.xml @@ -18566,24 +18486,6 @@ Creates averaged material. Square refractive index of returned material is arith // File: SimulationElement_8h.xml -// File: PyEmbeddedUtils_8cpp.xml - - -// File: PyEmbeddedUtils_8h.xml - - -// File: PyImport_8cpp.xml - - -// File: PyImport_8h.xml - - -// File: PythonFormatting_8cpp.xml - - -// File: PythonFormatting_8h.xml - - // File: ILayerRTCoefficients_8h.xml @@ -19134,9 +19036,6 @@ Generate vertices of centered ellipse with given semi-axes at height z. // File: dir_359af669373d7705e93988ea0fa15f60.xml -// File: dir_437a42df1810106c8392af0ca05a14b2.xml - - // File: dir_8e60847f0ac26e3d8a13e8a06357123f.xml