Skip to content

Commit f5dcc1d

Browse files
authored
Cleaning out unnecessary uses of r.o (#1999)
1 parent 01a5adf commit f5dcc1d

File tree

6 files changed

+26
-56
lines changed

6 files changed

+26
-56
lines changed

armi/mpiActions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def __init__(self, skipInterfaces=False):
505505
self._skipInterfaces = skipInterfaces
506506

507507
def invokeHook(self):
508-
r"""Sync up all nodes with the reactor, the cs, and the interfaces.
508+
"""Sync up all nodes with the reactor, the cs, and the interfaces.
509509
510510
Notes
511511
-----
@@ -604,9 +604,7 @@ def _distributeReactor(self, cs):
604604

605605
self.r.o = self.o
606606

607-
runLog.debug(
608-
"The reactor has {} assemblies".format(len(self.r.core.getAssemblies()))
609-
)
607+
runLog.debug(f"The reactor has {len(self.r.core.getAssemblies())} assemblies")
610608
# attach here so any interface actions use a properly-setup reactor.
611609
self.o.reattach(self.r, cs) # sets r and cs
612610

armi/physics/fuelCycle/tests/test_fuelHandlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def test_repeatShuffles(self):
481481
self.assertEqual(a.getLocation(), "SFP")
482482

483483
# do some shuffles
484-
fh = self.r.o.getInterface("fuelHandler")
484+
fh = self.o.getInterface("fuelHandler")
485485
self.runShuffling(fh) # changes caseTitle
486486

487487
# Make sure the generated shuffles file matches the tracked one. This will need to be
@@ -504,7 +504,7 @@ def test_repeatShuffles(self):
504504
newSettings["explicitRepeatShuffles"] = "armiRun-SHUFFLES.txt"
505505
self.o.cs = self.o.cs.modified(newSettings=newSettings)
506506

507-
fh = self.r.o.getInterface("fuelHandler")
507+
fh = self.o.getInterface("fuelHandler")
508508

509509
self.runShuffling(fh)
510510

armi/physics/neutronics/macroXSGenerationInterface.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from armi import mpiActions
2626
from armi import runLog
2727
from armi.nuclearDataIO import xsCollections
28-
from armi.utils import iterables
2928
from armi.physics.neutronics.settings import CONF_MINIMUM_NUCLIDE_DENSITY
29+
from armi.utils import getBurnSteps, iterables
3030

3131

3232
class MacroXSGenerator(mpiActions.MpiAction):
@@ -112,12 +112,12 @@ def invokeHook(self):
112112

113113
class MacroXSGenerationInterface(interfaces.Interface):
114114
"""
115-
Builds macroscopic cross sections on all blocks.
116-
117-
.. warning::
118-
This probably shouldn't be an interface since it has no interactXYZ methods
119-
It should probably be converted to an MpiAction.
115+
Builds macroscopic cross sections on all Blocks.
120116
117+
Warning
118+
-------
119+
This probably shouldn't be an interface since it has no interactXYZ methods. It should probably
120+
be converted to an MpiAction.
121121
"""
122122

123123
name = "macroXsGen"
@@ -136,8 +136,7 @@ def buildMacros(
136136
libType="micros",
137137
):
138138
"""
139-
Builds block-level macroscopic cross sections for making diffusion
140-
equation matrices.
139+
Builds block-level macroscopic cross sections for making diffusion equation matrices.
141140
142141
This will use MPI if armi.context.MPI_SIZE > 1
143142
@@ -188,8 +187,9 @@ def buildMacros(
188187
block: either "micros" for neutron XS or "gammaXS" for gamma XS.
189188
"""
190189
cycle = self.r.p.cycle
190+
burnSteps = getBurnSteps(self.cs)
191191
self.macrosLastBuiltAt = (
192-
sum([self.r.o.burnSteps[i] + 1 for i in range(cycle)]) + self.r.p.timeNode
192+
sum([burnSteps[i] + 1 for i in range(cycle)]) + self.r.p.timeNode
193193
)
194194

195195
runLog.important("Building macro XS")
@@ -205,10 +205,8 @@ def buildMacros(
205205
xsGen.invoke(self.o, self.r, self.cs)
206206

207207

208-
# helper functions for mpi communication
209-
210-
211208
def _scatterList(lst):
209+
"""Helper functions for mpi communication."""
212210
if context.MPI_RANK == 0:
213211
chunked = iterables.split(lst, context.MPI_SIZE)
214212
else:
@@ -217,6 +215,7 @@ def _scatterList(lst):
217215

218216

219217
def _gatherList(localList):
218+
"""Helper functions for mpi communication."""
220219
globalList = context.MPI_COMM.gather(localList, root=0)
221220
if context.MPI_RANK == 0:
222221
globalList = iterables.flatten(globalList)

armi/reactor/assemblies.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,28 +1018,24 @@ def getParamValuesAtZ(
10181018
This caches interpolators for each param and must be cleared if new params are
10191019
set or new heights are set.
10201020
1021-
WARNING:
1022-
Fails when requested to extrapolate.With higher order splines it is possible
1023-
to interpolate non-physical values, for example a negative flux or dpa. Please
1024-
use caution when going off default in interpType and be certain that
1025-
interpolated values are physical.
1021+
Warning
1022+
-------
1023+
Fails when requested to extrapolate. With higher order splines it is possible to interpolate
1024+
non-physical values, for example, a negative flux or dpa. Please use caution when going off
1025+
default in interpType and be certain that interpolated values are physical.
10261026
10271027
Parameters
10281028
----------
10291029
param : str
10301030
the parameter to interpolate
1031-
10321031
elevations : array of float
1033-
the elevations from the bottom of the assembly in cm at which you want the
1034-
point.
1035-
1032+
the elevations from the bottom of the assembly in cm at which you want the point.
10361033
interpType: str or int
10371034
used in interp1d. interp1d documention: Specifies the kind of interpolation
10381035
as a string ('linear', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic'
10391036
where 'slinear', 'quadratic' and 'cubic' refer to a spline interpolation of
10401037
first, second or third order) or as an integer specifying the order of the
10411038
spline interpolator to use. Default is 'linear'.
1042-
10431039
fillValue: str
10441040
Rough pass through to scipy.interpolate.interp1d. If 'extend', then the
10451041
lower and upper bounds are used as the extended value. If 'extrapolate',
@@ -1070,23 +1066,22 @@ def getParamOfZFunction(self, param, interpType="linear", fillValue=np.NaN):
10701066
This caches interpolators for each param and must be cleared if new params are
10711067
set or new heights are set.
10721068
1073-
WARNING: Fails when requested to extrapololate. With higher order splines it is
1074-
possible to interpolate nonphysical values, for example a negative flux or dpa.
1075-
Please use caution when going off default in interpType and be certain that
1076-
interpolated values are physical.
1069+
Warning
1070+
-------
1071+
Fails when requested to extrapololate. With higher order splines it is possible to
1072+
interpolate nonphysical values, for example, a negative flux or dpa. Please use caution when
1073+
going off default in interpType and be certain that interpolated values are physical.
10771074
10781075
Parameters
10791076
----------
10801077
param : str
10811078
the parameter to interpolate
1082-
10831079
interpType: str or int
10841080
used in interp1d. interp1d documention: Specifies the kind of interpolation
10851081
as a string ('linear', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic'
10861082
where 'slinear', 'quadratic' and 'cubic' refer to a spline interpolation of
10871083
first, second or third order) or as an integer specifying the order of the
10881084
spline interpolator to use. Default is 'linear'.
1089-
10901085
fillValue: float
10911086
Rough pass through to scipy.interpolate.interp1d. If 'extend', then the
10921087
lower and upper bounds are used as the extended value. If 'extrapolate',

armi/reactor/converters/parameterSweeps/generalParameterSweepConverters.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ def convert(self, r=None):
5252
)
5353

5454

55-
class CustomModifier(ParameterSweepConverter):
56-
"""Invoke the shuffle logic `applyCustomPerturbation` method to make a custom setting."""
57-
58-
def convert(self, r=None):
59-
ParameterSweepConverter.convert(self, r)
60-
fh = r.o.getInterface("fuelHandler")
61-
fh.applyCustomPerturbation(self._parameter)
62-
63-
6455
class NeutronicConvergenceModifier(ParameterSweepConverter):
6556
"""Adjusts the neutronics convergence parameters."""
6657

armi/reactor/converters/parameterSweeps/tests/test_paramSweepConverters.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from armi.tests import TEST_ROOT
2020
from armi.reactor.converters.parameterSweeps.generalParameterSweepConverters import (
21-
CustomModifier,
2221
NeutronicConvergenceModifier,
2322
ParameterSweepConverter,
2423
SettingsModifier,
@@ -64,15 +63,3 @@ def test_settingsModifier(self):
6463
# NOTE: Settings objects are not modified, but we point to new objects
6564
self.assertIn("Simple test input", self.cs["comment"])
6665
self.assertEqual(con._cs["comment"], "FakeParam")
67-
68-
def test_customModifier(self):
69-
"""Super basic test of the Custom Modifier."""
70-
con = CustomModifier(self.cs, "FakeParam")
71-
self.assertEqual(con._parameter, "FakeParam")
72-
73-
# For testing purposes, we need to add a dummy perturbation
74-
fh = self.r.o.getInterface("fuelHandler")
75-
fh.applyCustomPerturbation = lambda val: val
76-
77-
con.convert(self.r)
78-
self.assertEqual(con._sourceReactor, self.r)

0 commit comments

Comments
 (0)