pharmpy.modeling.get_unit_of#

pharmpy.modeling.get_unit_of(model, variable=None)[source]#

Derive the physical unit of a variable in the model

Unit information for the dataset needs to be available. The variable can be defined in the code, a dataset column, a parameter or a random variable. Optionally units could be derived for all variables in the model.

Parameters:
  • model (Model) – Pharmpy model

  • variable (str | Expr | None) – Find physical unit of this variable. For None get a dict with units for all variables defined by the model.

Returns:

Unit – A unit expression

Examples

>>> from pharmpy.modeling import load_example_model, get_unit_of
>>> model = load_example_model("pheno")
>>> get_unit_of(model, "Y")
mg/L
>>> get_unit_of(model, "VC")
L
>>> get_unit_of(model, "WGT")
kg