Skip to content
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

Merged
merged 10 commits into from
Jun 21, 2023

Conversation

onufer
Copy link
Member

@onufer onufer commented Jun 17, 2023

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

  • This PR has only one purpose or idea.
  • Tests have been added/updated to verify that the new/changed code works.
  • The release notes (location doc/release/0.X.rst) are up-to-date with any important changes.
  • The documentation is still up-to-date in the doc folder.
  • The dependencies are still up-to-date in setup.py.

@onufer onufer requested a review from albeanth June 17, 2023 14:45
@@ -272,7 +272,7 @@ def __iter__(self):
--------
getAssemblies()
"""
return iter(sorted(self._children))
return iter(self._children)
Copy link
Member Author

@onufer onufer Jun 17, 2023

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

@onufer onufer requested a review from opotowsky June 17, 2023 14:53
@onufer onufer mentioned this pull request Jun 17, 2023
7 tasks
@@ -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):
Copy link
Member Author

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):
Copy link
Member Author

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()
Copy link
Member Author

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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes broken unit test

Copy link
Member

@opotowsky opotowsky left a 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!

doc/release/0.2.rst Outdated Show resolved Hide resolved
doc/release/0.2.rst Outdated Show resolved Hide resolved
@onufer onufer marked this pull request as ready for review June 21, 2023 18:08
Co-authored-by: Arrielle Opotowsky <c-aopotowsky@terrapower.com>
@opotowsky opotowsky merged commit f79ec01 into main Jun 21, 2023
@opotowsky opotowsky deleted the sortAssemByRing branch June 21, 2023 19:03
@john-science john-science added the feature request Smaller user request label Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Smaller user request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants