Skip to content

Commit

Permalink
Fixing the Setting copy to also copy non-default values. (#534)
Browse files Browse the repository at this point in the history
It appears that a recent PR removed a single line of code from setting.py,
this has lead to a invisibly broken system that works for nearly all unit
tests. I have added a unit test to explicitly check for this important
feature in the future.
Also, bumped the ARMI version to 0.2.1.
  • Loading branch information
john-science committed Jan 14, 2022
1 parent 21a451a commit 14be902
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion armi/meta.py
Expand Up @@ -16,4 +16,4 @@
Metadata describing an ARMI distribution.
"""

__version__ = "0.2.0"
__version__ = "0.2.1"
1 change: 1 addition & 0 deletions armi/settings/setting.py
Expand Up @@ -326,6 +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)
return setting


Expand Down
19 changes: 19 additions & 0 deletions armi/settings/tests/test_settings.py
Expand Up @@ -303,6 +303,25 @@ def test_copySetting(self):
self.assertTrue(hasattr(s2, "schema"))
self.assertTrue(hasattr(s2, "_customSchema"))

def test_copySettingNotDefault(self):
"""Ensure that when we copy a Setting() object, the result is sound
when the Setting value is set to a non-default value.
"""
# get a baseline: show how the Setting object looks to start
s1 = setting.Setting("testCopy", 765)
s1.value = 999
self.assertEquals(s1.name, "testCopy")
self.assertEquals(s1._value, 999)
self.assertTrue(hasattr(s1, "schema"))
self.assertTrue(hasattr(s1, "_customSchema"))

# show that copy(Setting) is working correctly
s2 = copy.copy(s1)
self.assertEquals(s2._value, 999)
self.assertEquals(s2.name, "testCopy")
self.assertTrue(hasattr(s2, "schema"))
self.assertTrue(hasattr(s2, "_customSchema"))


class TestSettingsConversion(unittest.TestCase):
"""Make sure we can convert from old XML type settings to new Yaml settings."""
Expand Down
16 changes: 15 additions & 1 deletion doc/release/0.2.rst
Expand Up @@ -3,10 +3,23 @@ ARMI v0.2 Release Notes
=======================


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

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

Bug fixes
---------
#. TBD


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

What's new in ARMI v0.2.1
-------------------------
#. Added new reference data for lumped fission products (`#507 <https://github.com/terrapower/armi/issues/507>`_)
Expand All @@ -15,6 +28,7 @@ Bug fixes
---------
#. Fixed issue where grid GUI was not saving lattice maps (`#490 <https://github.com/terrapower/armi/issues/490>`_)
#. Fixed issue where SettingsModifier was using old Settings API (`#500 <https://github.com/terrapower/armi/issues/500>`_)
#. Fixed issue where copying a Setting only copied the default value (`PR#534 <https://github.com/terrapower/armi/pull/534>`_)


ARMI v0.2.0
Expand Down

0 comments on commit 14be902

Please sign in to comment.