-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sortAssemsByRing to sort the reactor assemblies by ring #1320
Conversation
@@ -272,7 +272,7 @@ def __iter__(self): | |||
-------- | |||
getAssemblies() | |||
""" | |||
return iter(sorted(self._children)) | |||
return iter(self._children) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sorting itter will guarantee list accessing and iteration will not be out of sync. otherwise index accessing can be different from itter order
@@ -2681,7 +2681,7 @@ def sort(self): | |||
|
|||
# recursively sort the children below it. | |||
for c in self._children: | |||
if issubclass(Composite, c.__class__): | |||
if issubclass(c.__class__, Composite): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bug that caused no recursive sorting since its never true.
@@ -272,6 +270,25 @@ def test_factorySortSetting(self): | |||
a1 = [a.name for a in r1.core] | |||
self.assertNotEqual(a0, a1) | |||
|
|||
def test_sortChildren(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test failed on main due to the if issubclass(c.__class__, Composite):
issue
@@ -179,7 +179,6 @@ def loadTestReactor( | |||
assemblies.setAssemNumCounter(assemNum) | |||
settings.setMasterCs(o.cs) | |||
o.reattach(r, o.cs) | |||
r.sort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are not needed since its sorted on initialization as the test below shows.
@@ -53,7 +53,8 @@ | |||
"metadata": {}, | |||
"outputs": [], | |||
"source": [ | |||
"o=armi.init(fName=\"anl-afci-177.yaml\");" | |||
"o=armi.init(fName=\"anl-afci-177.yaml\");\n", | |||
"o.r.core.sortAssemsByRing() # makes innermost assemblies appear first" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes broken unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For how difficult this was (mostly from the bug) the resulting code update is pretty simple.
Assuming the downstream effects are OK, I think the PR looks good!
Co-authored-by: Arrielle Opotowsky <c-aopotowsky@terrapower.com>
What is the change?
Fix bug in reactor sorting that didn't recursively sort
Add sortAssemsByRing method to sort assembly from inner to outer.
Why is the change being made?
for ease of postprocessing. a full sort caused many internal unit test issues.
#1305
Checklist
doc/release/0.X.rst
) are up-to-date with any important changes.doc
folder.setup.py
.