mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
PEP8 fixes on Python scripts.
This commit is contained in:
parent
3f47b31784
commit
1bfbde7cf0
7 changed files with 66 additions and 50 deletions
|
|
@ -79,7 +79,8 @@ tests = ['compile', 'normal', 'debug', 'optimize',
|
|||
'phdf5-omp', 'phdf5-omp-debug', 'phdf5-omp-optimize',
|
||||
'petsc', 'petsc-debug', 'petsc-optimize',
|
||||
'phdf5-petsc', 'phdf5-petsc-debug', 'phdf5-petsc-optimize',
|
||||
'omp-phdf5-petsc', 'omp-phdf5-petsc-debug', 'omp-phdf5-petsc-optimize']
|
||||
'omp-phdf5-petsc', 'omp-phdf5-petsc-debug',
|
||||
'omp-phdf5-petsc-optimize']
|
||||
if len(sys.argv) > 1:
|
||||
flags = [i for i in sys.argv[1:] if i.startswith('-')]
|
||||
tests_ = [i for i in sys.argv[1:] if not i.startswith('-')]
|
||||
|
|
@ -138,7 +139,7 @@ for name in tests:
|
|||
'petsc', 'petsc-debug', 'petsc-optimize',
|
||||
'phdf5-petsc', 'phdf5-petsc-debug', 'phdf5-petsc-optimize',
|
||||
'omp-phdf5-petsc', 'omp-phdf5-petsc-debug',
|
||||
'omp-phdf5-petsc-optimize']:
|
||||
'omp-phdf5-petsc-optimize']:
|
||||
run_suite(name=name, mpi=True)
|
||||
|
||||
# print out summary of results
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ results4 = np.reshape(results4, size4)
|
|||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
|
@ -42,41 +42,41 @@ outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
|||
# write out tally results
|
||||
outstr += 'tally 1:\n'
|
||||
for item in results1:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 2:\n'
|
||||
for item in results2:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 3:\n'
|
||||
for item in results3:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 4:\n'
|
||||
for item in results4:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write out cmfd answers
|
||||
outstr += 'cmfd indices\n'
|
||||
for item in sp.cmfd_indices:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'k cmfd\n'
|
||||
for item in sp.k_cmfd:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd entropy\n'
|
||||
for item in sp.cmfd_entropy:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd balance\n'
|
||||
for item in sp.cmfd_balance:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd dominance ratio\n'
|
||||
for item in sp.cmfd_dominance:
|
||||
outstr += "{0:10.3E}\n".format(item)
|
||||
outstr += "{0:10.3E}\n".format(item)
|
||||
outstr += 'cmfd openmc source comparison\n'
|
||||
for item in sp.cmfd_srccmp:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd source\n'
|
||||
cmfdsrc = np.reshape(sp.cmfd_src, np.product(sp.cmfd_indices), order='F')
|
||||
for item in cmfdsrc:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
with open('results_test.dat', 'w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
|
|||
|
|
@ -14,17 +14,19 @@ pwd = os.path.dirname(__file__)
|
|||
|
||||
skipAll = False
|
||||
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
global skipAll
|
||||
skipAll = False
|
||||
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
returncode = proc.wait()
|
||||
|
|
@ -36,6 +38,7 @@ def test_run():
|
|||
raise SkipTest
|
||||
assert returncode == 0
|
||||
|
||||
|
||||
def test_created_statepoint():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
|
|
@ -43,11 +46,13 @@ def test_created_statepoint():
|
|||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
|
||||
|
||||
def test_output_exists():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
|
||||
|
||||
def test_results():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
|
|
@ -55,9 +60,10 @@ def test_results():
|
|||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.20.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
|
|
@ -65,4 +71,3 @@ def teardown():
|
|||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ results4 = np.reshape(results4, size4)
|
|||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
|
@ -42,41 +42,41 @@ outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
|||
# write out tally results
|
||||
outstr += 'tally 1:\n'
|
||||
for item in results1:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 2:\n'
|
||||
for item in results2:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 3:\n'
|
||||
for item in results3:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 4:\n'
|
||||
for item in results4:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write out cmfd answers
|
||||
outstr += 'cmfd indices\n'
|
||||
for item in sp.cmfd_indices:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'k cmfd\n'
|
||||
for item in sp.k_cmfd:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd entropy\n'
|
||||
for item in sp.cmfd_entropy:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd balance\n'
|
||||
for item in sp.cmfd_balance:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd dominance ratio\n'
|
||||
for item in sp.cmfd_dominance:
|
||||
outstr += "{0:10.3E}\n".format(item)
|
||||
outstr += "{0:10.3E}\n".format(item)
|
||||
outstr += 'cmfd openmc source comparison\n'
|
||||
for item in sp.cmfd_srccmp:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd source\n'
|
||||
cmfdsrc = np.reshape(sp.cmfd_src, np.product(sp.cmfd_indices), order='F')
|
||||
for item in cmfdsrc:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
with open('results_test.dat', 'w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
|
|||
|
|
@ -14,17 +14,19 @@ pwd = os.path.dirname(__file__)
|
|||
|
||||
skipAll = False
|
||||
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
global skipAll
|
||||
skipAll = False
|
||||
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
returncode = proc.wait()
|
||||
|
|
@ -36,6 +38,7 @@ def test_run():
|
|||
raise SkipTest
|
||||
assert returncode == 0
|
||||
|
||||
|
||||
def test_created_statepoint():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
|
|
@ -43,11 +46,13 @@ def test_created_statepoint():
|
|||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
|
||||
|
||||
def test_output_exists():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
|
||||
|
||||
def test_results():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
|
|
@ -55,9 +60,10 @@ def test_results():
|
|||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.20.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
|
|
@ -65,4 +71,3 @@ def teardown():
|
|||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ results4 = np.reshape(results4, size4)
|
|||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
|
@ -42,41 +42,41 @@ outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
|||
# write out tally results
|
||||
outstr += 'tally 1:\n'
|
||||
for item in results1:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 2:\n'
|
||||
for item in results2:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 3:\n'
|
||||
for item in results3:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 4:\n'
|
||||
for item in results4:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write out cmfd answers
|
||||
outstr += 'cmfd indices\n'
|
||||
for item in sp.cmfd_indices:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'k cmfd\n'
|
||||
for item in sp.k_cmfd:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd entropy\n'
|
||||
for item in sp.cmfd_entropy:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd balance\n'
|
||||
for item in sp.cmfd_balance:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd dominance ratio\n'
|
||||
for item in sp.cmfd_dominance:
|
||||
outstr += "{0:10.3E}\n".format(item)
|
||||
outstr += "{0:10.3E}\n".format(item)
|
||||
outstr += 'cmfd openmc source comparison\n'
|
||||
for item in sp.cmfd_srccmp:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd source\n'
|
||||
cmfdsrc = np.reshape(sp.cmfd_src, np.product(sp.cmfd_indices), order='F')
|
||||
for item in cmfdsrc:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
with open('results_test.dat', 'w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
|
|||
|
|
@ -13,17 +13,19 @@ pwd = os.path.dirname(__file__)
|
|||
|
||||
skipAll = False
|
||||
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
global skipAll
|
||||
skipAll = False
|
||||
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
returncode = proc.wait()
|
||||
|
|
@ -35,6 +37,7 @@ def test_run():
|
|||
raise SkipTest
|
||||
assert returncode == 0
|
||||
|
||||
|
||||
def test_created_statepoint():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
|
|
@ -42,11 +45,13 @@ def test_created_statepoint():
|
|||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
|
||||
|
||||
def test_output_exists():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
|
||||
|
||||
def test_results():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
|
|
@ -54,9 +59,10 @@ def test_results():
|
|||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.20.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
|
|
@ -64,4 +70,3 @@ def teardown():
|
|||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue