(class from pyomo.core.base.units_container)
pyomo.core.base.units_container
Bases: StreamBasedExpressionVisitor
StreamBasedExpressionVisitor
Visitor class used to determine units of an expression. Do not use this class directly, but rather use “py:meth:PyomoUnitsContainer.assert_units_consistent or PyomoUnitsContainer.get_units()
PyomoUnitsContainer.get_units()
pyomo_units_container (PyomoUnitsContainer) – Instance of the PyomoUnitsContainer that was used for the units in the expressions. Pyomo does not support “mixing” units from different containers
units_equivalence_tolerance (float (default 1e-12)) – Floating point tolerance used when deciding if units are equivalent or not.
Notes
This class inherits from the StreamBasedExpressionVisitor to implement a walker that returns the pyomo units and pint units corresponding to an expression.
There are class attributes (dicts) that map the expression node type to the particular method that should be called to return the units of the node based on the units of its child arguments. This map is used in exitNode.
Methods
__init__(pyomo_units_container[, ...])
__init__
Visitor class used to determine units of an expression.
beforeChild(node, child, child_idx)
beforeChild
exitNode(node, data)
exitNode
Visitor callback when moving up the expression tree.
finalizeResult(result)
finalizeResult
initializeWalker(expr)
initializeWalker
walk_expression(expr)
walk_expression
Walk an expression, calling registered callbacks.
walk_expression_nonrecursive(expr)
walk_expression_nonrecursive
Nonrecursively walk an expression, calling registered callbacks.
Attributes
client_methods
node_type_method_map
unary_function_method_map
Member Documentation
Callback for pyomo.core.current.StreamBasedExpressionVisitor. This method is called when moving back up the tree in a depth first search.
pyomo.core.current.StreamBasedExpressionVisitor
This is the standard interface for running the visitor. It defaults to using an efficient recursive implementation of the visitor, falling back on walk_expression_nonrecursive() if the recursion stack gets too deep.
walk_expression_nonrecursive()
This routine is safer than the recursive walkers for deep (or unbalanced) trees. It is, however, slightly slower than the recursive implementations.