Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
joernweissenborn committed Oct 16, 2021
1 parent a14fcdd commit f8ec2ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 38 deletions.
46 changes: 17 additions & 29 deletions glotaran/builtin/io/yml/test/test_save_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING

from glotaran.examples.sequential import model
from glotaran.examples.sequential_spectral_decay import MODEL
from glotaran.io import load_model
from glotaran.io import save_model

Expand All @@ -11,47 +11,35 @@


want = """dataset:
dataset1:
dataset_1:
group: default
initial_concentration: j1
irf: irf1
irf: gaussian_irf
megacomplex:
- m1
- megacomplex_sequential_decay
dataset_groups:
default:
link_clp: null
residual_function: variable_projection
default-megacomplex: decay
initial_concentration:
j1:
compartments:
- s1
- s2
- s3
exclude_from_normalize: []
parameters:
- j.1
- j.0
- j.0
default-megacomplex: decay-sequential
irf:
irf1:
gaussian_irf:
backsweep: false
center: irf.center
normalize: true
type: gaussian
width: irf.width
k_matrix:
k1:
matrix:
(s2, s1): kinetic.1
(s3, s2): kinetic.2
(s3, s3): kinetic.3
megacomplex:
m1:
megacomplex_sequential_decay:
compartments:
- species_1
- species_2
- species_3
dimension: time
k_matrix:
- k1
type: decay
rates:
- rates.species_1
- rates.species_2
- rates.species_3
type: decay-sequential
"""


Expand All @@ -61,7 +49,7 @@ def test_save_model(
"""Check all files exist."""

model_path = tmp_path / "testmodel.yml"
save_model(file_name=model_path, format_name="yml", model=model)
save_model(file_name=model_path, format_name="yml", model=MODEL)

assert model_path.is_file()
assert model_path.read_text() == want
Expand Down
18 changes: 9 additions & 9 deletions glotaran/builtin/io/yml/test/test_save_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import xarray as xr

from glotaran.examples.sequential import dataset
from glotaran.examples.sequential import model
from glotaran.examples.sequential import parameter
from glotaran.examples.sequential_spectral_decay import DATASET
from glotaran.examples.sequential_spectral_decay import MODEL
from glotaran.examples.sequential_spectral_decay import PARAMETER
from glotaran.io import load_scheme
from glotaran.io import save_dataset
from glotaran.io import save_model
Expand Down Expand Up @@ -35,16 +35,16 @@

def test_save_scheme(tmp_path: Path):
scheme = Scheme(
model,
parameter,
{"dataset_1": dataset},
MODEL,
PARAMETER,
{"dataset_1": DATASET},
model_file="m.yml",
parameters_file="p.csv",
data_files={"dataset_1": "d.nc"},
)
save_model(model, tmp_path / "m.yml")
save_parameters(parameter, tmp_path / "p.csv")
save_dataset(dataset, tmp_path / "d.nc")
save_model(MODEL, tmp_path / "m.yml")
save_parameters(PARAMETER, tmp_path / "p.csv")
save_dataset(DATASET, tmp_path / "d.nc")
scheme_path = tmp_path / "testscheme.yml"
save_scheme(file_name=scheme_path, format_name="yml", scheme=scheme)

Expand Down

0 comments on commit f8ec2ad

Please sign in to comment.