BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
Utility functions for writing Python code snippets.
Functions | |
std::string | indent (size_t width=4u) |
Returns a string of blanks with given width. By default the width equals standard offset in python files. More... | |
bool | isHexagonal (double length1, double length2, double angle) |
bool | isSquare (double length1, double length2, double angle) |
std::string | printArguments (const std::vector< std::pair< double, std::string >> &arguments) |
Takes pairs of value/unit and concatenates them for an argument list. Each pair's content will be processed by printValue(), so the meaning of the content is the same as in printValue(). More... | |
std::string | printArguments (const std::vector< std::pair< std::variant< double, int >, std::string >> &arguments) |
Convenience overload for printing arguments containing a mixture of int and double. More... | |
std::string | printBool (double value) |
std::string | printDegrees (double input) |
std::string | printDouble (double input) |
std::string | printFunction (const std::string &name, const std::vector< std::pair< double, std::string >> &arguments) |
Print a function in the form "<name>(<arguments>)". arguments will be processed by printArguments(), see there for details. More... | |
std::string | printFunction (const std::string &name, double value, const std::string &unit) |
Convenience overload for printing a function with one argument. More... | |
std::string | printFunction (const std::string &name, double value1, const std::string &unit1, double value2, const std::string &unit2) |
Convenience overload for printing a function with two arguments. More... | |
std::string | printImportedSymbols (const std::string &code) |
std::string | printInt (int value) |
std::string | printKvector (const R3 value) |
std::string | printLightDouble (double input) |
prints double as an integer, if possible within standard accuracy More... | |
std::string | printNm (double input) |
std::string | printNm2 (double input) |
std::string | printRealLimits (const RealLimits &limits, const std::string &units) |
std::string | printRealLimitsArg (const RealLimits &limits, const std::string &units) |
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)". More... | |
std::string | printScientificDouble (double input) |
std::string | printString (const std::string &value) |
std::string | printValue (double value, const std::string &units) |
std::string | printValue (std::variant< double, int > value, const std::string &units) |
std::string Py::Fmt::indent | ( | size_t | width | ) |
Returns a string of blanks with given width. By default the width equals standard offset in python files.
Definition at line 203 of file PyFmt.cpp.
Referenced by SampleToPython::defineCoreShellParticles(), SampleToPython::defineCrystals(), SampleToPython::defineFormFactors(), SampleToPython::defineInterferences(), SampleToPython::defineLattices2D(), SampleToPython::defineLattices3D(), SampleToPython::defineLayers(), SampleToPython::defineMaterials(), SampleToPython::defineMesoCrystals(), SampleToPython::defineMultiLayers(), SampleToPython::defineParticleCompositions(), SampleToPython::defineParticleLayouts(), SampleToPython::defineParticles(), SampleToPython::defineRoughnesses(), Py::Fmt2::printRangedDistribution(), and Py::Fmt2::representShape2D().
bool Py::Fmt::isHexagonal | ( | double | length1, |
double | length2, | ||
double | angle | ||
) |
Definition at line 190 of file PyFmt.cpp.
References BaseUtils::algo::almostEqual(), and M_TWOPI.
bool Py::Fmt::isSquare | ( | double | length1, |
double | length2, | ||
double | angle | ||
) |
Definition at line 185 of file PyFmt.cpp.
References BaseUtils::algo::almostEqual(), and M_PI_2.
std::string Py::Fmt::printArguments | ( | const std::vector< std::pair< double, std::string >> & | arguments | ) |
Takes pairs of value/unit and concatenates them for an argument list. Each pair's content will be processed by printValue(), so the meaning of the content is the same as in printValue().
Definition at line 151 of file PyFmt.cpp.
References BaseUtils::String::join(), and printValue().
Referenced by printFunction().
std::string Py::Fmt::printArguments | ( | const std::vector< std::pair< std::variant< double, int >, std::string >> & | arguments | ) |
Convenience overload for printing arguments containing a mixture of int and double.
Definition at line 160 of file PyFmt.cpp.
References BaseUtils::String::join(), and printValue().
std::string Py::Fmt::printBool | ( | double | value | ) |
Definition at line 41 of file PyFmt.cpp.
Referenced by Py::Fmt2::representShape2D().
std::string Py::Fmt::printDegrees | ( | double | input | ) |
Definition at line 116 of file PyFmt.cpp.
References printLightDouble(), and Units::rad2deg().
Referenced by SampleToPython::defineInterferences(), SampleToPython::defineLattices2D(), printValue(), and Py::Fmt2::representShape2D().
std::string Py::Fmt::printDouble | ( | double | input | ) |
Definition at line 46 of file PyFmt.cpp.
Referenced by SampleToPython::defineInterferences(), SampleToPython::defineMaterials(), SampleToPython::defineParticleLayouts(), printKvector(), Py::Fmt2::printParameterDistribution(), Py::Fmt2::printRangedDistribution(), and printValue().
std::string Py::Fmt::printFunction | ( | const std::string & | name, |
const std::vector< std::pair< double, std::string >> & | arguments | ||
) |
Print a function in the form "<name>(<arguments>)". arguments will be processed by printArguments(), see there for details.
Definition at line 168 of file PyFmt.cpp.
References printArguments().
Referenced by printFunction(), IProfile1D::pythonConstructor(), IProfile2D::pythonConstructor(), LayerRoughness::pythonConstructor(), IFormFactor::pythonConstructor(), Profile1DVoigt::pythonConstructor(), Profile2DVoigt::pythonConstructor(), DistributionGate::pythonConstructor(), DistributionLorentz::pythonConstructor(), DistributionGaussian::pythonConstructor(), DistributionLogNormal::pythonConstructor(), DistributionCosine::pythonConstructor(), and DistributionTrapezoid::pythonConstructor().
std::string Py::Fmt::printFunction | ( | const std::string & | name, |
double | value, | ||
const std::string & | unit | ||
) |
Convenience overload for printing a function with one argument.
Definition at line 174 of file PyFmt.cpp.
References printFunction().
std::string Py::Fmt::printFunction | ( | const std::string & | name, |
double | value1, | ||
const std::string & | unit1, | ||
double | value2, | ||
const std::string & | unit2 | ||
) |
Convenience overload for printing a function with two arguments.
Definition at line 179 of file PyFmt.cpp.
References printFunction().
std::string Py::Fmt::printImportedSymbols | ( | const std::string & | code | ) |
Definition at line 24 of file PyFmt.cpp.
References BaseUtils::String::join().
std::string Py::Fmt::printInt | ( | int | value | ) |
Definition at line 36 of file PyFmt.cpp.
Referenced by printValue().
std::string Py::Fmt::printKvector | ( | const R3 | value | ) |
Definition at line 195 of file PyFmt.cpp.
References printDouble().
std::string Py::Fmt::printLightDouble | ( | double | input | ) |
prints double as an integer, if possible within standard accuracy
Definition at line 61 of file PyFmt.cpp.
Referenced by printDegrees(), printNm(), and printNm2().
std::string Py::Fmt::printNm | ( | double | input | ) |
Definition at line 79 of file PyFmt.cpp.
References printLightDouble().
Referenced by SampleToPython::defineInterferences(), SampleToPython::defineLattices2D(), SampleToPython::defineLattices3D(), SampleToPython::defineLayers(), and printValue().
std::string Py::Fmt::printNm2 | ( | double | input | ) |
Definition at line 87 of file PyFmt.cpp.
References printLightDouble().
Referenced by SampleToPython::defineInterferences().
std::string Py::Fmt::printRealLimits | ( | const RealLimits & | limits, |
const std::string & | units | ||
) |
Definition at line 22 of file PyFmtLimits.cpp.
References RealLimits::isLimited(), RealLimits::isLimitless(), RealLimits::isLowerLimited(), RealLimits::isNonnegative(), RealLimits::isPositive(), RealLimits::isUpperLimited(), RealLimits::lowerLimit(), printValue(), and RealLimits::upperLimit().
Referenced by printRealLimitsArg().
std::string Py::Fmt::printRealLimitsArg | ( | const RealLimits & | limits, |
const std::string & | units | ||
) |
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)".
Definition at line 59 of file PyFmtLimits.cpp.
References RealLimits::isLimitless(), and printRealLimits().
Referenced by Py::Fmt2::printParameterDistribution(), and Py::Fmt2::printRangedDistribution().
std::string Py::Fmt::printScientificDouble | ( | double | input | ) |
Definition at line 96 of file PyFmt.cpp.
References BaseUtils::String::scientific().
Referenced by SampleToPython::defineMultiLayers().
std::string Py::Fmt::printString | ( | const std::string & | value | ) |
std::string Py::Fmt::printValue | ( | double | value, |
const std::string & | units | ||
) |
Definition at line 123 of file PyFmt.cpp.
References ASSERT, printDegrees(), printDouble(), and printNm().
Referenced by printArguments(), Py::Fmt2::printAxis(), printRealLimits(), and printValue().
std::string Py::Fmt::printValue | ( | std::variant< double, int > | value, |
const std::string & | units | ||
) |
Definition at line 134 of file PyFmt.cpp.
References ASSERT, printInt(), and printValue().