mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
Use super() in Python classes in tests package
This commit is contained in:
parent
59861c9507
commit
b7c63be018
22 changed files with 30 additions and 30 deletions
|
|
@ -9,7 +9,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class AsymmetricLatticeTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AsymmetricLatticeTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Extract universes encapsulating fuel and water assemblies
|
||||
geometry = self._model.geometry
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class DiffTallyTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DiffTallyTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Set settings explicitly
|
||||
self._model.settings.batches = 3
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class DistribmatTestHarness(PyAPITestHarness):
|
|||
plots.export_to_xml()
|
||||
|
||||
def _get_results(self):
|
||||
outstr = super(DistribmatTestHarness, self)._get_results()
|
||||
outstr = super()._get_results()
|
||||
su = openmc.Summary('summary.h5')
|
||||
outstr += str(su.geometry.get_all_cells()[11])
|
||||
return outstr
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from tests.testing_harness import *
|
|||
|
||||
class DistribcellTestHarness(TestHarness):
|
||||
def __init__(self):
|
||||
super(DistribcellTestHarness, self).__init__(None)
|
||||
super().__init__(None)
|
||||
|
||||
def execute_test(self):
|
||||
"""Run OpenMC with the appropriate arguments and check the outputs."""
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class FilterEnergyFunHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FilterEnergyFunHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Add Am241 to the fuel.
|
||||
self._model.materials[1].add_nuclide('Am241', 1e-7)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from tests.testing_harness import HashedPyAPITestHarness
|
|||
|
||||
class FilterMeshTestHarness(HashedPyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FilterMeshTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize Meshes
|
||||
mesh_1d = openmc.Mesh(mesh_id=1)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class MGXSTestHarness(PyAPITestHarness):
|
|||
return outstr
|
||||
|
||||
def _cleanup(self):
|
||||
super(MGXSTestHarness, self)._cleanup()
|
||||
super()._cleanup()
|
||||
f = os.path.join(os.getcwd(), 'mgxs.h5')
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from tests.regression_tests import config
|
|||
class MGXSTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# Generate inputs using parent class routine
|
||||
super(MGXSTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
|
||||
|
|
@ -71,7 +71,7 @@ class MGXSTestHarness(PyAPITestHarness):
|
|||
openmc.run(openmc_exec=config['exe'])
|
||||
|
||||
def _cleanup(self):
|
||||
super(MGXSTestHarness, self)._cleanup()
|
||||
super()._cleanup()
|
||||
f = 'mgxs.h5'
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class MGXSTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MGXSTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
class MGXSTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# Generate inputs using parent class routine
|
||||
super(MGXSTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize a one-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 20.e6])
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
class MGXSTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# Generate inputs using parent class routine
|
||||
super(MGXSTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
|
||||
|
|
@ -67,7 +67,7 @@ class MGXSTestHarness(PyAPITestHarness):
|
|||
return outstr
|
||||
|
||||
def _cleanup(self):
|
||||
super(MGXSTestHarness, self)._cleanup()
|
||||
super()._cleanup()
|
||||
f = 'mgxs.h5'
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class MGXSTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MGXSTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize a one-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 20.e6])
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
class MGXSTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# Generate inputs using parent class routine
|
||||
super(MGXSTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class MGXSTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MGXSTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
|
||||
|
|
|
|||
|
|
@ -71,10 +71,10 @@ class MultipoleTestHarness(PyAPITestHarness):
|
|||
raise RuntimeError("The 'OPENMC_MULTIPOLE_LIBRARY' environment "
|
||||
"variable must be specified for this test.")
|
||||
else:
|
||||
super(MultipoleTestHarness, self).execute_test()
|
||||
super().execute_test()
|
||||
|
||||
def _get_results(self):
|
||||
outstr = super(MultipoleTestHarness, self)._get_results()
|
||||
outstr = super()._get_results()
|
||||
su = openmc.Summary('summary.h5')
|
||||
outstr += str(su.geometry.get_all_cells()[11])
|
||||
return outstr
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from tests.regression_tests import config
|
|||
class PlotTestHarness(TestHarness):
|
||||
"""Specialized TestHarness for running OpenMC plotting tests."""
|
||||
def __init__(self, plot_names):
|
||||
super(PlotTestHarness, self).__init__(None)
|
||||
super().__init__(None)
|
||||
self._plot_names = plot_names
|
||||
|
||||
def _run_openmc(self):
|
||||
|
|
@ -24,7 +24,7 @@ class PlotTestHarness(TestHarness):
|
|||
assert os.path.exists(fname), 'Plot output file does not exist.'
|
||||
|
||||
def _cleanup(self):
|
||||
super(PlotTestHarness, self)._cleanup()
|
||||
super()._cleanup()
|
||||
for fname in self._plot_names:
|
||||
if os.path.exists(fname):
|
||||
os.remove(fname)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from tests.testing_harness import TestHarness
|
|||
|
||||
class StatepointTestHarness(TestHarness):
|
||||
def __init__(self):
|
||||
super(StatepointTestHarness, self).__init__(None)
|
||||
super().__init__(None)
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure statepoint files have been created."""
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.regression_tests import config
|
|||
|
||||
class StatepointRestartTestHarness(TestHarness):
|
||||
def __init__(self, final_sp, restart_sp):
|
||||
super(StatepointRestartTestHarness, self).__init__(final_sp)
|
||||
super().__init__(final_sp)
|
||||
self._restart_sp = restart_sp
|
||||
|
||||
def execute_test(self):
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class TallyAggregationTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TallyAggregationTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize the filters
|
||||
energy_filter = openmc.EnergyFilter([0.0, 0.253, 1.0e3, 1.0e6, 20.0e6])
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class TallyArithmeticTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TallyArithmeticTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Initialize Mesh
|
||||
mesh = openmc.Mesh(mesh_id=1)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from tests.testing_harness import PyAPITestHarness
|
|||
|
||||
class TallySliceMergeTestHarness(PyAPITestHarness):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TallySliceMergeTestHarness, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Define nuclides and scores to add to both tallies
|
||||
self.nuclides = ['U235', 'U238']
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class HashedTestHarness(TestHarness):
|
|||
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
return super(HashedTestHarness, self)._get_results(True)
|
||||
return super()._get_results(True)
|
||||
|
||||
|
||||
class CMFDTestHarness(TestHarness):
|
||||
|
|
@ -137,7 +137,7 @@ class CMFDTestHarness(TestHarness):
|
|||
"""Digest info in the statepoint and return as a string."""
|
||||
|
||||
# Write out the eigenvalue and tallies.
|
||||
outstr = super(CMFDTestHarness, self)._get_results()
|
||||
outstr = super()._get_results()
|
||||
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(self._sp_name)[0]
|
||||
|
|
@ -220,7 +220,7 @@ class ParticleRestartTestHarness(TestHarness):
|
|||
|
||||
class PyAPITestHarness(TestHarness):
|
||||
def __init__(self, statepoint_name, model=None):
|
||||
super(PyAPITestHarness, self).__init__(statepoint_name)
|
||||
super().__init__(statepoint_name)
|
||||
if model is None:
|
||||
self._model = pwr_core()
|
||||
else:
|
||||
|
|
@ -300,7 +300,7 @@ class PyAPITestHarness(TestHarness):
|
|||
|
||||
def _cleanup(self):
|
||||
"""Delete XMLs, statepoints, tally, and test files."""
|
||||
super(PyAPITestHarness, self)._cleanup()
|
||||
super()._cleanup()
|
||||
output = ['materials.xml', 'geometry.xml', 'settings.xml',
|
||||
'tallies.xml', 'plots.xml', 'inputs_test.dat']
|
||||
for f in output:
|
||||
|
|
@ -311,4 +311,4 @@ class PyAPITestHarness(TestHarness):
|
|||
class HashedPyAPITestHarness(PyAPITestHarness):
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
return super(HashedPyAPITestHarness, self)._get_results(True)
|
||||
return super()._get_results(True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue