modelgraph package

Submodules

modelgraph.cli module

modelgraph.dependency_graph module

class modelgraph.dependency_graph.DependencyGraph(ode: GotranxODE | GotranODE)[source]

Bases: object

dependency_graph(name: str) DiGraph[source]

Get the dependency graph where each node reperesents an expression and a directed edge means that there is a dependency.

There will be a directed edge from the root node to another node if the root node is a dependency of the other node.

Parameters:

name (str) – Name of the root node

Returns:

A directed dependency graph

Return type:

nx.DiGraph

property dependent_names: list[str]

Return all the names of the expressions having dependencies

Returns:

List of names

Return type:

list[str]

dependents(name: str, direct: bool = True) set[str][source]

Given a name of an expression return its dependencies

Parameters:
  • name (str) – Name of the expression

  • direct (bool, optional) – Whether to return only direct depenencies or also include indirect dependencies, by default True

Returns:

Set of names of all dependencies

Return type:

set[str]

inv_dependency_graph(name: str)[source]

Get the dependency graph where each node reperesents an expression and a directed edge means that there is a dependency.

There will be a directed edge from the root node to another node if the root node depends on the other node.

Parameters:

name (str) – Name of the root node

Returns:

A directed dependency graph

Return type:

nx.DiGraph

property inv_dependent_names: list[str]

Return all the names of the expressions that other expressions depdens on

Returns:

List of names

Return type:

list[str]

inv_dependents(name: str, direct: bool = True) set[str][source]

Given a name of an expression return all expressions that depends on it

Parameters:
  • name (str) – Name of the expression

  • direct (bool, optional) – Whether to return only direct depenencies or also include indirect dependencies, by default True

Returns:

Set of names of all dependencies

Return type:

set[str]

class modelgraph.dependency_graph.GotranDependent(*args, **kwargs)[source]

Bases: Protocol

is_Symbol: bool
class modelgraph.dependency_graph.GotranODE(*args, **kwargs)[source]

Bases: Protocol

intermediates: Sequence[GotranVariable]
state_expressions: Sequence[GotranVariable]
class modelgraph.dependency_graph.GotranVariable(*args, **kwargs)[source]

Bases: Protocol

dependent: Sequence[GotranDependent]
name: str
class modelgraph.dependency_graph.GotranxODE(*args, **kwargs)[source]

Bases: Protocol

dependents() dict[str, set[str]][source]

Module contents

class modelgraph.DependencyGraph(ode: GotranxODE | GotranODE)[source]

Bases: object

dependency_graph(name: str) DiGraph[source]

Get the dependency graph where each node reperesents an expression and a directed edge means that there is a dependency.

There will be a directed edge from the root node to another node if the root node is a dependency of the other node.

Parameters:

name (str) – Name of the root node

Returns:

A directed dependency graph

Return type:

nx.DiGraph

property dependent_names: list[str]

Return all the names of the expressions having dependencies

Returns:

List of names

Return type:

list[str]

dependents(name: str, direct: bool = True) set[str][source]

Given a name of an expression return its dependencies

Parameters:
  • name (str) – Name of the expression

  • direct (bool, optional) – Whether to return only direct depenencies or also include indirect dependencies, by default True

Returns:

Set of names of all dependencies

Return type:

set[str]

inv_dependency_graph(name: str)[source]

Get the dependency graph where each node reperesents an expression and a directed edge means that there is a dependency.

There will be a directed edge from the root node to another node if the root node depends on the other node.

Parameters:

name (str) – Name of the root node

Returns:

A directed dependency graph

Return type:

nx.DiGraph

property inv_dependent_names: list[str]

Return all the names of the expressions that other expressions depdens on

Returns:

List of names

Return type:

list[str]

inv_dependents(name: str, direct: bool = True) set[str][source]

Given a name of an expression return all expressions that depends on it

Parameters:
  • name (str) – Name of the expression

  • direct (bool, optional) – Whether to return only direct depenencies or also include indirect dependencies, by default True

Returns:

Set of names of all dependencies

Return type:

set[str]