Assignment#
- class pharmpy.model.Assignment(symbol, expression)[source]#
Bases:
Statement
Representation of variable assignment
This class represents an assignment of an expression to a variable. Multiple assignments are combined together into a Statements object.
- Parameters:
symbol (Expr) – Symbol of assignment
expression (Expr) – Expression of assignment
Attributes Summary
Expression of assignment
Get set of all free symbols in the assignment
Get set of all free symbols in the right hand side expression
Symbol of statement
Methods Summary
create
(symbol, expression)from_dict
(d)replace
(**kwargs)subs
(substitutions)Substitute expressions or symbols in assignment
to_dict
()Attributes Documentation
- expression#
Expression of assignment
- free_symbols#
Get set of all free symbols in the assignment
Note that the left hand side symbol will be in the set
Examples
>>> from pharmpy.model import Assignment >>> a = Assignment.create('CL', 'POP_CL + ETA_CL') >>> a.free_symbols {CL, ETA_CL, POP_CL}
- rhs_symbols#
Get set of all free symbols in the right hand side expression
Examples
>>> from pharmpy.model import Assignment >>> a = Assignment.create('CL', 'POP_CL + ETA_CL') >>> a.rhs_symbols {ETA_CL, POP_CL}
- symbol#
Symbol of statement
Methods Documentation
- subs(substitutions)[source]#
Substitute expressions or symbols in assignment
- Parameters:
substitutions (dict) – old-new pairs
- Returns:
Assignment – Updated assignment object
Examples
>>> from pharmpy.model import Assignment >>> a = Assignment.create('CL', 'POP_CL + ETA_CL') >>> a CL = ETA_CL + POP_CL >>> b = a.subs({'ETA_CL' : 'ETA_CL * WGT'}) >>> b CL = ETA_CL⋅WGT + POP_CL