Skip to content

Commit

Permalink
Update test case with parallel model
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnel committed Jan 28, 2024
1 parent 0192b9b commit 0e68c1b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 55 deletions.
58 changes: 11 additions & 47 deletions examples/01-fluorescence/analysis.ipynb

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions examples/01-fluorescence/scheme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ library:
(s4, s3): rates_global.3
(s4, s4): rates_global.4

parallel_model: # TJust a name, could be MyDescriptiveModelName
type: kinetic
rates:
(s1, s1): rates_global.1
(s2, s2): rates_global.2
(s3, s3): rates_global.3
(s4, s4): rates_global.4

experiments:
experiment1: # Just a name, could be MyFirstExperiment
datasets:
Expand All @@ -20,3 +28,16 @@ experiments:
width: irf.width
backsweep: 13200.0 # backsweep.period
residual_function: non_negative_least_squares

experiment2: # Just a name, could be MyFirstExperiment
datasets:
dataset2: # Should be possible to uses dataset1 here as well
elements: [parallel_model]
activation:
- type: gaussian
compartments:
s1: 1.0 # input.1
center: irf.center
width: irf.width
backsweep: 13200.0 # backsweep.period
residual_function: non_negative_least_squares
Empty file added tests/examples/__init__.py
Empty file.
29 changes: 21 additions & 8 deletions tests/examples/test_01_fluorescence.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
from glotaran.io import load_dataset, load_parameters, load_scheme
from __future__ import annotations

from pathlib import Path
from pytest import approx

from pyreporoot import project_root
from pytest import approx

from glotaran.io import load_dataset
from glotaran.io import load_parameters
from glotaran.io import load_scheme

repo_root = Path(project_root(__file__, root_files=[".git", "pyproject.toml"]))
example_folder = repo_root / "examples/01-fluorescence"


def test_01_fluorescence():
fit_scheme = load_scheme(example_folder/"scheme.yaml", format_name="yml")
parameters = load_parameters(example_folder/"parameters.yaml")
data_path = example_folder/"data/data.ascii"
fit_scheme.load_data({"dataset1": load_dataset(data_path)})
fit_scheme = load_scheme(example_folder / "scheme.yaml", format_name="yml")
parameters = load_parameters(example_folder / "parameters.yaml")
data_path = example_folder / "data/data.ascii"
fit_scheme.load_data(
{"dataset1": load_dataset(data_path), "dataset2": load_dataset(data_path)}
)
result = fit_scheme.optimize(parameters=parameters)
assert result is not None
assert result.data['dataset1'].root_mean_square_error == approx(43.98496093)
assert result.data["dataset1"].root_mean_square_error == approx(43.98496093)

# Compare the 'SAS' (EAS / DAS) for the both cases:
# result.data['dataset1'].species_associated_estimation
# result.data['dataset2'].species_associated_estimation
# Currently seems incorrect.


if __name__ == "__main__":
test_01_fluorescence()

0 comments on commit 0e68c1b

Please sign in to comment.