Skip to content

Commit

Permalink
regen hash script for pypesto test
Browse files Browse the repository at this point in the history
  • Loading branch information
dilpath committed Nov 11, 2024
1 parent 54145d3 commit 6951e8b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/pypesto/regenerate_model_hashes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from pathlib import Path

import pandas as pd
import yaml

import petab_select
from petab_select import (
MODEL_HASH,
MODEL_ID,
MODEL_SUBSPACE_ID,
MODEL_SUBSPACE_INDICES,
PREDECESSOR_MODEL_HASH,
)

test_cases_path = Path(__file__).resolve().parent.parent.parent / 'test_cases'


for test_case_path in test_cases_path.glob('*'):
petab_select_problem = petab_select.Problem.from_yaml(
test_case_path / 'petab_select_problem.yaml',
)
expected_model_yaml = test_case_path / 'expected.yaml'

with open(expected_model_yaml, "r") as f:
model_dict = yaml.safe_load(f)

model = petab_select_problem.model_space.model_subspaces[
model_dict[MODEL_SUBSPACE_ID]
].indices_to_model(model_dict[MODEL_SUBSPACE_INDICES])
model_dict[MODEL_ID] = str(model.model_id)
model_dict[MODEL_HASH] = str(model.get_hash())
model_dict[PREDECESSOR_MODEL_HASH] = None

with open(expected_model_yaml, "w") as f:
yaml.safe_dump(model_dict, f)

0 comments on commit 6951e8b

Please sign in to comment.