modelparameters package¶
Subpackages¶
- modelparameters.sympy package
- Subpackages
- modelparameters.sympy.assumptions package
- Subpackages
- Submodules
- modelparameters.sympy.assumptions.ask module
- modelparameters.sympy.assumptions.ask_generated module
- modelparameters.sympy.assumptions.assume module
- modelparameters.sympy.assumptions.refine module
- modelparameters.sympy.assumptions.satask module
- modelparameters.sympy.assumptions.sathandlers module
- Module contents
- modelparameters.sympy.calculus package
- modelparameters.sympy.categories package
- modelparameters.sympy.codegen package
- modelparameters.sympy.combinatorics package
- Submodules
- modelparameters.sympy.combinatorics.fp_groups module
- modelparameters.sympy.combinatorics.free_groups module
- modelparameters.sympy.combinatorics.generators module
- modelparameters.sympy.combinatorics.graycode module
- modelparameters.sympy.combinatorics.group_constructs module
- modelparameters.sympy.combinatorics.named_groups module
- modelparameters.sympy.combinatorics.partitions module
- modelparameters.sympy.combinatorics.perm_groups module
- modelparameters.sympy.combinatorics.permutations module
- modelparameters.sympy.combinatorics.polyhedron module
- modelparameters.sympy.combinatorics.prufer module
- modelparameters.sympy.combinatorics.subsets module
- modelparameters.sympy.combinatorics.tensor_can module
- modelparameters.sympy.combinatorics.testutil module
- modelparameters.sympy.combinatorics.util module
- Module contents
- modelparameters.sympy.concrete package
- Submodules
- modelparameters.sympy.concrete.delta module
- modelparameters.sympy.concrete.expr_with_intlimits module
- modelparameters.sympy.concrete.expr_with_limits module
- modelparameters.sympy.concrete.gosper module
- modelparameters.sympy.concrete.guess module
- modelparameters.sympy.concrete.products module
- modelparameters.sympy.concrete.summations module
- Module contents
- modelparameters.sympy.core package
- Submodules
- modelparameters.sympy.core.add module
- modelparameters.sympy.core.alphabets module
- modelparameters.sympy.core.assumptions module
- modelparameters.sympy.core.backend module
- modelparameters.sympy.core.basic module
- modelparameters.sympy.core.cache module
- modelparameters.sympy.core.compatibility module
- modelparameters.sympy.core.containers module
- modelparameters.sympy.core.core module
- modelparameters.sympy.core.coreerrors module
- modelparameters.sympy.core.decorators module
- modelparameters.sympy.core.evalf module
- modelparameters.sympy.core.evaluate module
- modelparameters.sympy.core.expr module
- modelparameters.sympy.core.exprtools module
- modelparameters.sympy.core.facts module
- modelparameters.sympy.core.function module
- modelparameters.sympy.core.logic module
- modelparameters.sympy.core.mod module
- modelparameters.sympy.core.mul module
- modelparameters.sympy.core.multidimensional module
- modelparameters.sympy.core.numbers module
- modelparameters.sympy.core.operations module
- modelparameters.sympy.core.power module
- modelparameters.sympy.core.relational module
- modelparameters.sympy.core.rules module
- modelparameters.sympy.core.singleton module
- modelparameters.sympy.core.symbol module
- modelparameters.sympy.core.sympify module
- modelparameters.sympy.core.trace module
- Module contents
- modelparameters.sympy.crypto package
- modelparameters.sympy.deprecated package
- modelparameters.sympy.diffgeom package
- modelparameters.sympy.external package
- modelparameters.sympy.functions package
- modelparameters.sympy.geometry package
- Submodules
- modelparameters.sympy.geometry.curve module
- modelparameters.sympy.geometry.ellipse module
- modelparameters.sympy.geometry.entity module
- modelparameters.sympy.geometry.exceptions module
- modelparameters.sympy.geometry.line module
- modelparameters.sympy.geometry.parabola module
- modelparameters.sympy.geometry.plane module
- modelparameters.sympy.geometry.point module
- modelparameters.sympy.geometry.polygon module
- modelparameters.sympy.geometry.util module
- Module contents
- modelparameters.sympy.holonomic package
- modelparameters.sympy.integrals package
- Submodules
- modelparameters.sympy.integrals.deltafunctions module
- modelparameters.sympy.integrals.heurisch module
- modelparameters.sympy.integrals.integrals module
- modelparameters.sympy.integrals.manualintegrate module
- modelparameters.sympy.integrals.meijerint module
- modelparameters.sympy.integrals.meijerint_doc module
- modelparameters.sympy.integrals.prde module
- modelparameters.sympy.integrals.quadrature module
- modelparameters.sympy.integrals.rationaltools module
- modelparameters.sympy.integrals.rde module
- modelparameters.sympy.integrals.risch module
- modelparameters.sympy.integrals.singularityfunctions module
- modelparameters.sympy.integrals.transforms module
- modelparameters.sympy.integrals.trigonometry module
- Module contents
- modelparameters.sympy.interactive package
- modelparameters.sympy.liealgebras package
- Submodules
- modelparameters.sympy.liealgebras.cartan_matrix module
- modelparameters.sympy.liealgebras.cartan_type module
- modelparameters.sympy.liealgebras.dynkin_diagram module
- modelparameters.sympy.liealgebras.root_system module
- modelparameters.sympy.liealgebras.type_a module
- modelparameters.sympy.liealgebras.type_b module
- modelparameters.sympy.liealgebras.type_c module
- modelparameters.sympy.liealgebras.type_d module
- modelparameters.sympy.liealgebras.type_e module
- modelparameters.sympy.liealgebras.type_f module
- modelparameters.sympy.liealgebras.type_g module
- modelparameters.sympy.liealgebras.weyl_group module
- Module contents
- modelparameters.sympy.logic package
- modelparameters.sympy.matrices package
- Subpackages
- Submodules
- modelparameters.sympy.matrices.common module
- modelparameters.sympy.matrices.dense module
- modelparameters.sympy.matrices.densearith module
- modelparameters.sympy.matrices.densesolve module
- modelparameters.sympy.matrices.densetools module
- modelparameters.sympy.matrices.immutable module
- modelparameters.sympy.matrices.matrices module
- modelparameters.sympy.matrices.normalforms module
- modelparameters.sympy.matrices.sparse module
- modelparameters.sympy.matrices.sparsetools module
- Module contents
- modelparameters.sympy.ntheory package
- Submodules
- modelparameters.sympy.ntheory.bbp_pi module
- modelparameters.sympy.ntheory.continued_fraction module
- modelparameters.sympy.ntheory.egyptian_fraction module
- modelparameters.sympy.ntheory.factor_ module
- modelparameters.sympy.ntheory.generate module
- modelparameters.sympy.ntheory.modular module
- modelparameters.sympy.ntheory.multinomial module
- modelparameters.sympy.ntheory.partitions_ module
- modelparameters.sympy.ntheory.primetest module
- modelparameters.sympy.ntheory.residue_ntheory module
- Module contents
- modelparameters.sympy.parsing package
- modelparameters.sympy.physics package
- Subpackages
- Submodules
- modelparameters.sympy.physics.gaussopt module
- modelparameters.sympy.physics.hydrogen module
- modelparameters.sympy.physics.matrices module
- modelparameters.sympy.physics.paulialgebra module
- modelparameters.sympy.physics.pring module
- modelparameters.sympy.physics.qho_1d module
- modelparameters.sympy.physics.secondquant module
- modelparameters.sympy.physics.sho module
- modelparameters.sympy.physics.unitsystems module
- modelparameters.sympy.physics.wigner module
- Module contents
- modelparameters.sympy.plotting package
- modelparameters.sympy.polys package
- Subpackages
- Submodules
- modelparameters.sympy.polys.compatibility module
- modelparameters.sympy.polys.constructor module
- modelparameters.sympy.polys.densearith module
- modelparameters.sympy.polys.densebasic module
- modelparameters.sympy.polys.densetools module
- modelparameters.sympy.polys.dispersion module
- modelparameters.sympy.polys.distributedmodules module
- modelparameters.sympy.polys.euclidtools module
- modelparameters.sympy.polys.factortools module
- modelparameters.sympy.polys.fglmtools module
- modelparameters.sympy.polys.fields module
- modelparameters.sympy.polys.galoistools module
- modelparameters.sympy.polys.groebnertools module
- modelparameters.sympy.polys.heuristicgcd module
- modelparameters.sympy.polys.modulargcd module
- modelparameters.sympy.polys.monomials module
- modelparameters.sympy.polys.numberfields module
- modelparameters.sympy.polys.orderings module
- modelparameters.sympy.polys.orthopolys module
- modelparameters.sympy.polys.partfrac module
- modelparameters.sympy.polys.polyclasses module
- modelparameters.sympy.polys.polyconfig module
- modelparameters.sympy.polys.polyerrors module
- modelparameters.sympy.polys.polyfuncs module
- modelparameters.sympy.polys.polymatrix module
- modelparameters.sympy.polys.polyoptions module
- modelparameters.sympy.polys.polyquinticconst module
- modelparameters.sympy.polys.polyroots module
- modelparameters.sympy.polys.polytools module
- modelparameters.sympy.polys.polyutils module
- modelparameters.sympy.polys.rationaltools module
- modelparameters.sympy.polys.ring_series module
- modelparameters.sympy.polys.rings module
- modelparameters.sympy.polys.rootisolation module
- modelparameters.sympy.polys.rootoftools module
- modelparameters.sympy.polys.solvers module
- modelparameters.sympy.polys.specialpolys module
- modelparameters.sympy.polys.sqfreetools module
- modelparameters.sympy.polys.subresultants_qq_zz module
- Module contents
- modelparameters.sympy.printing package
- Subpackages
- Submodules
- modelparameters.sympy.printing.ccode module
- modelparameters.sympy.printing.codeprinter module
- modelparameters.sympy.printing.conventions module
- modelparameters.sympy.printing.cxxcode module
- modelparameters.sympy.printing.defaults module
- modelparameters.sympy.printing.dot module
- modelparameters.sympy.printing.fcode module
- modelparameters.sympy.printing.gtk module
- modelparameters.sympy.printing.jscode module
- modelparameters.sympy.printing.julia module
- modelparameters.sympy.printing.lambdarepr module
- modelparameters.sympy.printing.latex module
- modelparameters.sympy.printing.llvmjitcode module
- modelparameters.sympy.printing.mathematica module
- modelparameters.sympy.printing.mathml module
- modelparameters.sympy.printing.octave module
- modelparameters.sympy.printing.precedence module
- modelparameters.sympy.printing.preview module
- modelparameters.sympy.printing.printer module
- modelparameters.sympy.printing.python module
- modelparameters.sympy.printing.rcode module
- modelparameters.sympy.printing.repr module
- modelparameters.sympy.printing.rust module
- modelparameters.sympy.printing.str module
- modelparameters.sympy.printing.tableform module
- modelparameters.sympy.printing.theanocode module
- modelparameters.sympy.printing.tree module
- Module contents
- modelparameters.sympy.sandbox package
- modelparameters.sympy.series package
- Submodules
- modelparameters.sympy.series.acceleration module
- modelparameters.sympy.series.approximants module
- modelparameters.sympy.series.formal module
- modelparameters.sympy.series.fourier module
- modelparameters.sympy.series.gruntz module
- modelparameters.sympy.series.kauers module
- modelparameters.sympy.series.limits module
- modelparameters.sympy.series.limitseq module
- modelparameters.sympy.series.order module
- modelparameters.sympy.series.residues module
- modelparameters.sympy.series.sequences module
- modelparameters.sympy.series.series module
- modelparameters.sympy.series.series_class module
- Module contents
- modelparameters.sympy.sets package
- modelparameters.sympy.simplify package
- Submodules
- modelparameters.sympy.simplify.combsimp module
- modelparameters.sympy.simplify.cse_main module
- modelparameters.sympy.simplify.cse_opts module
- modelparameters.sympy.simplify.epathtools module
- modelparameters.sympy.simplify.fu module
- modelparameters.sympy.simplify.hyperexpand module
- modelparameters.sympy.simplify.hyperexpand_doc module
- modelparameters.sympy.simplify.powsimp module
- modelparameters.sympy.simplify.radsimp module
- modelparameters.sympy.simplify.ratsimp module
- modelparameters.sympy.simplify.simplify module
- modelparameters.sympy.simplify.sqrtdenest module
- modelparameters.sympy.simplify.traversaltools module
- modelparameters.sympy.simplify.trigsimp module
- Module contents
- modelparameters.sympy.solvers package
- Submodules
- modelparameters.sympy.solvers.bivariate module
- modelparameters.sympy.solvers.decompogen module
- modelparameters.sympy.solvers.deutils module
- modelparameters.sympy.solvers.diophantine module
- modelparameters.sympy.solvers.inequalities module
- modelparameters.sympy.solvers.ode module
- modelparameters.sympy.solvers.pde module
- modelparameters.sympy.solvers.polysys module
- modelparameters.sympy.solvers.recurr module
- modelparameters.sympy.solvers.solvers module
- modelparameters.sympy.solvers.solveset module
- Module contents
- modelparameters.sympy.stats package
- Submodules
- modelparameters.sympy.stats.crv module
- modelparameters.sympy.stats.crv_types module
- modelparameters.sympy.stats.drv module
- modelparameters.sympy.stats.drv_types module
- modelparameters.sympy.stats.error_prop module
- modelparameters.sympy.stats.frv module
- modelparameters.sympy.stats.frv_types module
- modelparameters.sympy.stats.rv module
- modelparameters.sympy.stats.rv_interface module
- modelparameters.sympy.stats.symbolic_probability module
- Module contents
- modelparameters.sympy.strategies package
- Subpackages
- Submodules
- modelparameters.sympy.strategies.core module
- modelparameters.sympy.strategies.rl module
- modelparameters.sympy.strategies.tools module
- modelparameters.sympy.strategies.traverse module
- modelparameters.sympy.strategies.tree module
- modelparameters.sympy.strategies.util module
- Module contents
- modelparameters.sympy.tensor package
- modelparameters.sympy.unify package
- modelparameters.sympy.utilities package
- Subpackages
- Submodules
- modelparameters.sympy.utilities.autowrap module
- modelparameters.sympy.utilities.benchmarking module
- modelparameters.sympy.utilities.codegen module
- modelparameters.sympy.utilities.decorator module
- modelparameters.sympy.utilities.enumerative module
- modelparameters.sympy.utilities.exceptions module
- modelparameters.sympy.utilities.iterables module
- modelparameters.sympy.utilities.lambdify module
- modelparameters.sympy.utilities.magic module
- modelparameters.sympy.utilities.memoization module
- modelparameters.sympy.utilities.misc module
- modelparameters.sympy.utilities.pkgdata module
- modelparameters.sympy.utilities.pytest module
- modelparameters.sympy.utilities.randtest module
- modelparameters.sympy.utilities.runtests module
- modelparameters.sympy.utilities.source module
- modelparameters.sympy.utilities.timeutils module
- Module contents
- modelparameters.sympy.vector package
- Submodules
- modelparameters.sympy.vector.basisdependent module
- modelparameters.sympy.vector.coordsysrect module
- modelparameters.sympy.vector.deloperator module
- modelparameters.sympy.vector.dyadic module
- modelparameters.sympy.vector.functions module
- modelparameters.sympy.vector.operators module
- modelparameters.sympy.vector.orienters module
- modelparameters.sympy.vector.point module
- modelparameters.sympy.vector.scalar module
- modelparameters.sympy.vector.vector module
- Module contents
- modelparameters.sympy.assumptions package
- Submodules
- modelparameters.sympy.abc module
- modelparameters.sympy.galgebra module
- modelparameters.sympy.release module
- Module contents
- Subpackages
Submodules¶
modelparameters.codegeneration module¶
- modelparameters.codegeneration.ccode(expr, assign_to=None, float_precision='double')[source]¶
Return a C-code representation of a sympy expression
- modelparameters.codegeneration.cppcode(expr, assign_to=None, float_precision='double')[source]¶
Return a C++-code representation of a sympy expression
- modelparameters.codegeneration.error(*message, **kwargs)[source]¶
Write error message and raise an exception.
- modelparameters.codegeneration.latex(expr, **settings)[source]¶
Convert the given expression to LaTeX representation.
>>> from .. import latex, pi, sin, asin, Integral, Matrix, Rational >>> from ..abc import x, y, mu, r, tau
>>> print(latex((2*tau)**Rational(7,2))) 8 \sqrt{2} \tau^{\frac{7}{2}}
Not using a print statement for printing, results in double backslashes for latex commands since that’s the way Python escapes backslashes in strings.
>>> latex((2*tau)**Rational(7,2)) '8 \\sqrt{2} \\tau^{\\frac{7}{2}}'
order: Any of the supported monomial orderings (currently “lex”, “grlex”, or “grevlex”), “old”, and “none”. This parameter does nothing for Mul objects. Setting order to “old” uses the compatibility ordering for Add defined in Printer. For very large expressions, set the ‘order’ keyword to ‘none’ if speed is a concern.
mode: Specifies how the generated code will be delimited. ‘mode’ can be one of ‘plain’, ‘inline’, ‘equation’ or ‘equation*’. If ‘mode’ is set to ‘plain’, then the resulting code will not be delimited at all (this is the default). If ‘mode’ is set to ‘inline’ then inline LaTeX $ $ will be used. If ‘mode’ is set to ‘equation’ or ‘equation*’, the resulting code will be enclosed in the ‘equation’ or ‘equation*’ environment (remember to import ‘amsmath’ for ‘equation*’), unless the ‘itex’ option is set. In the latter case, the
$$ $$
syntax is used.>>> print(latex((2*mu)**Rational(7,2), mode='plain')) 8 \sqrt{2} \mu^{\frac{7}{2}}
>>> print(latex((2*tau)**Rational(7,2), mode='inline')) $8 \sqrt{2} \tau^{7 / 2}$
>>> print(latex((2*mu)**Rational(7,2), mode='equation*')) \begin{equation*}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation*}
>>> print(latex((2*mu)**Rational(7,2), mode='equation')) \begin{equation}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation}
itex: Specifies if itex-specific syntax is used, including emitting
$$ $$
.>>> print(latex((2*mu)**Rational(7,2), mode='equation', itex=True)) $$8 \sqrt{2} \mu^{\frac{7}{2}}$$
fold_frac_powers: Emit “^{p/q}” instead of “^{frac{p}{q}}” for fractional powers.
>>> print(latex((2*tau)**Rational(7,2), fold_frac_powers=True)) 8 \sqrt{2} \tau^{7/2}
fold_func_brackets: Fold function brackets where applicable.
>>> print(latex((2*tau)**sin(Rational(7,2)))) \left(2 \tau\right)^{\sin{\left (\frac{7}{2} \right )}} >>> print(latex((2*tau)**sin(Rational(7,2)), fold_func_brackets = True)) \left(2 \tau\right)^{\sin {\frac{7}{2}}}
fold_short_frac: Emit “p / q” instead of “frac{p}{q}” when the denominator is simple enough (at most two terms and no powers). The default value is True for inline mode, False otherwise.
>>> print(latex(3*x**2/y)) \frac{3 x^{2}}{y} >>> print(latex(3*x**2/y, fold_short_frac=True)) 3 x^{2} / y
long_frac_ratio: The allowed ratio of the width of the numerator to the width of the denominator before we start breaking off long fractions. The default value is 2.
>>> print(latex(Integral(r, r)/2/pi, long_frac_ratio=2)) \frac{\int r\, dr}{2 \pi} >>> print(latex(Integral(r, r)/2/pi, long_frac_ratio=0)) \frac{1}{2 \pi} \int r\, dr
mul_symbol: The symbol to use for multiplication. Can be one of None, “ldot”, “dot”, or “times”.
>>> print(latex((2*tau)**sin(Rational(7,2)), mul_symbol="times")) \left(2 \times \tau\right)^{\sin{\left (\frac{7}{2} \right )}}
inv_trig_style: How inverse trig functions should be displayed. Can be one of “abbreviated”, “full”, or “power”. Defaults to “abbreviated”.
>>> print(latex(asin(Rational(7,2)))) \operatorname{asin}{\left (\frac{7}{2} \right )} >>> print(latex(asin(Rational(7,2)), inv_trig_style="full")) \arcsin{\left (\frac{7}{2} \right )} >>> print(latex(asin(Rational(7,2)), inv_trig_style="power")) \sin^{-1}{\left (\frac{7}{2} \right )}
mat_str: Which matrix environment string to emit. “smallmatrix”, “matrix”, “array”, etc. Defaults to “smallmatrix” for inline mode, “matrix” for matrices of no more than 10 columns, and “array” otherwise.
>>> print(latex(Matrix(2, 1, [x, y]))) \left[\begin{matrix}x\\y\end{matrix}\right]
>>> print(latex(Matrix(2, 1, [x, y]), mat_str = "array")) \left[\begin{array}{c}x\\y\end{array}\right]
mat_delim: The delimiter to wrap around matrices. Can be one of “[”, “(“, or the empty string. Defaults to “[“.
>>> print(latex(Matrix(2, 1, [x, y]), mat_delim="(")) \left(\begin{matrix}x\\y\end{matrix}\right)
symbol_names: Dictionary of symbols and the custom strings they should be emitted as.
>>> print(latex(x**2, symbol_names={x:'x_i'})) x_i^{2}
latex
also supports the builtin container types list, tuple, and dictionary.>>> print(latex([2/x, y], mode='inline')) $\left [ 2 / x, \quad y\right ]$
- modelparameters.codegeneration.latex_unit(unit)[source]¶
Return sympified and LaTeX-formatted string describing given unit. E.g.: >>> LatexCodeGenerator.format_unit(“m/s**2”) ‘mathrm{frac{m}{s^{2}}}’
- modelparameters.codegeneration.octavecode(expr, assign_to=None)¶
modelparameters.commands module¶
modelparameters.config module¶
modelparameters.logger module¶
- class modelparameters.logger.Logger(name)[source]¶
Bases:
object
- pop_log_level()[source]¶
Pop log level from the level stack, reverting to before the last push_level.
modelparameters.parameterdict module¶
Contains the ParameterDict class, useful for defining recursive dictionaries of parameters and using attribute syntax for later access.
- class modelparameters.parameterdict.ArrayParam(value, size=None, ge=None, le=None, gt=None, lt=None, unit='1', name='', description='')[source]¶
Bases:
ScalarParam
A numpy Array based parameter
- property value¶
Return the value
- class modelparameters.parameterdict.ConstParam(value, name='', description='')[source]¶
Bases:
Param
A Constant parameter which prevent any change of values
- class modelparameters.parameterdict.OptionParam(value, options, name='', description='')[source]¶
Bases:
Param
A simple type and options checking class for a single value
- class modelparameters.parameterdict.Param(value, name='', description='', **kwargs)[source]¶
Bases:
object
A simple type checking class for a single value
- convert_to(unit)[source]¶
Convert parameter to a different unit than the current one.
- Parameters:
unit (str) – The new unit
- Returns:
Return the same prameter with the new unit
- Return type:
Example
>>> p_s = ScalarParam(1.0, unit="s") >>> p_ms = p_s.convert_to('ms') >>> print('value = {}, unit = {}'.format(p_ms.value), p_ms.unit)) value = 1000.0, unit = 'milliseconds'
- copy(include_checkarg=True, include_name=True, include_description=True)[source]¶
Return a copy of the parameter
- property description¶
- format_data(value=None, not_in=False, str_length=0)[source]¶
Print a nice formated version of the value and its range
- property name¶
- repr(include_checkarg=True, include_name=True, include_description=True)[source]¶
Returns an executable version of the Param including optional arguments
- property value¶
Return the value
- class modelparameters.parameterdict.ParameterDict(**params)[source]¶
Bases:
dict
A dictionary with attribute-style access, that maps attribute access to the real dictionary.
- copy(to_dict=False)[source]¶
Make a deep copy of self, including recursive copying of parameter subsets.
- Parameters:
to_dict (bool (optional)) – Return a dict with items representing the values of the Parameters
- format_data(indent=None)[source]¶
Make a recursive indented pretty-print string of self and parameter subsets.
- iterparameterdicts()[source]¶
Iterate over all ParameterDicts
- Parameters:
recurse (bool (optional)) – If True each encountered ParameterDict will also be entered
- iterparams(recurse=False)[source]¶
Iterate over all Param
- Parameters:
recurse (bool (optional)) – If True each encountered ParameterDict will be entered
- optstr()[source]¶
Return a string with option set
An option string can be sent to a script using a parameter dict to set its parameters from command line options
- class modelparameters.parameterdict.ScalarParam(value, ge=None, le=None, gt=None, lt=None, unit='1', name='', description='')[source]¶
Bases:
Param
A simple type and range checking class for a scalar value
- copy(include_checkarg=True, include_name=True, include_description=True, include_unit=True)[source]¶
Return a copy of the parameter
- property name¶
- repr(include_checkarg=True, include_name=True, include_description=True, include_unit=True)[source]¶
Returns an executable version of the Param including optional arguments
- property sym¶
- property unit¶
Return the unit
- class modelparameters.parameterdict.SlaveParam(expr, unit='1', name='', description='')[source]¶
Bases:
ScalarParam
A slave parameter defined by other parameters
- property expr¶
Return the stored expression
- format_data(value=None, not_in=False, str_length=0)[source]¶
Print a nice formated version of the value and its range
- property value¶
Return a computed value of the Parameters
modelparameters.parameters module¶
- class modelparameters.parameters.ArrayParam(value, size=None, ge=None, le=None, gt=None, lt=None, unit='1', name='', description='')[source]¶
Bases:
ScalarParam
A numpy Array based parameter
- property value¶
Return the value
- class modelparameters.parameters.ConstParam(value, name='', description='')[source]¶
Bases:
Param
A Constant parameter which prevent any change of values
- class modelparameters.parameters.OptionParam(value, options, name='', description='')[source]¶
Bases:
Param
A simple type and options checking class for a single value
- class modelparameters.parameters.Param(value, name='', description='', **kwargs)[source]¶
Bases:
object
A simple type checking class for a single value
- convert_to(unit)[source]¶
Convert parameter to a different unit than the current one.
- Parameters:
unit (str) – The new unit
- Returns:
Return the same prameter with the new unit
- Return type:
Example
>>> p_s = ScalarParam(1.0, unit="s") >>> p_ms = p_s.convert_to('ms') >>> print('value = {}, unit = {}'.format(p_ms.value), p_ms.unit)) value = 1000.0, unit = 'milliseconds'
- copy(include_checkarg=True, include_name=True, include_description=True)[source]¶
Return a copy of the parameter
- property description¶
- format_data(value=None, not_in=False, str_length=0)[source]¶
Print a nice formated version of the value and its range
- property name¶
- repr(include_checkarg=True, include_name=True, include_description=True)[source]¶
Returns an executable version of the Param including optional arguments
- property value¶
Return the value
- class modelparameters.parameters.Range(ge=None, le=None, gt=None, lt=None)[source]¶
Bases:
object
A simple class for helping checking a given value is within a certain range
- format(value, width=0)[source]¶
Return a formated range check of the value
- Parameters:
value (scalar) – A value to be used in checking range
width (int) – A min str length value
- class modelparameters.parameters.ScalarParam(value, ge=None, le=None, gt=None, lt=None, unit='1', name='', description='')[source]¶
Bases:
Param
A simple type and range checking class for a scalar value
- copy(include_checkarg=True, include_name=True, include_description=True, include_unit=True)[source]¶
Return a copy of the parameter
- property name¶
- repr(include_checkarg=True, include_name=True, include_description=True, include_unit=True)[source]¶
Returns an executable version of the Param including optional arguments
- property sym¶
- property unit¶
Return the unit
- class modelparameters.parameters.SlaveParam(expr, unit='1', name='', description='')[source]¶
Bases:
ScalarParam
A slave parameter defined by other parameters
- property expr¶
Return the stored expression
- format_data(value=None, not_in=False, str_length=0)[source]¶
Print a nice formated version of the value and its range
- property value¶
Return a computed value of the Parameters
- class modelparameters.parameters.TypelessParam(value, name='', description='')[source]¶
Bases:
Param
A Typeless parameter allowing any change of value, including type changes
- modelparameters.parameters.check_arg(arg, argtypes, num=-1, context=None, itemtypes=None, ge=None, le=None, gt=None, lt=None)[source]¶
Type check for positional arguments
- Parameters:
arg (any) – The argument to be checked
num (int (optional)) – The argument positional number
context (type, function/method (optional)) – The context of the check. If context is a class the check is assumed to be during creation. If a function/method the contex is assumed to be a call to that function/method
itemtypes (type (optional)) – If given argtypes must be a tuple or list and itemtypes forces each item to be a certain type
ge (scalar (optional)) – Greater than or equal, range control of argument
le (scalar (optional)) – Lesser than or equal, range control of argument
gt (scalar (optional)) – Greater than, range control of argument
lt (scalar (optional)) – Lesser than, range control of argument
- modelparameters.parameters.check_kwarg(kwarg, name, argtypes, context=None, itemtypes=None, ge=None, le=None, gt=None, lt=None)[source]¶
Type check for keyword arguments
- Parameters:
kwarg (any) – The keyword argument to be checked
name (str) – The name of the keyword argument
context (type, function/method (optional)) – The context of the check. If context is a class the check is assumed to be during creation. If a function/method the contex is assumed to be a call to that function/method
itemtypes (type (optional)) – If given argtypes must be a tuple or list and itemtypes forces each item to be a certain type
ge (scalar (optional)) – Greater than or equal, range control of argument
le (scalar (optional)) – Lesser than or equal, range control of argument
gt (scalar (optional)) – Greater than, range control of argument
lt (scalar (optional)) – Lesser than, range control of argument
- modelparameters.parameters.error(*message, **kwargs)[source]¶
Write error message and raise an exception.
- modelparameters.parameters.eval_param_expr(expr, param_ns=None, include_derivatives=False, ns=None)[source]¶
Eval an expression of symbols of ScalarParam
- Parameters:
expr (expression of ParamSymbols) – The expression to be evaulated
param_ns (dict (optional)) – A namespace containing the parameters for which the expr should be evaluated with.
include_derivatives (bool (optional)) – If True not only symbols are evaulated but also derivatives
ns (dict (optional)) – A namespace in which the expression will be evaluated in
- modelparameters.parameters.pythoncode(expr, assign_to=None, namespace='math')[source]¶
Return a Python-code representation of a sympy expression
- modelparameters.parameters.symbol_to_param(sym)[source]¶
Take a symbol or expression of symbols and returns the corresponding Parameters
- modelparameters.parameters.symbols_from_expr(expr, include_numbers=False, include_derivatives=False)[source]¶
Returns a set of all symbols of an expression
- modelparameters.parameters.type_error(*message, **kwargs)[source]¶
Write error message and raise a type error exception.
- modelparameters.parameters.value_error(*message, **kwargs)[source]¶
Write error message and raise a value error exception.
- modelparameters.parameters.value_formatter(value, width=0)[source]¶
Return a formated string of a value
- Parameters:
value (any) – The value which is formatted
width (int) – A min str length value
modelparameters.sympytools module¶
- modelparameters.sympytools.Conditional(cond, true_value, false_value)[source]¶
Declares a conditional
- Parameters:
cond (A conditional) – The conditional which should be evaluated
true_value (Any model expression) – Model expression for a true evaluation of the conditional
false_value (Any model expression) – Model expression for a false evaluation of the conditional
- modelparameters.sympytools.ContinuousConditional(cond, true_value, false_value, sigma=1.0)[source]¶
Declares a continuous conditional. Instead of a either or result the true and false values are weighted with a sigmoidal function which either evaluates to 0 or 1 instead of the true or false.
- Parameters:
cond (An InEquality conditional) – An InEquality conditional which should be evaluated
true_value (Any model expression) – Model expression for a true evaluation of the conditional
false_value (Any model expression) – Model expression for a false evaluation of the conditional
sigma (float (optional)) – Determines the sharpness of the sigmoidal function
- modelparameters.sympytools.add_pair_to_subs(subs, old, new)[source]¶
Add a pair of old and new symbols to subs. If a subs with old as a key already excist it will be removed before insertion.
- modelparameters.sympytools.check_arg(arg, argtypes, num=-1, context=None, itemtypes=None, ge=None, le=None, gt=None, lt=None)[source]¶
Type check for positional arguments
- Parameters:
arg (any) – The argument to be checked
num (int (optional)) – The argument positional number
context (type, function/method (optional)) – The context of the check. If context is a class the check is assumed to be during creation. If a function/method the contex is assumed to be a call to that function/method
itemtypes (type (optional)) – If given argtypes must be a tuple or list and itemtypes forces each item to be a certain type
ge (scalar (optional)) – Greater than or equal, range control of argument
le (scalar (optional)) – Lesser than or equal, range control of argument
gt (scalar (optional)) – Greater than, range control of argument
lt (scalar (optional)) – Lesser than, range control of argument
- modelparameters.sympytools.deprecated(func)[source]¶
This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.
- modelparameters.sympytools.error(*message, **kwargs)[source]¶
Write error message and raise an exception.
- modelparameters.sympytools.iter_symbol_params_from_expr(expr)[source]¶
Return an iterator over sp.Symbols from expr
- modelparameters.sympytools.symbol_param_value_namespace(expr)[source]¶
Create a value name space for the included symbols in the expression
- modelparameters.sympytools.symbol_params_from_expr(expr)[source]¶
Return a list of Symbols from expr
- modelparameters.sympytools.symbol_to_param(sym)[source]¶
Take a symbol or expression of symbols and returns the corresponding Parameters
- modelparameters.sympytools.symbols_from_expr(expr, include_numbers=False, include_derivatives=False)[source]¶
Returns a set of all symbols of an expression
- modelparameters.sympytools.type_error(*message, **kwargs)[source]¶
Write error message and raise a type error exception.
modelparameters.utils module¶
- class modelparameters.utils.Range(ge=None, le=None, gt=None, lt=None)[source]¶
Bases:
object
A simple class for helping checking a given value is within a certain range
- format(value, width=0)[source]¶
Return a formated range check of the value
- Parameters:
value (scalar) – A value to be used in checking range
width (int) – A min str length value
- modelparameters.utils.VALUE_JUST(s, *args, **kwargs)¶
- modelparameters.utils.check_arg(arg, argtypes, num=-1, context=None, itemtypes=None, ge=None, le=None, gt=None, lt=None)[source]¶
Type check for positional arguments
- Parameters:
arg (any) – The argument to be checked
num (int (optional)) – The argument positional number
context (type, function/method (optional)) – The context of the check. If context is a class the check is assumed to be during creation. If a function/method the contex is assumed to be a call to that function/method
itemtypes (type (optional)) – If given argtypes must be a tuple or list and itemtypes forces each item to be a certain type
ge (scalar (optional)) – Greater than or equal, range control of argument
le (scalar (optional)) – Lesser than or equal, range control of argument
gt (scalar (optional)) – Greater than, range control of argument
lt (scalar (optional)) – Lesser than, range control of argument
- modelparameters.utils.check_kwarg(kwarg, name, argtypes, context=None, itemtypes=None, ge=None, le=None, gt=None, lt=None)[source]¶
Type check for keyword arguments
- Parameters:
kwarg (any) – The keyword argument to be checked
name (str) – The name of the keyword argument
context (type, function/method (optional)) – The context of the check. If context is a class the check is assumed to be during creation. If a function/method the contex is assumed to be a call to that function/method
itemtypes (type (optional)) – If given argtypes must be a tuple or list and itemtypes forces each item to be a certain type
ge (scalar (optional)) – Greater than or equal, range control of argument
le (scalar (optional)) – Lesser than or equal, range control of argument
gt (scalar (optional)) – Greater than, range control of argument
lt (scalar (optional)) – Lesser than, range control of argument
- modelparameters.utils.deprecated(func)[source]¶
This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.
- modelparameters.utils.error(*message, **kwargs)[source]¶
Write error message and raise an exception.
- modelparameters.utils.format_time(time)[source]¶
Return a formated version of the time argument
- Parameters:
time (float) – Time given in sections
- modelparameters.utils.is_iterable(obj)[source]¶
Test for iterable
- Parameters:
obj (any) – Object which is beeing tested
- modelparameters.utils.quote_join(list_of_str)[source]¶
Join a list of strings with quotes and commans
- modelparameters.utils.reduce(function, sequence[, initial]) value ¶
Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.
- modelparameters.utils.type_error(*message, **kwargs)[source]¶
Write error message and raise a type error exception.
- modelparameters.utils.value_error(*message, **kwargs)[source]¶
Write error message and raise a value error exception.
Module contents¶
- class modelparameters.ParameterDict(**params)[source]¶
Bases:
dict
A dictionary with attribute-style access, that maps attribute access to the real dictionary.
- copy(to_dict=False)[source]¶
Make a deep copy of self, including recursive copying of parameter subsets.
- Parameters:
to_dict (bool (optional)) – Return a dict with items representing the values of the Parameters
- format_data(indent=None)[source]¶
Make a recursive indented pretty-print string of self and parameter subsets.
- iterparameterdicts()[source]¶
Iterate over all ParameterDicts
- Parameters:
recurse (bool (optional)) – If True each encountered ParameterDict will also be entered
- iterparams(recurse=False)[source]¶
Iterate over all Param
- Parameters:
recurse (bool (optional)) – If True each encountered ParameterDict will be entered
- optstr()[source]¶
Return a string with option set
An option string can be sent to a script using a parameter dict to set its parameters from command line options
- class modelparameters.ScalarParam(value, ge=None, le=None, gt=None, lt=None, unit='1', name='', description='')[source]¶
Bases:
Param
A simple type and range checking class for a scalar value
- copy(include_checkarg=True, include_name=True, include_description=True, include_unit=True)[source]¶
Return a copy of the parameter
- property name¶
- repr(include_checkarg=True, include_name=True, include_description=True, include_unit=True)[source]¶
Returns an executable version of the Param including optional arguments
- property sym¶
- property unit¶
Return the unit