Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ def pytest_addoption(parser):
def pytest_configure(config):
"""Workaround because store_true doesn't work"""
pytest.coverage = config.option.coverage == True

50 changes: 36 additions & 14 deletions tests/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,46 @@
import os
import json
import pandas as pd
import pytest

import sys
sys.path.append(os.path.dirname(__file__))

from .utils import run_test_case_by_name, get_result, run_with_reference, RTOL_FLOW, RTOL_PRES


def test_all():
@pytest.mark.parametrize("testfile", ['chamber_elastance_inductor.json',
'steadyFlow_R_R.json',
'pulsatileFlow_R_coronary_cycle_error.json',
'pulsatileFlow_R_coronary.json',
'coupledBlock_closedLoopHeart_withCoronaries.json',
'pulsatileFlow_R_RCR_derivative.json',
'steadyFlow_bifurcationR_R1.json',
'closedLoopHeart_singleVessel.json',
'pulsatileFlow_R_RCR_variable.json',
'coupledBlock_closedLoopHeart_singleVessel.json',
'steadyFlow_R_steadyPressure.json',
'steadyFlow_bifurcationR_R1_blockNames.json',
'pulsatileFlow_R_RCR.json',
'closedLoopHeart_withCoronaries.json',
'steadyFlow_RL_R.json',
'steadyFlow_bifurcationR_R2.json',
'pulsatileFlow_R_RCR_derivative_variable.json',
'steadyFlow_confluenceR_R.json',
'steadyFlow_R_RCR.json',
'steadyFlow_stenosis_R.json',
'pulsatileFlow_R_RCR_mean.json',
'pulsatileFlow_R_RCR_mean_derivative.json',
'pulsatileFlow_CStenosis_steadyPressure.json',
'pulsatileFlow_R_RCR_mean_variable.json',
'steadyFlow_RC_R.json',
'steadyFlow_R_coronary.json',
'steadyFlow_RLC_R.json',
'steadyFlow_blood_vessel_junction.json',
'valve_tanh.json',
'pulsatileFlow_bifurcationR_RCR_cycle_error.json',
'pulsatileFlow_R_RCR_mean_derivative_variable.json'
])
def test_solver(testfile):
'''
run all test cases and compare against stored reference solution
'''
Expand All @@ -20,16 +52,6 @@ def test_all():

results_dir = os.path.join(this_file_dir, 'cases', 'results')

testfiles = [f for f in os.listdir(os.path.join(this_file_dir, 'cases')) if os.path.isfile(os.path.join(this_file_dir, 'cases', f))]

# we only want to test the solver, not the calibrator
testfiles.remove("steadyFlow_calibration.json")

for file in testfiles:

with open(os.path.join(this_file_dir, 'cases', file), "r") as f:
config = json.load(f)

ref = pd.read_json(os.path.join(results_dir, 'result_' + file))
ref = pd.read_json(os.path.join(results_dir, f'result_{testfile}'))

run_with_reference(ref, config)
run_with_reference(ref, os.path.join(this_file_dir, 'cases', testfile))
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def run_with_reference(
):


res = pysvzerod.simulate(test_config)
res, config = execute_pysvzerod(test_config, "solver")

if res.shape[1] == 6:
# we have a result with fields [name, time, p_in, p_out, q_in, q_out]
Expand Down