study
behaviour.study
What a SimulationStudy record does: load itself, walk what it nests, run, report and cite.
A study that declares studies is a study-of-studies — it aggregates other studies and owns whatever experiments, analyses and figures belong to none of them — so every operation here recurses. The nested studies are records of the same class, which is what makes the nesting self-similar to any depth, and is why nothing here has to promote a nested study to a different class before it can run.
Classes
| Name | Description |
|---|---|
| SimulationStudyBehaviour | A collection of related SimulationExperiments with shared provenance. |
SimulationStudyBehaviour
behaviour.study.SimulationStudyBehaviour()A collection of related SimulationExperiments with shared provenance.
Aggregates the experiments behind a published paper or analysis (model, DOI, year, citation, dataset) into one declarative YAML/Pydantic object. Load with from_db(name) for curated studies, from_file(path) for local YAML, or from_openminds(...) for JSON-LD provenance graphs.
A study that declares studies is a study-of-studies: it aggregates other studies and owns whatever experiments, analyses and figures belong to none of them. The nested studies are SimulationStudy objects like this one, so the nesting is self-similar and recurses to any depth.
The most-used entry points are get_experiment(id) to materialise a single run, cite() for the formatted citation, and to_openminds(...) for JSON-LD export.
Methods
| Name | Description |
|---|---|
| cite | Return the formatted citation for this study. |
| experiment_ids | The declared experiment ids, in recipe order. |
| from_datamodel | Wrap a generated datamodel instance as a SimulationStudy. |
| from_file | Load a study from a local YAML file. |
| from_openminds | Create a SimulationStudy from openMINDS JSON-LD. |
| get_experiment | Retrieve a single experiment by its declared id. |
| nested_studies | This study’s immediate sub-studies as (label, study) pairs. |
| report | Render one Methods section for the whole study. |
| run | Run the whole study in process — every experiment, its analyses, its declared figures — and return what it produced. |
| study_label | The name this study is addressed by — in a --skip list, a count: binding, or a run’s progress line. |
| to_openminds | Export study to openMINDS JSON-LD format. |
| walk_studies | Every study in this tree, each sub-study before the study that holds it. |
cite
behaviour.study.SimulationStudyBehaviour.cite()Return the formatted citation for this study.
Returns
| Name | Type | Description |
|---|---|---|
The citation string resolved from the study’s key. |
experiment_ids
behaviour.study.SimulationStudyBehaviour.experiment_ids()The declared experiment ids, in recipe order.
from_datamodel
behaviour.study.SimulationStudyBehaviour.from_datamodel(datamodel)Wrap a generated datamodel instance as a SimulationStudy.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| datamodel | A datamodel-level study whose fields are copied into the user-facing class. | required |
Returns
| Name | Type | Description |
|---|---|---|
A SimulationStudy with the same field values as datamodel. |
from_file
behaviour.study.SimulationStudyBehaviour.from_file(filepath)Load a study from a local YAML file.
The document is read once, through yaml_loader.load_as_dict, which resolves anchors and !include fragments and normalises exactly as every other load path does, and it serves three readers. The study is constructed from a copy of it. Its raw experiment dicts are kept, so an experiment can be materialised through SimulationExperiment.from_dict, the path that iri-sources dynamics and coupling from the registry, which constructing the record does not, and that keeps every mapping in its declared order. And the nested studies are wired from it rather than by reloading each recipe: !include has already read every one of them, and a tree of twenty-odd studies parsed twice costs seconds on every command that only wants to know what it contains.
The resolved absolute path is stored on the returned instance so that experiments materialised later can locate sibling data files, and the recipe’s callable code is made importable — an explicit code_source when declared, else the code/ directory beside the YAML — so custom builders and callables resolve by bare module name.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| filepath | Path to the study YAML file. | required |
Returns
| Name | Type | Description |
|---|---|---|
A SimulationStudy parsed from the file. |
from_openminds
behaviour.study.SimulationStudyBehaviour.from_openminds(source)Create a SimulationStudy from openMINDS JSON-LD.
Parameters
source : str or dict Either a file path to a JSON-LD file, or a dict containing JSON-LD data.
Returns:
SimulationStudy New instance constructed from the openMINDS data.
Example:
study = SimulationStudy.from_openminds(“study.jsonld”) study = SimulationStudy.from_openminds({“type?”: “tvbo:SimulationStudy”, …})
get_experiment
behaviour.study.SimulationStudyBehaviour.get_experiment(experiment_id)Retrieve a single experiment by its declared id.
nested_studies
behaviour.study.SimulationStudyBehaviour.nested_studies()This study’s immediate sub-studies as (label, study) pairs.
A sub-study spliced in by !include carries the file it came from, so it keeps its own _source_file and therefore its own results root, code directory and relative references — which is the whole point of nesting by pointer rather than by copy. A sub-study written inline has no file of its own and inherits this study’s.
Wired once when the study is loaded, so the tree is parsed exactly once however often it is walked.
report
behaviour.study.SimulationStudyBehaviour.report(
format='markdown',
part='main',
level=2,
equations='semantic',
orient='auto',
experiments=None,
outputfile=None,
derivative_notation='dot',
mul_symbol=None,
)Render one Methods section for the whole study.
Experiments that share a model share its equations and its symbol table; a model that merely varies a sibling contributes only its delta. Everything the experiments hold in common is stated once, and the comparison table carries only what actually differs — so a seven-experiment study stops emitting seven copies of the same six equations and three copies of the same parameter table.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| format | str | markdown / md (\\tag numbering), qmd (Quarto {#eq-…} / {#tbl-…} anchors), or pdf. |
'markdown' |
| part | str | main, supplementary or all — which experiments carry their full paragraph, read from each experiment’s declared part. Every experiment appears in the comparison table regardless, so a demoted one is still visible; part never changes what runs. |
'main' |
| level | int | Heading depth of the model sections, so the block nests under the section that hosts it; experiments sit one level deeper. | 2 |
| equations | str | semantic anchors on model and variable (stable when an experiment is inserted), sequential anchors on the number, none leaves equations unnumbered. |
'semantic' |
| orient | str | auto keeps the experiment table narrow, or pin it with rows / columns (where the experiments go) so the Methods keeps its shape. |
'auto' |
| experiments | Optional explicit ids to describe; defaults to all of them. | None |
|
| outputfile | str | None | Write the render here; the extension (.md / .qmd / .pdf) overrides format. |
None |
| derivative_notation | str | dot for :math:\\dot x, anything else for dx/dt. |
'dot' |
| mul_symbol | str | None | Passed to sympy.latex. |
None |
run
behaviour.study.SimulationStudyBehaviour.run(
root=None,
*,
backend=None,
figures=True,
)Run the whole study in process — every experiment, its analyses, its declared figures — and return what it produced.
The Python entry point to what tvbo run <recipe>.yaml does from a shell, through the same function (:func:tvbo.run.study.run_study), so a notebook and the CLI cannot drift apart: every container the run writes records the run in its sidecar either way. Use it wherever the containers are wanted as objects rather than as files: a docs page, a notebook, an embedding application.
A study-of-studies runs through the same tree walk the CLI takes: every nested study first, in its own directory, then this study’s own content, then the results manifest — and each nested study’s own StudyResult comes back under StudyResult.studies.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| root | The study root this run writes into — containers land in its results directory, figures in its figures directory, and every layer’s used: resolves against it. Defaults to the recipe’s own directory, which is what the CLI uses; point it elsewhere to keep a run’s outputs out of the tree the recipe is committed in. |
None |
|
| backend | str | None | Backend for each experiment that does not declare its own. | None |
| figures | bool | Render the study’s declared figures: once the experiments finish. |
True |
Returns
| Name | Type | Description |
|---|---|---|
A StudyResult — the experiments’ containers by id, the analyses by name, the rendered figures, and any nested studies. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | The study was built in memory, so there is no recipe to resolve its relative paths against. | |
| tvbo.run.study.StudyRunError | The run refused its input or could not finish; the message says why. |
study_label
behaviour.study.SimulationStudyBehaviour.study_label()The name this study is addressed by — in a --skip list, a count: binding, or a run’s progress line.
The citekey first, then the recipe’s own filename, and only then label: a study’s label is a human-readable title and is frequently a whole sentence, which no one can type into --skip and which reads as noise in a progress line.
to_openminds
behaviour.study.SimulationStudyBehaviour.to_openminds(
filepath=None,
base_id=None,
include_context=True,
)Export study to openMINDS JSON-LD format.
Parameters
filepath : str, optional If provided, write JSON-LD to this file path. base_id : str, optional Base URI for generating id? values (e.g., “https://example.org/studies”). If not provided and study has a DOI, uses the DOI as id?. include_context : bool Whether to include the context? in the output. Default True.
Returns:
dict OpenMINDS-compatible JSON-LD dictionary.
Example:
study = SimulationStudy.from_file(“study.yaml”) jsonld = study.to_openminds() study.to_openminds(“output.jsonld”, base_id=“https://example.org”)
walk_studies
behaviour.study.SimulationStudyBehaviour.walk_studies(include_self=True)Every study in this tree, each sub-study before the study that holds it.
Depth first with the holder last, because that is the order the content depends in: a study’s own analyses and figures may read what its sub-studies produced, never the other way round. include_self drops the outermost study, which is how a caller runs the tree without re-running the study it started from.
Functions
| Name | Description |
|---|---|
| hand_down_theme | Give every figure of study, and of the studies nested in it, the theme it is drawn in. |
hand_down_theme
behaviour.study.hand_down_theme(study, inherited=None)Give every figure of study, and of the studies nested in it, the theme it is drawn in.
A study states its look once, in theme, and each figure in its figures list takes it, whichever file the figure record was included from: a figure is drawn in the look of the study that prints it. A nested study that states no theme takes its parent’s, so a paper’s rule reaches the studies it aggregates, and one that states its own keeps it.