diff --git a/tests/test_asymmetric_lattice/test_asymmetric_lattice.py b/tests/test_asymmetric_lattice/test_asymmetric_lattice.py
index 6684087bc3..58c1b22ab5 100644
--- a/tests/test_asymmetric_lattice/test_asymmetric_lattice.py
+++ b/tests/test_asymmetric_lattice/test_asymmetric_lattice.py
@@ -91,5 +91,5 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = AsymmetricLatticeTestHarness('statepoint.10.h5', True)
+ harness = AsymmetricLatticeTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_cmfd_feed/test_cmfd_feed.py b/tests/test_cmfd_feed/test_cmfd_feed.py
index 3bc5f61743..17bebf68c0 100644
--- a/tests/test_cmfd_feed/test_cmfd_feed.py
+++ b/tests/test_cmfd_feed/test_cmfd_feed.py
@@ -7,5 +7,5 @@ from testing_harness import CMFDTestHarness
if __name__ == '__main__':
- harness = CMFDTestHarness('statepoint.20.*', True)
+ harness = CMFDTestHarness('statepoint.20.h5')
harness.main()
diff --git a/tests/test_cmfd_nofeed/test_cmfd_nofeed.py b/tests/test_cmfd_nofeed/test_cmfd_nofeed.py
index 3bc5f61743..17bebf68c0 100644
--- a/tests/test_cmfd_nofeed/test_cmfd_nofeed.py
+++ b/tests/test_cmfd_nofeed/test_cmfd_nofeed.py
@@ -7,5 +7,5 @@ from testing_harness import CMFDTestHarness
if __name__ == '__main__':
- harness = CMFDTestHarness('statepoint.20.*', True)
+ harness = CMFDTestHarness('statepoint.20.h5')
harness.main()
diff --git a/tests/test_complex_cell/test_complex_cell.py b/tests/test_complex_cell/test_complex_cell.py
index 1777db993e..0669165e25 100755
--- a/tests/test_complex_cell/test_complex_cell.py
+++ b/tests/test_complex_cell/test_complex_cell.py
@@ -6,5 +6,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*', True)
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_confidence_intervals/test_confidence_intervals.py b/tests/test_confidence_intervals/test_confidence_intervals.py
index ed6addec45..b04fcc6eba 100755
--- a/tests/test_confidence_intervals/test_confidence_intervals.py
+++ b/tests/test_confidence_intervals/test_confidence_intervals.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*', True)
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_create_fission_neutrons/test_create_fission_neutrons.py b/tests/test_create_fission_neutrons/test_create_fission_neutrons.py
index 4434502d67..87abeda7fe 100755
--- a/tests/test_create_fission_neutrons/test_create_fission_neutrons.py
+++ b/tests/test_create_fission_neutrons/test_create_fission_neutrons.py
@@ -70,5 +70,5 @@ class CreateFissionNeutronsTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = CreateFissionNeutronsTestHarness('statepoint.10.h5', True)
+ harness = CreateFissionNeutronsTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_density/test_density.py b/tests/test_density/test_density.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_density/test_density.py
+++ b/tests/test_density/test_density.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_diff_tally/test_diff_tally.py b/tests/test_diff_tally/test_diff_tally.py
index 9343e59138..02798e70e0 100644
--- a/tests/test_diff_tally/test_diff_tally.py
+++ b/tests/test_diff_tally/test_diff_tally.py
@@ -126,5 +126,5 @@ class DiffTallyTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = DiffTallyTestHarness('statepoint.3.h5', True)
+ harness = DiffTallyTestHarness('statepoint.3.h5')
harness.main()
diff --git a/tests/test_distribmat/inputs_true.dat b/tests/test_distribmat/inputs_true.dat
index 2d3e39a65d..cd26a0e7ce 100644
--- a/tests/test_distribmat/inputs_true.dat
+++ b/tests/test_distribmat/inputs_true.dat
@@ -46,9 +46,6 @@
-1 -1 -1 1 1 1
-
diff --git a/tests/test_distribmat/test_distribmat.py b/tests/test_distribmat/test_distribmat.py
index 2816bbfbc3..9dd5d319a2 100644
--- a/tests/test_distribmat/test_distribmat.py
+++ b/tests/test_distribmat/test_distribmat.py
@@ -5,8 +5,6 @@ import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness, PyAPITestHarness
import openmc
-from openmc.stats import Box
-from openmc.source import Source
class DistribmatTestHarness(PyAPITestHarness):
@@ -31,25 +29,18 @@ class DistribmatTestHarness(PyAPITestHarness):
mats_file = openmc.Materials([moderator, dense_fuel, light_fuel])
mats_file.export_to_xml()
-
####################
# Geometry
####################
- c1 = openmc.Cell(cell_id=1)
- c1.fill = moderator
- mod_univ = openmc.Universe(universe_id=1)
- mod_univ.add_cell(c1)
+ c1 = openmc.Cell(cell_id=1, fill=moderator)
+ mod_univ = openmc.Universe(universe_id=1, cells=[c1])
r0 = openmc.ZCylinder(R=0.3)
- c11 = openmc.Cell(cell_id=11)
- c11.region = -r0
+ c11 = openmc.Cell(cell_id=11, region=-r0)
c11.fill = [dense_fuel, light_fuel, None, dense_fuel]
- c12 = openmc.Cell(cell_id=12)
- c12.region = +r0
- c12.fill = moderator
- fuel_univ = openmc.Universe(universe_id=11)
- fuel_univ.add_cells((c11, c12))
+ c12 = openmc.Cell(cell_id=12, region=+r0, fill=moderator)
+ fuel_univ = openmc.Universe(universe_id=11, cells=[c11, c12])
lat = openmc.RectLattice(lattice_id=101)
lat.lower_left = [-2.0, -2.0]
@@ -63,17 +54,13 @@ class DistribmatTestHarness(PyAPITestHarness):
y1 = openmc.YPlane(y0=3.0)
for s in [x0, x1, y0, y1]:
s.boundary_type = 'reflective'
- c101 = openmc.Cell(cell_id=101)
+ c101 = openmc.Cell(cell_id=101, fill=lat)
c101.region = +x0 & -x1 & +y0 & -y1
- c101.fill = lat
- root_univ = openmc.Universe(universe_id=0)
- root_univ.add_cell(c101)
+ root_univ = openmc.Universe(universe_id=0, cells=[c101])
- geometry = openmc.Geometry()
- geometry.root_universe = root_univ
+ geometry = openmc.Geometry(root_univ)
geometry.export_to_xml()
-
####################
# Settings
####################
@@ -82,36 +69,32 @@ class DistribmatTestHarness(PyAPITestHarness):
sets_file.batches = 5
sets_file.inactive = 0
sets_file.particles = 1000
- sets_file.source = Source(space=Box([-1, -1, -1], [1, 1, 1]))
- sets_file.output = {'summary': True}
+ sets_file.source = openmc.Source(space=openmc.stats.Box(
+ [-1, -1, -1], [1, 1, 1]))
sets_file.export_to_xml()
-
####################
# Plots
####################
- plots_file = openmc.Plots()
+ plot1 = openmc.Plot(plot_id=1)
+ plot1.basis = 'xy'
+ plot1.color_by = 'cell'
+ plot1.filename = 'cellplot'
+ plot1.origin = (0, 0, 0)
+ plot1.width = (7, 7)
+ plot1.pixels = (400, 400)
- plot = openmc.Plot(plot_id=1)
- plot.basis = 'xy'
- plot.color_by = 'cell'
- plot.filename = 'cellplot'
- plot.origin = (0, 0, 0)
- plot.width = (7, 7)
- plot.pixels = (400, 400)
- plots_file.add_plot(plot)
+ plot2 = openmc.Plot(plot_id=2)
+ plot2.basis = 'xy'
+ plot2.color_by = 'material'
+ plot2.filename = 'matplot'
+ plot2.origin = (0, 0, 0)
+ plot2.width = (7, 7)
+ plot2.pixels = (400, 400)
- plot = openmc.Plot(plot_id=2)
- plot.basis = 'xy'
- plot.color_by = 'material'
- plot.filename = 'matplot'
- plot.origin = (0, 0, 0)
- plot.width = (7, 7)
- plot.pixels = (400, 400)
- plots_file.add_plot(plot)
-
- plots_file.export_to_xml()
+ plots = openmc.Plots([plot1, plot2])
+ plots.export_to_xml()
def _get_results(self):
outstr = super(DistribmatTestHarness, self)._get_results()
@@ -119,12 +102,6 @@ class DistribmatTestHarness(PyAPITestHarness):
outstr += str(su.geometry.get_all_cells()[11])
return outstr
- def _cleanup(self):
- f = os.path.join(os.getcwd(), 'plots.xml')
- if os.path.exists(f):
- os.remove(f)
- super(DistribmatTestHarness, self)._cleanup()
-
if __name__ == '__main__':
harness = DistribmatTestHarness('statepoint.5.h5')
diff --git a/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py b/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py
index d6f69fdbb5..59a60b63a4 100644
--- a/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py
+++ b/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.7.*')
+ harness = TestHarness('statepoint.7.h5')
harness.main()
diff --git a/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py b/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py
+++ b/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_energy_cutoff/test_energy_cutoff.py b/tests/test_energy_cutoff/test_energy_cutoff.py
index 064e5c4d32..3aa3400c7a 100755
--- a/tests/test_energy_cutoff/test_energy_cutoff.py
+++ b/tests/test_energy_cutoff/test_energy_cutoff.py
@@ -74,5 +74,5 @@ class EnergyCutoffTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = EnergyCutoffTestHarness('statepoint.10.h5', True)
+ harness = EnergyCutoffTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_energy_grid/test_energy_grid.py b/tests/test_energy_grid/test_energy_grid.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_energy_grid/test_energy_grid.py
+++ b/tests/test_energy_grid/test_energy_grid.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_energy_laws/test_energy_laws.py b/tests/test_energy_laws/test_energy_laws.py
index 0e593876fc..254126ff30 100644
--- a/tests/test_energy_laws/test_energy_laws.py
+++ b/tests/test_energy_laws/test_energy_laws.py
@@ -26,5 +26,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_entropy/test_entropy.py b/tests/test_entropy/test_entropy.py
index 113cafcb27..36e2170af8 100644
--- a/tests/test_entropy/test_entropy.py
+++ b/tests/test_entropy/test_entropy.py
@@ -5,7 +5,7 @@ import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness
-from openmc.statepoint import StatePoint
+from openmc import StatePoint
class EntropyTestHarness(TestHarness):
@@ -13,21 +13,19 @@ class EntropyTestHarness(TestHarness):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
- sp = StatePoint(statepoint)
+ with StatePoint(statepoint) as sp:
+ # Write out k-combined.
+ outstr = 'k-combined:\n'
+ outstr += '{0:12.6E} {1:12.6E}\n'.format(*sp.k_combined)
- # Write out k-combined.
- outstr = 'k-combined:\n'
- form = '{0:12.6E} {1:12.6E}\n'
- outstr += form.format(sp.k_combined[0], sp.k_combined[1])
-
- # Write out entropy data.
- outstr += 'entropy:\n'
- results = ['{0:12.6E}'.format(x) for x in sp.entropy]
- outstr += '\n'.join(results) + '\n'
+ # Write out entropy data.
+ outstr += 'entropy:\n'
+ results = ['{0:12.6E}'.format(x) for x in sp.entropy]
+ outstr += '\n'.join(results) + '\n'
return outstr
if __name__ == '__main__':
- harness = EntropyTestHarness('statepoint.10.*')
+ harness = EntropyTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_filter_distribcell/test_filter_distribcell.py b/tests/test_filter_distribcell/test_filter_distribcell.py
index 3a145832cc..f0fc270399 100644
--- a/tests/test_filter_distribcell/test_filter_distribcell.py
+++ b/tests/test_filter_distribcell/test_filter_distribcell.py
@@ -10,7 +10,7 @@ from testing_harness import *
class DistribcellTestHarness(TestHarness):
def __init__(self):
- super(DistribcellTestHarness, self).__init__(None, True)
+ super(DistribcellTestHarness, self).__init__(None)
def execute_test(self):
"""Run OpenMC with the appropriate arguments and check the outputs."""
@@ -41,8 +41,8 @@ class DistribcellTestHarness(TestHarness):
base_dir = os.getcwd()
try:
dirs = ('case-1', '../case-2', '../case-3', '../case-4')
- sps = ('statepoint.1.*', 'statepoint.1.*', 'statepoint.3.*',
- 'statepoint.1.*')
+ sps = ('statepoint.1.h5', 'statepoint.1.h5', 'statepoint.3.h5',
+ 'statepoint.1.h5')
tallies_out_present = (True, True, False, True)
hash_out = (False, False, True, False)
for i in range(len(dirs)):
diff --git a/tests/test_filter_energyfun/test_filter_energyfun.py b/tests/test_filter_energyfun/test_filter_energyfun.py
index 7d8b884ec7..07ae993a9e 100644
--- a/tests/test_filter_energyfun/test_filter_energyfun.py
+++ b/tests/test_filter_energyfun/test_filter_energyfun.py
@@ -49,5 +49,5 @@ class FilterEnergyFunHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = FilterEnergyFunHarness('statepoint.10.h5', True)
+ harness = FilterEnergyFunHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_filter_mesh/test_filter_mesh.py b/tests/test_filter_mesh/test_filter_mesh.py
index d9caf9d951..7b9e8bd16b 100644
--- a/tests/test_filter_mesh/test_filter_mesh.py
+++ b/tests/test_filter_mesh/test_filter_mesh.py
@@ -68,5 +68,5 @@ class FilterMeshTestHarness(HashedPyAPITestHarness):
if __name__ == '__main__':
- harness = FilterMeshTestHarness('statepoint.10.h5', True)
+ harness = FilterMeshTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_fixed_source/test_fixed_source.py b/tests/test_fixed_source/test_fixed_source.py
index 12dbb8d769..8d61a46d0a 100644
--- a/tests/test_fixed_source/test_fixed_source.py
+++ b/tests/test_fixed_source/test_fixed_source.py
@@ -6,7 +6,7 @@ import sys
import numpy as np
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness
-from openmc.statepoint import StatePoint
+from openmc import StatePoint
class FixedSourceTestHarness(TestHarness):
@@ -14,31 +14,27 @@ class FixedSourceTestHarness(TestHarness):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
- sp = StatePoint(statepoint)
-
- # Write out tally data.
outstr = ''
- if self._tallies:
- tally_num = 1
- for tally_ind in sp.tallies:
+ with StatePoint(statepoint) as sp:
+ # Write out tally data.
+ for i, tally_ind in enumerate(sp.tallies):
tally = sp.tallies[tally_ind]
results = np.zeros((tally.sum.size*2, ))
results[0::2] = tally.sum.ravel()
results[1::2] = tally.sum_sq.ravel()
results = ['{0:12.6E}'.format(x) for x in results]
- outstr += 'tally ' + str(tally_num) + ':\n'
+ outstr += 'tally ' + str(i + 1) + ':\n'
outstr += '\n'.join(results) + '\n'
- tally_num += 1
- gt = sp.global_tallies
- outstr += 'leakage:\n'
- outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum']) + '\n'
- outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum_sq']) + '\n'
+ gt = sp.global_tallies
+ outstr += 'leakage:\n'
+ outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum']) + '\n'
+ outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum_sq']) + '\n'
return outstr
if __name__ == '__main__':
- harness = FixedSourceTestHarness('statepoint.10.*', True)
+ harness = FixedSourceTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_infinite_cell/test_infinite_cell.py b/tests/test_infinite_cell/test_infinite_cell.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_infinite_cell/test_infinite_cell.py
+++ b/tests/test_infinite_cell/test_infinite_cell.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_lattice/test_lattice.py b/tests/test_lattice/test_lattice.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_lattice/test_lattice.py
+++ b/tests/test_lattice/test_lattice.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_lattice_hex/test_lattice_hex.py b/tests/test_lattice_hex/test_lattice_hex.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_lattice_hex/test_lattice_hex.py
+++ b/tests/test_lattice_hex/test_lattice_hex.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_lattice_mixed/test_lattice_mixed.py b/tests/test_lattice_mixed/test_lattice_mixed.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_lattice_mixed/test_lattice_mixed.py
+++ b/tests/test_lattice_mixed/test_lattice_mixed.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_lattice_multiple/test_lattice_multiple.py b/tests/test_lattice_multiple/test_lattice_multiple.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_lattice_multiple/test_lattice_multiple.py
+++ b/tests/test_lattice_multiple/test_lattice_multiple.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_mg_basic/test_mg_basic.py b/tests/test_mg_basic/test_mg_basic.py
index 35b9c47d3a..21871efd72 100644
--- a/tests/test_mg_basic/test_mg_basic.py
+++ b/tests/test_mg_basic/test_mg_basic.py
@@ -9,5 +9,5 @@ from openmc.examples import slab_mg
if __name__ == '__main__':
model = slab_mg()
- harness = PyAPITestHarness('statepoint.10.h5', False, model)
+ harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mg_convert/test_mg_convert.py b/tests/test_mg_convert/test_mg_convert.py
index 45e703b0e3..9d13714580 100755
--- a/tests/test_mg_convert/test_mg_convert.py
+++ b/tests/test_mg_convert/test_mg_convert.py
@@ -206,5 +206,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = MGXSTestHarness('statepoint.10.*', False)
+ harness = MGXSTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_mg_legendre/test_mg_legendre.py b/tests/test_mg_legendre/test_mg_legendre.py
index 3db74a824c..eee0f0800f 100644
--- a/tests/test_mg_legendre/test_mg_legendre.py
+++ b/tests/test_mg_legendre/test_mg_legendre.py
@@ -12,5 +12,5 @@ if __name__ == '__main__':
model = slab_mg(reps=['iso'])
model.settings.tabular_legendre = {'enable': False}
- harness = PyAPITestHarness('statepoint.10.h5', False, model)
+ harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mg_max_order/test_mg_max_order.py b/tests/test_mg_max_order/test_mg_max_order.py
index 6a3db3aa5e..8ac0f58785 100644
--- a/tests/test_mg_max_order/test_mg_max_order.py
+++ b/tests/test_mg_max_order/test_mg_max_order.py
@@ -11,5 +11,5 @@ from openmc.examples import slab_mg
if __name__ == '__main__':
model = slab_mg(reps=['iso'])
model.settings.max_order = 1
- harness = PyAPITestHarness('statepoint.10.h5', False, model)
+ harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mg_nuclide/test_mg_nuclide.py b/tests/test_mg_nuclide/test_mg_nuclide.py
index a0adfb0236..0f3c9dd6d7 100644
--- a/tests/test_mg_nuclide/test_mg_nuclide.py
+++ b/tests/test_mg_nuclide/test_mg_nuclide.py
@@ -10,5 +10,5 @@ from openmc.examples import slab_mg
if __name__ == '__main__':
model = slab_mg(as_macro=False)
- harness = PyAPITestHarness('statepoint.10.h5', False, model)
+ harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mg_survival_biasing/test_mg_survival_biasing.py b/tests/test_mg_survival_biasing/test_mg_survival_biasing.py
index 2fefee21d6..9886ad3e49 100644
--- a/tests/test_mg_survival_biasing/test_mg_survival_biasing.py
+++ b/tests/test_mg_survival_biasing/test_mg_survival_biasing.py
@@ -10,5 +10,5 @@ from openmc.examples import slab_mg
if __name__ == '__main__':
model = slab_mg()
model.settings.survival_biasing = True
- harness = PyAPITestHarness('statepoint.10.h5', False, model)
+ harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mg_tallies/test_mg_tallies.py b/tests/test_mg_tallies/test_mg_tallies.py
index cdd3a90f59..7024a48749 100644
--- a/tests/test_mg_tallies/test_mg_tallies.py
+++ b/tests/test_mg_tallies/test_mg_tallies.py
@@ -92,5 +92,5 @@ if __name__ == '__main__':
t.nuclides = nuclides
model.tallies.append(t)
- harness = HashedPyAPITestHarness('statepoint.10.h5', True, model)
+ harness = HashedPyAPITestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mgxs_library_ce_to_mg/test_mgxs_library_ce_to_mg.py b/tests/test_mgxs_library_ce_to_mg/test_mgxs_library_ce_to_mg.py
index c296e39882..aaa83a70db 100644
--- a/tests/test_mgxs_library_ce_to_mg/test_mgxs_library_ce_to_mg.py
+++ b/tests/test_mgxs_library_ce_to_mg/test_mgxs_library_ce_to_mg.py
@@ -89,5 +89,5 @@ if __name__ == '__main__':
# Set the input set to use the pincell model
model = pwr_pin_cell()
- harness = MGXSTestHarness('statepoint.10.h5', False, model)
+ harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mgxs_library_condense/test_mgxs_library_condense.py b/tests/test_mgxs_library_condense/test_mgxs_library_condense.py
index bfa612e4e8..127980da6e 100644
--- a/tests/test_mgxs_library_condense/test_mgxs_library_condense.py
+++ b/tests/test_mgxs_library_condense/test_mgxs_library_condense.py
@@ -68,5 +68,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
# Use the pincell model
model = pwr_pin_cell()
- harness = MGXSTestHarness('statepoint.10.h5', True, model)
+ harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py b/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py
index 71b7b43780..38f16c5884 100644
--- a/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py
+++ b/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py
@@ -71,5 +71,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
model = pwr_assembly()
- harness = MGXSTestHarness('statepoint.10.h5', True, model)
+ harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py b/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py
index 219ba4c0f0..31a9d96126 100644
--- a/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py
+++ b/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py
@@ -84,5 +84,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
model = pwr_pin_cell()
- harness = MGXSTestHarness('statepoint.10.*', True, model)
+ harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mgxs_library_mesh/test_mgxs_library_mesh.py b/tests/test_mgxs_library_mesh/test_mgxs_library_mesh.py
index c52a23153f..e0a3307bc3 100644
--- a/tests/test_mgxs_library_mesh/test_mgxs_library_mesh.py
+++ b/tests/test_mgxs_library_mesh/test_mgxs_library_mesh.py
@@ -71,5 +71,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = MGXSTestHarness('statepoint.10.h5', True)
+ harness = MGXSTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py b/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py
index fdd05bb655..793cfc7146 100644
--- a/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py
+++ b/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py
@@ -64,5 +64,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
model = pwr_pin_cell()
- harness = MGXSTestHarness('statepoint.10.h5', True, model)
+ harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py b/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py
index d5c3665ff4..9e54e1bb6b 100644
--- a/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py
+++ b/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py
@@ -60,5 +60,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
model = pwr_pin_cell()
- harness = MGXSTestHarness('statepoint.10.h5', True, model)
+ harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()
diff --git a/tests/test_multipole/inputs_true.dat b/tests/test_multipole/inputs_true.dat
index ee1ba636e2..4163a00e3c 100644
--- a/tests/test_multipole/inputs_true.dat
+++ b/tests/test_multipole/inputs_true.dat
@@ -43,9 +43,6 @@
-1 -1 -1 1 1 1
-
True
1000
diff --git a/tests/test_multipole/test_multipole.py b/tests/test_multipole/test_multipole.py
index 33a9295dbc..1ab22f6e69 100644
--- a/tests/test_multipole/test_multipole.py
+++ b/tests/test_multipole/test_multipole.py
@@ -4,8 +4,6 @@ import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness, PyAPITestHarness
import openmc
-from openmc.stats import Box
-from openmc.source import Source
class MultipoleTestHarness(PyAPITestHarness):
def _build_inputs(self):
@@ -66,8 +64,8 @@ class MultipoleTestHarness(PyAPITestHarness):
sets_file.batches = 5
sets_file.inactive = 0
sets_file.particles = 1000
- sets_file.source = Source(space=Box([-1, -1, -1], [1, 1, 1]))
- sets_file.output = {'summary': True}
+ sets_file.source = openmc.Source(space=openmc.stats.Box(
+ [-1, -1, -1], [1, 1, 1]))
sets_file.temperature = {'tolerance': 1000, 'multipole': True}
sets_file.export_to_xml()
@@ -75,27 +73,24 @@ class MultipoleTestHarness(PyAPITestHarness):
# Plots
####################
- plots_file = openmc.Plots()
+ plot1 = openmc.Plot(plot_id=1)
+ plot1.basis = 'xy'
+ plot1.color_by = 'cell'
+ plot1.filename = 'cellplot'
+ plot1.origin = (0, 0, 0)
+ plot1.width = (7, 7)
+ plot1.pixels = (400, 400)
- plot = openmc.Plot(plot_id=1)
- plot.basis = 'xy'
- plot.color_by = 'cell'
- plot.filename = 'cellplot'
- plot.origin = (0, 0, 0)
- plot.width = (7, 7)
- plot.pixels = (400, 400)
- plots_file.append(plot)
+ plot2 = openmc.Plot(plot_id=2)
+ plot2.basis = 'xy'
+ plot2.color_by = 'material'
+ plot2.filename = 'matplot'
+ plot2.origin = (0, 0, 0)
+ plot2.width = (7, 7)
+ plot2.pixels = (400, 400)
- plot = openmc.Plot(plot_id=2)
- plot.basis = 'xy'
- plot.color_by = 'material'
- plot.filename = 'matplot'
- plot.origin = (0, 0, 0)
- plot.width = (7, 7)
- plot.pixels = (400, 400)
- plots_file.append(plot)
-
- plots_file.export_to_xml()
+ plots = openmc.Plots([plot1, plot2])
+ plots.export_to_xml()
def execute_test(self):
if not 'OPENMC_MULTIPOLE_LIBRARY' in os.environ:
@@ -110,12 +105,6 @@ class MultipoleTestHarness(PyAPITestHarness):
outstr += str(su.geometry.get_all_cells()[11])
return outstr
- def _cleanup(self):
- f = os.path.join(os.getcwd(), 'plots.xml')
- if os.path.exists(f):
- os.remove(f)
- super(MultipoleTestHarness, self)._cleanup()
-
if __name__ == '__main__':
harness = MultipoleTestHarness('statepoint.5.h5')
diff --git a/tests/test_output/test_output.py b/tests/test_output/test_output.py
index 81f8f42c8a..475b3e9f02 100644
--- a/tests/test_output/test_output.py
+++ b/tests/test_output/test_output.py
@@ -29,5 +29,5 @@ class OutputTestHarness(TestHarness):
if __name__ == '__main__':
- harness = OutputTestHarness('statepoint.10.*')
+ harness = OutputTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_plot/test_plot.py b/tests/test_plot/test_plot.py
index b21e1aada8..d484925cb4 100644
--- a/tests/test_plot/test_plot.py
+++ b/tests/test_plot/test_plot.py
@@ -15,7 +15,7 @@ import openmc
class PlotTestHarness(TestHarness):
"""Specialized TestHarness for running OpenMC plotting tests."""
def __init__(self, plot_names):
- super(PlotTestHarness, self).__init__(None, False)
+ super(PlotTestHarness, self).__init__(None)
self._plot_names = plot_names
def _run_openmc(self):
diff --git a/tests/test_ptables_off/test_ptables_off.py b/tests/test_ptables_off/test_ptables_off.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_ptables_off/test_ptables_off.py
+++ b/tests/test_ptables_off/test_ptables_off.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_quadric_surfaces/test_quadric_surfaces.py b/tests/test_quadric_surfaces/test_quadric_surfaces.py
index 2a595f3e66..b04fcc6eba 100755
--- a/tests/test_quadric_surfaces/test_quadric_surfaces.py
+++ b/tests/test_quadric_surfaces/test_quadric_surfaces.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_reflective_plane/test_reflective_plane.py b/tests/test_reflective_plane/test_reflective_plane.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_reflective_plane/test_reflective_plane.py
+++ b/tests/test_reflective_plane/test_reflective_plane.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_rotation/test_rotation.py b/tests/test_rotation/test_rotation.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_rotation/test_rotation.py
+++ b/tests/test_rotation/test_rotation.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_salphabeta/test_salphabeta.py b/tests/test_salphabeta/test_salphabeta.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_salphabeta/test_salphabeta.py
+++ b/tests/test_salphabeta/test_salphabeta.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_score_current/test_score_current.py b/tests/test_score_current/test_score_current.py
index 99c2981c2a..ea5886a639 100644
--- a/tests/test_score_current/test_score_current.py
+++ b/tests/test_score_current/test_score_current.py
@@ -7,5 +7,5 @@ from testing_harness import HashedTestHarness
if __name__ == '__main__':
- harness = HashedTestHarness('statepoint.10.*', True)
+ harness = HashedTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_seed/test_seed.py b/tests/test_seed/test_seed.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_seed/test_seed.py
+++ b/tests/test_seed/test_seed.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_source_file/test_source_file.py b/tests/test_source_file/test_source_file.py
index 6f76438c2a..5631814b4c 100644
--- a/tests/test_source_file/test_source_file.py
+++ b/tests/test_source_file/test_source_file.py
@@ -98,5 +98,5 @@ class SourceFileTestHarness(TestHarness):
if __name__ == '__main__':
- harness = SourceFileTestHarness('statepoint.10.*')
+ harness = SourceFileTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_sourcepoint_batch/test_sourcepoint_batch.py b/tests/test_sourcepoint_batch/test_sourcepoint_batch.py
index 5db0541344..d5ea0e48b2 100644
--- a/tests/test_sourcepoint_batch/test_sourcepoint_batch.py
+++ b/tests/test_sourcepoint_batch/test_sourcepoint_batch.py
@@ -5,7 +5,7 @@ import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness
-from openmc.statepoint import StatePoint
+from openmc import StatePoint
class SourcepointTestHarness(TestHarness):
@@ -18,21 +18,20 @@ class SourcepointTestHarness(TestHarness):
def _get_results(self):
"""Digest info in the statepoint and return as a string."""
- # Read the statepoint file.
- statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
- sp = StatePoint(statepoint)
-
# Get the eigenvalue information.
outstr = TestHarness._get_results(self)
- # Add the source information.
- xyz = sp.source[0]['xyz']
- outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
- outstr += "\n"
+ # Read the statepoint file.
+ statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
+ with StatePoint(statepoint) as sp:
+ # Add the source information.
+ xyz = sp.source[0]['xyz']
+ outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
+ outstr += "\n"
return outstr
if __name__ == '__main__':
- harness = SourcepointTestHarness('statepoint.08.*')
+ harness = SourcepointTestHarness('statepoint.08.h5')
harness.main()
diff --git a/tests/test_sourcepoint_latest/test_sourcepoint_latest.py b/tests/test_sourcepoint_latest/test_sourcepoint_latest.py
index 724a88fa65..c64cc20cc7 100644
--- a/tests/test_sourcepoint_latest/test_sourcepoint_latest.py
+++ b/tests/test_sourcepoint_latest/test_sourcepoint_latest.py
@@ -18,5 +18,5 @@ class SourcepointTestHarness(TestHarness):
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_sourcepoint_restart/test_sourcepoint_restart.py b/tests/test_sourcepoint_restart/test_sourcepoint_restart.py
index ed6addec45..b04fcc6eba 100644
--- a/tests/test_sourcepoint_restart/test_sourcepoint_restart.py
+++ b/tests/test_sourcepoint_restart/test_sourcepoint_restart.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*', True)
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_statepoint_batch/test_statepoint_batch.py b/tests/test_statepoint_batch/test_statepoint_batch.py
index c8da1c9adc..e3e2391ba1 100644
--- a/tests/test_statepoint_batch/test_statepoint_batch.py
+++ b/tests/test_statepoint_batch/test_statepoint_batch.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python
import os
import sys
@@ -8,11 +8,11 @@ from testing_harness import TestHarness
class StatepointTestHarness(TestHarness):
def __init__(self):
- super(StatepointTestHarness, self).__init__(None, False)
+ super(StatepointTestHarness, self).__init__(None)
def _test_output_created(self):
"""Make sure statepoint files have been created."""
- sps = ('statepoint.03.*', 'statepoint.06.*', 'statepoint.09.*')
+ sps = ('statepoint.03.h5', 'statepoint.06.h5', 'statepoint.09.h5')
for sp in sps:
self._sp_name = sp
TestHarness._test_output_created(self)
diff --git a/tests/test_statepoint_restart/test_statepoint_restart.py b/tests/test_statepoint_restart/test_statepoint_restart.py
index 61522ee051..2c1c444958 100644
--- a/tests/test_statepoint_restart/test_statepoint_restart.py
+++ b/tests/test_statepoint_restart/test_statepoint_restart.py
@@ -9,9 +9,8 @@ import openmc
class StatepointRestartTestHarness(TestHarness):
- def __init__(self, final_sp, restart_sp, tallies_present=False):
- super(StatepointRestartTestHarness, self).__init__(final_sp,
- tallies_present)
+ def __init__(self, final_sp, restart_sp):
+ super(StatepointRestartTestHarness, self).__init__(final_sp)
self._restart_sp = restart_sp
def execute_test(self):
@@ -63,5 +62,5 @@ class StatepointRestartTestHarness(TestHarness):
if __name__ == '__main__':
harness = StatepointRestartTestHarness('statepoint.10.h5',
- 'statepoint.07.h5', True)
+ 'statepoint.07.h5')
harness.main()
diff --git a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py
index 00ded42ec2..f4bdcfb7b3 100644
--- a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py
+++ b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py
@@ -26,5 +26,5 @@ class SourcepointTestHarness(TestHarness):
if __name__ == '__main__':
- harness = SourcepointTestHarness('statepoint.10.*')
+ harness = SourcepointTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_survival_biasing/test_survival_biasing.py b/tests/test_survival_biasing/test_survival_biasing.py
index ed6addec45..b04fcc6eba 100644
--- a/tests/test_survival_biasing/test_survival_biasing.py
+++ b/tests/test_survival_biasing/test_survival_biasing.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*', True)
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_tallies/test_tallies.py b/tests/test_tallies/test_tallies.py
index b41068f8e8..315a5b6be2 100644
--- a/tests/test_tallies/test_tallies.py
+++ b/tests/test_tallies/test_tallies.py
@@ -10,7 +10,7 @@ from openmc import Mesh, Tally, Tallies
if __name__ == '__main__':
- harness = HashedPyAPITestHarness('statepoint.5.h5', True)
+ harness = HashedPyAPITestHarness('statepoint.5.h5')
model = harness._model
# Set settings explicitly
diff --git a/tests/test_tally_aggregation/test_tally_aggregation.py b/tests/test_tally_aggregation/test_tally_aggregation.py
index cb98b53fa1..cf291e0266 100644
--- a/tests/test_tally_aggregation/test_tally_aggregation.py
+++ b/tests/test_tally_aggregation/test_tally_aggregation.py
@@ -67,5 +67,5 @@ class TallyAggregationTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = TallyAggregationTestHarness('statepoint.10.h5', True)
+ harness = TallyAggregationTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_tally_arithmetic/test_tally_arithmetic.py b/tests/test_tally_arithmetic/test_tally_arithmetic.py
index 6fcbb15a8a..593a0a2917 100644
--- a/tests/test_tally_arithmetic/test_tally_arithmetic.py
+++ b/tests/test_tally_arithmetic/test_tally_arithmetic.py
@@ -81,5 +81,5 @@ class TallyArithmeticTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = TallyArithmeticTestHarness('statepoint.10.h5', True)
+ harness = TallyArithmeticTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_tally_assumesep/test_tally_assumesep.py b/tests/test_tally_assumesep/test_tally_assumesep.py
index ed6addec45..b04fcc6eba 100644
--- a/tests/test_tally_assumesep/test_tally_assumesep.py
+++ b/tests/test_tally_assumesep/test_tally_assumesep.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*', True)
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_tally_nuclides/test_tally_nuclides.py b/tests/test_tally_nuclides/test_tally_nuclides.py
index ed6addec45..b04fcc6eba 100644
--- a/tests/test_tally_nuclides/test_tally_nuclides.py
+++ b/tests/test_tally_nuclides/test_tally_nuclides.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*', True)
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_tally_slice_merge/test_tally_slice_merge.py b/tests/test_tally_slice_merge/test_tally_slice_merge.py
index 624624a153..d917d2dadb 100644
--- a/tests/test_tally_slice_merge/test_tally_slice_merge.py
+++ b/tests/test_tally_slice_merge/test_tally_slice_merge.py
@@ -172,5 +172,5 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
if __name__ == '__main__':
- harness = TallySliceMergeTestHarness('statepoint.10.h5', True)
+ harness = TallySliceMergeTestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_trace/test_trace.py b/tests/test_trace/test_trace.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_trace/test_trace.py
+++ b/tests/test_trace/test_trace.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_track_output/test_track_output.py b/tests/test_track_output/test_track_output.py
index 9e9ce87adb..231f25a0de 100644
--- a/tests/test_track_output/test_track_output.py
+++ b/tests/test_track_output/test_track_output.py
@@ -54,5 +54,5 @@ if __name__ == '__main__':
print('----------------Skipping test-------------')
shutil.copy('results_true.dat', 'results_test.dat')
exit()
- harness = TrackTestHarness('statepoint.2.*')
+ harness = TrackTestHarness('statepoint.2.h5')
harness.main()
diff --git a/tests/test_translation/test_translation.py b/tests/test_translation/test_translation.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_translation/test_translation.py
+++ b/tests/test_translation/test_translation.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_trigger_batch_interval/test_trigger_batch_interval.py b/tests/test_trigger_batch_interval/test_trigger_batch_interval.py
index a0b2119dea..fb88ada001 100644
--- a/tests/test_trigger_batch_interval/test_trigger_batch_interval.py
+++ b/tests/test_trigger_batch_interval/test_trigger_batch_interval.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.15.*', True)
+ harness = TestHarness('statepoint.15.h5')
harness.main()
diff --git a/tests/test_trigger_no_batch_interval/test_trigger_no_batch_interval.py b/tests/test_trigger_no_batch_interval/test_trigger_no_batch_interval.py
index a0b2119dea..fb88ada001 100644
--- a/tests/test_trigger_no_batch_interval/test_trigger_no_batch_interval.py
+++ b/tests/test_trigger_no_batch_interval/test_trigger_no_batch_interval.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.15.*', True)
+ harness = TestHarness('statepoint.15.h5')
harness.main()
diff --git a/tests/test_trigger_no_status/test_trigger_no_status.py b/tests/test_trigger_no_status/test_trigger_no_status.py
index ed6addec45..b04fcc6eba 100644
--- a/tests/test_trigger_no_status/test_trigger_no_status.py
+++ b/tests/test_trigger_no_status/test_trigger_no_status.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*', True)
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_trigger_tallies/test_trigger_tallies.py b/tests/test_trigger_tallies/test_trigger_tallies.py
index a0b2119dea..fb88ada001 100644
--- a/tests/test_trigger_tallies/test_trigger_tallies.py
+++ b/tests/test_trigger_tallies/test_trigger_tallies.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.15.*', True)
+ harness = TestHarness('statepoint.15.h5')
harness.main()
diff --git a/tests/test_uniform_fs/test_uniform_fs.py b/tests/test_uniform_fs/test_uniform_fs.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_uniform_fs/test_uniform_fs.py
+++ b/tests/test_uniform_fs/test_uniform_fs.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_universe/test_universe.py b/tests/test_universe/test_universe.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_universe/test_universe.py
+++ b/tests/test_universe/test_universe.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/test_void/test_void.py b/tests/test_void/test_void.py
index 2a595f3e66..b04fcc6eba 100644
--- a/tests/test_void/test_void.py
+++ b/tests/test_void/test_void.py
@@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
- harness = TestHarness('statepoint.10.*')
+ harness = TestHarness('statepoint.10.h5')
harness.main()
diff --git a/tests/testing_harness.py b/tests/testing_harness.py
index 71e72edbd9..428bf5c4b7 100644
--- a/tests/testing_harness.py
+++ b/tests/testing_harness.py
@@ -1,5 +1,6 @@
from __future__ import print_function
+from difflib import unified_diff
import filecmp
import glob
import hashlib
@@ -12,15 +13,14 @@ import numpy as np
sys.path.insert(0, os.path.join(os.pardir, os.pardir))
import openmc
-from openmc.examples import pwr_core, slab_mg
+from openmc.examples import pwr_core
class TestHarness(object):
"""General class for running OpenMC regression tests."""
- def __init__(self, statepoint_name, tallies_present=False):
+ def __init__(self, statepoint_name):
self._sp_name = statepoint_name
- self._tallies = tallies_present
self.parser = OptionParser()
self.parser.add_option('--exe', dest='exe', default='openmc')
self.parser.add_option('--mpi_exec', dest='mpi_exec', default=None)
@@ -78,7 +78,7 @@ class TestHarness(object):
' exist.'
assert statepoint[0].endswith('h5'), \
'Statepoint file is not a HDF5 file.'
- if self._tallies:
+ if os.path.exists('tallies.xml'):
assert os.path.exists('tallies.out'), \
'Tally output file does not exist.'
@@ -86,26 +86,22 @@ class TestHarness(object):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
statepoint = glob.glob(self._sp_name)[0]
- sp = openmc.StatePoint(statepoint)
+ with openmc.StatePoint(statepoint) as sp:
+ # Write out k-combined.
+ outstr = 'k-combined:\n'
+ form = '{0:12.6E} {1:12.6E}\n'
+ outstr += form.format(sp.k_combined[0], sp.k_combined[1])
- # Write out k-combined.
- outstr = 'k-combined:\n'
- form = '{0:12.6E} {1:12.6E}\n'
- outstr += form.format(sp.k_combined[0], sp.k_combined[1])
-
- # Write out tally data.
- if self._tallies:
- tally_num = 1
- for tally_ind in sp.tallies:
+ # Write out tally data.
+ for i, tally_ind in enumerate(sp.tallies):
tally = sp.tallies[tally_ind]
results = np.zeros((tally.sum.size * 2, ))
results[0::2] = tally.sum.ravel()
results[1::2] = tally.sum_sq.ravel()
results = ['{0:12.6E}'.format(x) for x in results]
- outstr += 'tally ' + str(tally_num) + ':\n'
+ outstr += 'tally {}:\n'.format(i + 1)
outstr += '\n'.join(results) + '\n'
- tally_num += 1
# Hash the results if necessary.
if hash_output:
@@ -154,31 +150,31 @@ class CMFDTestHarness(TestHarness):
def _get_results(self):
"""Digest info in the statepoint and return as a string."""
- # Read the statepoint file.
- statepoint = glob.glob(self._sp_name)[0]
- sp = openmc.StatePoint(statepoint)
# Write out the eigenvalue and tallies.
outstr = super(CMFDTestHarness, self)._get_results()
- # Write out CMFD data.
- outstr += 'cmfd indices\n'
- outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.cmfd_indices])
- outstr += '\nk cmfd\n'
- outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.k_cmfd])
- outstr += '\ncmfd entropy\n'
- outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.cmfd_entropy])
- outstr += '\ncmfd balance\n'
- outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.cmfd_balance])
- outstr += '\ncmfd dominance ratio\n'
- outstr += '\n'.join(['{0:10.3E}'.format(x) for x in sp.cmfd_dominance])
- outstr += '\ncmfd openmc source comparison\n'
- outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.cmfd_srccmp])
- outstr += '\ncmfd source\n'
- cmfdsrc = np.reshape(sp.cmfd_src, np.product(sp.cmfd_indices),
- order='F')
- outstr += '\n'.join(['{0:12.6E}'.format(x) for x in cmfdsrc])
- outstr += '\n'
+ # Read the statepoint file.
+ statepoint = glob.glob(self._sp_name)[0]
+ with openmc.StatePoint(statepoint) as sp:
+ # Write out CMFD data.
+ outstr += 'cmfd indices\n'
+ outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.cmfd_indices])
+ outstr += '\nk cmfd\n'
+ outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.k_cmfd])
+ outstr += '\ncmfd entropy\n'
+ outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.cmfd_entropy])
+ outstr += '\ncmfd balance\n'
+ outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.cmfd_balance])
+ outstr += '\ncmfd dominance ratio\n'
+ outstr += '\n'.join(['{0:10.3E}'.format(x) for x in sp.cmfd_dominance])
+ outstr += '\ncmfd openmc source comparison\n'
+ outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp.cmfd_srccmp])
+ outstr += '\ncmfd source\n'
+ cmfdsrc = np.reshape(sp.cmfd_src, np.product(sp.cmfd_indices),
+ order='F')
+ outstr += '\n'.join(['{0:12.6E}'.format(x) for x in cmfdsrc])
+ outstr += '\n'
return outstr
@@ -240,9 +236,8 @@ class ParticleRestartTestHarness(TestHarness):
class PyAPITestHarness(TestHarness):
- def __init__(self, statepoint_name, tallies_present=False, model=None):
- super(PyAPITestHarness, self).__init__(
- statepoint_name, tallies_present)
+ def __init__(self, statepoint_name, model=None):
+ super(PyAPITestHarness, self).__init__(statepoint_name)
self.parser.add_option('-b', '--build-inputs', dest='build_only',
action='store_true', default=False)
if model is None:
@@ -316,11 +311,11 @@ class PyAPITestHarness(TestHarness):
"""Make sure the current inputs agree with the _true standard."""
compare = filecmp.cmp('inputs_test.dat', 'inputs_true.dat')
if not compare:
- f = open('inputs_test.dat')
- for line in f.readlines():
- print(line)
- f.close()
os.rename('inputs_test.dat', 'inputs_error.dat')
+ for line in unified_diff(open('inputs_true.dat', 'r').readlines(),
+ open('inputs_error.dat', 'r').readlines(),
+ 'inputs_true.dat', 'inputs_error.dat'):
+ print(line, end='')
assert compare, 'Input files are broken.'
def _cleanup(self):