diff --git a/tests/test_confidence_intervals/results.py b/tests/test_confidence_intervals/results.py new file mode 100644 index 0000000000..f2f03137bf --- /dev/null +++ b/tests/test_confidence_intervals/results.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import sys +import numpy as np + +# import statepoint +sys.path.append('../../src/utils') +import statepoint + +# read in statepoint file +sp = statepoint.StatePoint('statepoint.10.binary') +sp.read_results() + +# extract tally results and convert to vector +results = sp.tallies[0].results +shape = results.shape +size = (np.product(shape)) +results = np.reshape(results, size) + +# set up output string +outstr = '' + +# write out k-combined +outstr += 'k-combined:\n' +outstr += "{0:10.8f} {1:10.8f}\n".format(sp.k_combined[0], sp.k_combined[1]) + +# write out tally results +outstr += 'tallies:\n' +for item in results: + outstr += "{0:10.8f}\n".format(item) + +# write results to file +with open('results_test.dat','w') as fh: + fh.write(outstr) diff --git a/tests/test_confidence_intervals/results_true.dat b/tests/test_confidence_intervals/results_true.dat new file mode 100644 index 0000000000..0e91748dd1 --- /dev/null +++ b/tests/test_confidence_intervals/results_true.dat @@ -0,0 +1,5 @@ +k-combined: +0.29618376 0.01254762 +tallies: +63.10626773 +503.50685224 diff --git a/tests/test_confidence_intervals/test_confidence_intervals.py b/tests/test_confidence_intervals/test_confidence_intervals.py index ae387dbb11..33590e0e28 100644 --- a/tests/test_confidence_intervals/test_confidence_intervals.py +++ b/tests/test_confidence_intervals/test_confidence_intervals.py @@ -2,6 +2,7 @@ import os from subprocess import Popen, STDOUT, PIPE +import filecmp pwd = os.path.dirname(__file__) @@ -21,6 +22,10 @@ def test_created_statepoint(): def test_created_output(): assert os.path.exists(pwd + '/tallies.out') +def test_results(): + os.system('python results.py') + assert filecmp.cmp('results_test.dat', 'results_true.dat') + def teardown(): output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out'] for f in output: diff --git a/tests/update_results.py b/tests/update_results.py index d435701a70..1cef0ae275 100644 --- a/tests/update_results.py +++ b/tests/update_results.py @@ -27,5 +27,3 @@ for root, dirs, files in os.walk('.'): # Go back a directory os.chdir('..') - - exit()