qat.pbo.VAR
- class qat.pbo.VAR
This class is useful to create mathematical expressions. Each instance of
VAR
represent an abstract variable.- Static functions:
- Member functions:
- Operators:
add (+)
sub (-)
mul (*)
div (/ or //)
pow (**)
- Example of use:
>>> # Init VAR objects >>> x = VAR() >>> y = VAR() ... >>> # Math expression (x and y have no value) >>> z = x + y ... >>> # Setting value for x and y >>> x.set_value(2) >>> y.set_value(3) ... >>> # The value of z in updated >>> z 5 ... >>> # The value of z can change >>> x.set_value(0) >>> z 3 ... >>> # Lock the value of z >>> val = z.eval() >>> y.set_value(0) ... >>> (val, z) (3, 0)
- classmethod copy(*args)
Copy several
VAR
objects preserving links between them- Example of use:
>>> x = VAR() >>> y = VAR() >>> z = x + y ... >>> x_cp, y_cp, z_cp = VAR.copy(x, y, z) >>> # equivalent to z_cp = x_cp + y_cp
- add_prohibited_value(value)
Add a prohibited value - if the
VAR
is NOT a formula, the methodset_value()
will refuse a value close to the given prohibited one- Parameters
value – the prohibited value
- pop_prohibited_value(value)
Remove a prohibited value
- Parameters
value – the prohibited value