petab.v2.extensions.sciml

PEtab SciML extension — classes and runtime state for hybrid ODE/ML problems.

Classes

Hybridization(*, targetId, targetValue, ...)

Assigns PEtab SciML NN inputs and outputs.

HybridizationTable([hybridizations])

PEtab SciML hybridization table.

NeuralNetConfig(*, location, ...)

A neural net in the PEtab SciML problem configuration.

SciMLConfig(*[, version, array_files, ...])

The extended configuration of a PEtab SciML problem.

SciMLExt([neural_networks, ...])

SciML extension runtime state.

class petab.v2.extensions.sciml.Hybridization(*, targetId: str, targetValue: Basic, **extra_data: Any)[source]

Bases: BaseModel

Assigns PEtab SciML NN inputs and outputs.

target_id: str

The target ID.

target_value: sp.Basic

The target value.

class petab.v2.extensions.sciml.HybridizationTable(hybridizations: list[Hybridization] = None, **kwargs)[source]

Bases: object

PEtab SciML hybridization table.

base_path: AnyUrl | Path | None
property elements: list[Hybridization]
classmethod from_df(df: DataFrame, **kwargs) HybridizationTable[source]

Create a HybridizationTable from a DataFrame.

classmethod from_tsv(file_path: str | Path, base_path: str | Path | None = None) HybridizationTable[source]

Create a HybridizationTable from a TSV file.

get(target_id, default=None)[source]

Get a hybridization by target ID or return a default value.

hybridizations: list[Hybridization]
rel_path: AnyUrl | Path | None
to_df() DataFrame[source]

Convert the HybridizationTable to a DataFrame.

to_tsv(file_path: str | Path = None) None[source]

Write the table to a TSV file.

class petab.v2.extensions.sciml.NeuralNetConfig(*, location: AnyUrl | Path, pre_initialization: bool, format: str)[source]

Bases: BaseModel

A neural net in the PEtab SciML problem configuration.

format: str
location: AnyUrl | Path
pre_initialization: bool
class petab.v2.extensions.sciml.SciMLConfig(*, version: str = '0.1.0', array_files: list[AnyUrl | Path] = [], hybridization_files: list[AnyUrl | Path] = [], neural_networks: dict[str, NeuralNetConfig] | None = {})[source]

Bases: BaseModel

The extended configuration of a PEtab SciML problem.

array_files: list[AnyUrl | Path]

The paths to the array data files.

hybridization_files: list[AnyUrl | Path]

The paths to the hybridization tables.

neural_networks: dict[str, NeuralNetConfig] | None

The neural network IDs and info.

to_yaml() dict[source]

Return a YAML-serializable dict with Paths converted to strings.

version: str

The PEtab SciML format version.

class petab.v2.extensions.sciml.SciMLExt(neural_networks: list | None = None, hybridization_tables: list[HybridizationTable] | None = None, array_data_files: list | None = None)[source]

Bases: object

SciML extension runtime state.

Accessible as Problem.extensions.sciml.

add_array_data_from_dict(array_data: dict)[source]

Add array data from a dictionary.

add_array_data_from_hdf5(file_path: str | Path, base_path: str | Path | None = None)[source]

Add array data from an HDF5 file.

add_hybridization(target_id: str, target_value: str)[source]

Add a hybridization entry.

If there is more than one hybridization table the entry is added to the last one.

Parameters:
  • target_id – The ID of the target entity in the PEtab problem or neural network model

  • target_value – The value that is assigned to the target id.

add_neural_network_from_dict(model_id: str, nn_dict: dict)[source]

Add a neural network from a dictionary.

add_neural_network_from_yaml(model_id: str, file_path: str | Path, base_path: str | Path | None = None)[source]

Add a neural network from a YAML file.

array_data_files: list
static from_config(config, base_path: str | Path | None = None) SciMLExt[source]

Construct a SciMLExt from a ProblemConfig.

Parameters:
  • config – A ProblemConfig whose extensions[EXT_ID_SCIML] entry is a SciMLConfig.

  • base_path – Base path used to resolve relative file paths.

property hybridization_df: DataFrame | None

Combined hybridization tables as a single DataFrame.

hybridization_tables: list[HybridizationTable]
property hybridizations: list[Hybridization]

Flat list of all hybridizations across all hybridization tables.

neural_networks: list