Skip to content

Commit

Permalink
Fixing issue with adding a Setting option (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Jan 20, 2022
1 parent 33def90 commit 9813a0c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
2 changes: 1 addition & 1 deletion armi/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Metadata describing an ARMI distribution.
"""

__version__ = "0.2.1"
__version__ = "0.2.2"
2 changes: 1 addition & 1 deletion armi/settings/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def __copy__(self):
isEnvironment=bool(self.isEnvironment),
oldNames=None if self.oldNames is None else list(self.oldNames),
)
setting.value = copy.deepcopy(self._value)
setting._value = copy.deepcopy(self._value)
return setting


Expand Down
38 changes: 38 additions & 0 deletions armi/settings/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@

import armi
from armi.physics.fuelCycle import FuelHandlerPlugin
from armi.physics.neutronics import settings as neutronicsSettings
from armi import settings
from armi.settings import caseSettings
from armi.settings import setting
from armi.operators import settingsValidation
from armi.tests import TEST_ROOT
from armi import plugins
from armi.utils import directoryChangers
from armi.reactor.flags import Flags
Expand Down Expand Up @@ -64,6 +66,16 @@ def defineSettings():
]


class PluginAddsOptions(plugins.ArmiPlugin):
@staticmethod
@plugins.HOOKIMPL
def defineSettings():
return [
setting.Option("MCNP", "neutronicsKernel"),
setting.Option("MCNP_Slab", "neutronicsKernel"),
]


class TestCaseSettings(unittest.TestCase):
def setUp(self):
self.cs = caseSettings.Settings()
Expand All @@ -86,6 +98,32 @@ def test_updateEnvironmentSettingsFrom(self):
self.assertEqual(self.cs["verbosity"], "9")


class TestAddingOptions(unittest.TestCase):
def setUp(self):
self.dc = directoryChangers.TemporaryDirectoryChanger()
self.dc.__enter__()

def tearDown(self):
self.dc.__exit__(None, None, None)

def test_addingOptions(self):
# load in the plugin with extra, added options
pm = armi.getPluginManagerOrFail()
pm.register(PluginAddsOptions)

# modify the default/text settings YAML file to include neutronicsKernel
fin = os.path.join(TEST_ROOT, "armiRun.yaml")
txt = open(fin, "r").read()
txt = txt.replace("\n nodeGroup:", "\n neutronicsKernel: MCNP\n nodeGroup:")
fout = "test_addingOptions.yaml"
open(fout, "w").write(txt)

# this settings file should load fine, and test some basics
cs = settings.Settings(fout)
self.assertEqual(cs["burnSteps"], 2)
self.assertEqual(cs["neutronicsKernel"], "MCNP")


class TestSettings2(unittest.TestCase):
def setUp(self):
# We are going to be messing with the plugin manager, which is global ARMI
Expand Down
20 changes: 18 additions & 2 deletions doc/release/0.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ ARMI v0.2 Release Notes
=======================


ARMI v0.2.2
ARMI v0.2.3
===========
Release Date: TBD

What's new in ARMI v0.2.2
What's new in ARMI v0.2.3
-------------------------
#. TBD

Expand All @@ -16,6 +16,22 @@ Bug fixes
#. TBD


ARMI v0.2.2
===========
Release Date: 2022-01-19

What's new in ARMI v0.2.2
-------------------------
#. Improved type hinting
#. Flushed out the ability to build the docs as PDF
#. Material modifications can now be made per-component
#. The ``loadOperator`` method now has the optional ``allowMissing`` argument

Bug fixes
---------
#. Fixed issue where copying a Setting with a defined list of options would throw an error (`PR#540 <https://github.com/terrapower/armi/pull/540>`_)


ARMI v0.2.1
===========
Release Date: 2022-01-13
Expand Down

0 comments on commit 9813a0c

Please sign in to comment.