pyvplm.core package

Submodules

pyvplm.core.definition module

Core module defining elementary class and methods for SizingLab

class pyvplm.core.definition.Constraint(expression, desc='')

Bases: object

Class defining a Constraint.

description

additional text to describe equation

Type

str

parameters

list of all the parameters names

Type

list(str)

function

is the computational expression of the constraint

Type

func

function_expr

is the literal expression of the constraint

Type

str

Example

compute(parameters_dict)
class pyvplm.core.definition.ConstraintSet(*constraints)

Bases: object

Class defining a ConstraintSet.

parameters

list of all the parameters names from all constraints

Type

list(str)

constraints_list

is the list of Constraint

Type

list(Constraint)

Example

declare_doe_constraint(parameter_set)

Specific method to generate constraint function for pyvplm pixdoe use.

class pyvplm.core.definition.Parameter(name: str, defined_bounds: list, defined_units: str, description: str)

Bases: object

Class defining one physical parameter.

name
the parameter name as a convention will be converted to :
  • upper char(s) for constant

  • lower char(s) for variable

Type

str

defined_bounds

converted to float and checked that defined_bounds[0]<defined_bounds[1], set to [] for constant

Type

[1*2] list of int or float

value

converted to float, set to [] for variable

Type

int or float

defined_units

the parameters defined units (expression checked using PINT package)

Type

str

description

some description on the parameter

Type

str

_SI_bounds(private)

the parameter bounds expressed into SI units automatically derived from defined bounds using PINT package

Type

[1*2] list of float

_SI_units(private)

SI units are automatically derived from defined units using PINT package

Type

str

_dimensionality(private)

the parameter dimensions derived from units using PINT package (ex: meter->[length])

Type

str

Examples

save a parameter:
>>> In [1]: m = Parameter('m', [50, 100], 'kg', 'mass')
save a constant:
>>> In [2]: k = Parameter('k', [2], '', 'oversizing coefficient')
get k parameter value in equation:
>>> In [3]: a = float(k)*2.0
>>> Out[3]: 4.0
print parameters’attributes:
>>> In [4]: print(m)
m.name=m
m.defined_bounds=[50.0, 100.0]
...
m._dimensionality=[mass]
change parameter’s attribute values:
>>> In [5]: m.description = 'body mass'
__float__()

Method to return parameter value with syntax float(parameter_name). If value is empty (i.e. parameter is a variable), returns NaN.

__getattribute__(attribute_name)

Method to access parameter attribute value (for private attributes, warning is displayed). Access is granted using command: parameter_name.attribute_name.

__repr__()

Method to represent parameter definition when entering only parameter_name command.

__setattr__(attribute_name, value, check_units=True)

Method to write parameter attribute value, parameter_name.attribute_name=value (private attribute writing access denied).

__str__()

Method used to print parameter, called with print(parameter_name) function.

check_bounds(defined_bounds)

Method (internal) to check bounds syntax and value(s).

check_units(defined_units)

Method (internal) to check units value.

ureg = <pint.registry.UnitRegistry object>
class pyvplm.core.definition.ParameterSet(*parameters_list)

Bases: object

Class defining a set of different Parameter(s).

dictionary

The Parameter are registered in oredered dictionary at key [Parameter.name]

Type

OrderedDict of Parameter

Example

save parameters m and k:
>>> In [1]: m = PositiveParameter('m', [50, 100], 'g', 'mass')
>>> In [2]: K1 = Parameter('K1', [2], 'g', 'oversizing coefficient')
>>> In [3]: parameter_set = ParameterSet(m, K1)
add a parameter afterwards:
>>> In [4]: K2 = Parameter('K2', [1.5], '', 'oversizing coefficient')
>>> In [5]: parameter_set['K2'] = K2
get K1 parameter value:
>>> In [6]: a = float(parameter_set['K1'])
change parameters order:
>>> In [7]: parameter_set.first('K2', 'K1')
>>> In [8]: print(parameter_set)
K2: K2=1.5, oversizing coefficient
K1: K1=2gram, oversizing coefficient
m: m in [50.0,100.0]gram, mass
delete K2 parameter:
>>> In [9]: del parameter_set['K2']

Note

While using print function, display differs between variable and constraint.

__delitem__(key)

Method to delete a parameter in a parameter set: del parameter_set[parameter.name].

__getitem__(index)

Method to return a parameter from a parameter set using its name as key: parameter=parameter_set[parameter.name].

__getstate__()

Method to save parameter set using pickle.

__setitem__(key, value)

Method to replace parameter in a parameter set or expend dictionary if new key.

__setstate__(dict)

Method to read parameter set using picklerLoad().

__str__()

Method used to print parameters in the set with function: print(parameter_set).

check_parameters(parameters_list: tuple)

Method (internal) to check parameters.

first(*parameters_list)

Run through parameters_list tuple to move dictionary key to its position in the list.

latex_render(textArea=False)

Method used to print parameters in latex form: latex_render(parameter_set) When parameter name is of the form name_indice this will lead to $name_{indice}$ latex form, number is automatically rendered as indice. Greek letters will also be escaped automatically lambda_wind will lead to $lambda_{wind}$.

class pyvplm.core.definition.PositiveParameter(name: str, defined_bounds: list, defined_units: str, description: str)

Bases: pyvplm.core.definition.Parameter

Subclass of the class Parameter.

Note

This class has identical methods and parameters as the Parameter class except for internal check_bounds method, therefore Parameter should be defined with strictly positive bounds: 0<defined_bounds[0]<defined_bounds[1]

For more details see Parameter()

check_bounds(defined_bounds)

Method (internal) to check bounds syntax and value(s).

class pyvplm.core.definition.PositiveParameterSet(*parameters_list)

Bases: pyvplm.core.definition.ParameterSet

Subclass of the class Parameter.

Note

This class has identical methods and parameters as the Parameter class except for internal check_parameters method, therefore parameters_list should be a tuple of PositiveParameter or a single PositiveParameter

For more details see ParameterSet()

__setitem__(key, value)

Method to replace parameter in a parameter set or expend dictionary if new key.

check_parameters(parameters_list: tuple)

Method (internal) to check parameters.

pyvplm.core.definition.logg_exception(ex: Exception)

Module contents