Skip to content

Commit

Permalink
Fixing string formatting in globalFluxInterface (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgjarrett committed Nov 17, 2022
1 parent 36fe1bc commit a6d0abc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion armi/physics/neutronics/globalFlux/globalFluxInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def fromReactor(self, reactor: reactors.Reactor):
self.geomType = reactor.core.geomType
self.symmetry = reactor.core.symmetry

cycleNodeStamp = "{reactor.p.cycle:03d}{reactor.p.timeNode:03d}"
cycleNodeStamp = f"{reactor.p.cycle:03d}{reactor.p.timeNode:03d}"
if self.savePhysicsFilesList is not None:
self.savePhysicsFiles = cycleNodeStamp in self.savePhysicsFilesList
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@


# pylint: disable=abstract-method
class MockParams:
class MockReactorParams:
def __init__(self):
self.cycle = 1
self.timeNode = 2


class MockCoreParams:
pass


Expand All @@ -38,13 +44,14 @@ def __init__(self):
# just pick a random geomType
self.geomType = geometry.GeomType.CARTESIAN
self.symmetry = "full"
self.p = MockParams()
self.p = MockCoreParams()


class MockReactor:
def __init__(self):
self.core = MockCore()
self.o = None
self.p = MockReactorParams()


class MockGlobalFluxInterface(globalFluxInterface.GlobalFluxInterface):
Expand Down Expand Up @@ -96,6 +103,21 @@ def test_readFromReactors(self):
opts = globalFluxInterface.GlobalFluxOptions("neutronics-run")
opts.fromReactor(reactor)
self.assertEqual(opts.geomType, geometry.GeomType.CARTESIAN)
self.assertFalse(opts.savePhysicsFiles)

def test_savePhysicsFiles(self):
reactor = MockReactor()
opts = globalFluxInterface.GlobalFluxOptions("neutronics-run")

# savePhysicsFilesList matches MockReactor parameters
opts.savePhysicsFilesList = ["001002"]
opts.fromReactor(reactor)
self.assertTrue(opts.savePhysicsFiles)

# savePhysicsFilesList does not match MockReactor parameters
opts.savePhysicsFilesList = ["001000"]
opts.fromReactor(reactor)
self.assertFalse(opts.savePhysicsFiles)


class TestGlobalFluxInterface(unittest.TestCase):
Expand Down

0 comments on commit a6d0abc

Please sign in to comment.