Skip to content

Commit 5c4900c

Browse files
committed
test(parallel): add unit test to check parallel and sequential execution produce equal results
1 parent 4599bf0 commit 5c4900c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_unittest_model.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,23 @@ def test_exponentional():
413413
assert not np.array_equal(sample1, sample2), (
414414
'Samples with different random seeds should not be equal.'
415415
)
416+
417+
418+
def test_parallel():
419+
"""
420+
Check that sequential and parallel execution produce consistent results.
421+
"""
422+
# Sequential (1 core) and parallel (-1 cores) execution
423+
results = {}
424+
for mode, cores in [('seq', 1), ('par', -1)]:
425+
param = Defaults()
426+
param.cores = cores
427+
trial = Trial(param)
428+
results[mode] = trial.run_single(run=0)
429+
430+
# Verify results are identical
431+
pd.testing.assert_frame_equal(
432+
results['seq']['patient'], results['par']['patient'])
433+
pd.testing.assert_frame_equal(
434+
results['seq']['interval_audit'], results['par']['interval_audit'])
435+
assert results['seq']['trial'] == results['par']['trial']

0 commit comments

Comments
 (0)