pharmpy.statements module

class pharmpy.statements.Assignment(symbol, expression)[source]

Bases: object

Representation of variable assignment, similar to sympy.codegen.Assignment

Variables
  • symbol (sympy.Symbol) – Symbol of statement

  • expression – Expression of statement

property free_symbols
order_terms(rvs, trans)[source]

Order terms such that random variables are placed last. Currently only supports additions.

print_custom(rvs, trans)[source]
property rhs_symbols
subs(substitutions)[source]

Substitute symbols in assignment.

substitutions - dictionary with old-new pair (can be type str or

sympy symbol)

class pharmpy.statements.Bolus(amount)[source]

Bases: object

property free_symbols
subs(substitutions)[source]
class pharmpy.statements.Compartment(name, index, lag_time=0)[source]

Bases: object

property amount
property free_symbols
property lag_time
subs(substitutions)[source]
class pharmpy.statements.CompartmentalSystem[source]

Bases: pharmpy.statements.ODESystem

System of ODEs descibed as a compartmental system

add_compartment(name)[source]
add_flow(source, destination, rate)[source]
property amounts
atoms(cls)[source]
property compartmental_matrix
find_central()[source]

Find the central compartment

The central compartment is defined to be the compartment that has an outward flow to the output compartment. Only one central compartment is supported.

find_compartment(name)[source]
find_depot(statements)[source]

Find the depot compartment

The depot compartment is defined to be the compartment that only has out flow to the central compartment, but no flow from the central compartment.

find_dosing()[source]

Find the dosing compartment

A dosing compartment is a compartment that receives an input dose. Only one dose compartment is supported.

find_output()[source]

Find the output compartment

An output compartment is defined to be a compartment that does not have any outward flow. A model has to have one and only one output compartment.

find_peripherals()[source]
find_transit_compartments(statements)[source]

Find all transit compartments

Transit compartments are a chain of compartments with the same out rate starting from the dose compartment. Because one single transit compartment cannot be distinguished from one depot compartment such compartment will be defined to be a depot and not a transit compartment.

property free_symbols
get_compartment_inflows(compartment)[source]

Generate all flows going in to a compartment

get_compartment_outflows(compartment)[source]

Generate all flows going out of a compartment

get_flow(source, destination)[source]
n_connected(comp)[source]

Get the number of compartments connected to comp

property names

A list of the names of all compartments

remove_compartment(compartment)[source]
remove_flow(source, destination)[source]
property rhs_symbols
subs(substitutions)[source]
t = t
to_explicit_odes(skip_output=False)[source]
property zero_order_inputs

A vector of all zero order inputs to each compartment

class pharmpy.statements.ExplicitODESystem(odes, ics)[source]

Bases: pharmpy.statements.ODESystem

System of ODEs described explicitly

property free_symbols
property rhs_symbols
subs(substitutions)[source]
to_compartmental_system()[source]
class pharmpy.statements.Infusion(amount, rate=None, duration=None)[source]

Bases: object

property free_symbols
subs(substitutions)[source]
class pharmpy.statements.ModelStatements(statements=None)[source]

Bases: collections.abc.MutableSequence

A list of sympy statements describing the model

add_before_odes(statement)[source]

Add a statement just before the ODE system or at the end of the model

before_ode()[source]
copy()[source]
dependencies(symbol)[source]

Find all dependencies of a symbol

extract_params_from_symb(symbol_name, pset)[source]
find_assignment(variable, is_symbol=True, last=True)[source]

Returns full last statement or all assignments that contains the symbol or variable of interest of an assignment

property free_symbols

Get a set of all free symbols

full_expression_after_odes(expression)[source]

Expand an expression into its full definition

After ODE system

full_expression_from_odes(expression)[source]

Expand an expression into its full definition

Before ODE system

insert(ind, value)[source]

S.insert(index, value) – insert value before index

property ode_system

Returns the ODE system of the model or None if the model doesn’t have an ODE system

reassign(symbol, expression)[source]

Reassign symbol to expression

remove_symbol_definitions(symbols, statement)[source]

Remove symbols and dependencies not used elsewhere. statement is the statement from which the symbol was removed

subs(substitutions)[source]

Substitute symbols in all statements.

substitutions - dictionary with old-new pair (can be type str or

sympy symbol)

class pharmpy.statements.MyPrinter(settings=None)[source]

Bases: sympy.printing.str.StrPrinter

class pharmpy.statements.ODESystem[source]

Bases: object

Base class and placeholder for ODE systems of different forms

Variables

solver (str) – Solver to use when numerically solving the ode system Currently supports NONMEM ADVANs

property free_symbols
property rhs_symbols
subs(substitutions)[source]

Inheritance Diagram

Inheritance diagram of pharmpy.statements