updated score_MT test

This commit is contained in:
Bryan Herman 2013-08-12 16:19:22 -04:00
parent d3a4b49d63
commit cc795f7fa9
3 changed files with 79 additions and 1 deletions

View file

@ -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)

View file

@ -0,0 +1,35 @@
k-combined:
1.63626998 0.13749537
tallies:
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00779560
0.00002384
0.00779560
0.00002384
0.32663574
0.02158530
1.33715285
0.36231473
0.00050120
0.00000015
0.00050120
0.00000015
0.03041830
0.00018839
0.01659841
0.00006394
0.00000000
0.00000000
0.00000000
0.00000000
0.00010215
0.00000000
0.06300369
0.00081033

View file

@ -2,6 +2,7 @@
import os
from subprocess import Popen, STDOUT, PIPE
import filecmp
pwd = os.path.dirname(__file__)
@ -21,8 +22,16 @@ def test_statepoint_exists():
def test_output_exists():
assert os.path.exists(pwd + '/tallies.out')
def test_results():
os.system('python results.py')
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
if not compare:
os.system('cp results_test.dat results_error.dat')
assert compare
def teardown():
output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out']
output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out',
pwd + '/results_test.dat']
for f in output:
if os.path.exists(f):
os.remove(f)