-
Notifications
You must be signed in to change notification settings - Fork 89
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
Implement more detailed __lt__
for components.
#1882
base: main
Are you sure you want to change the base?
Conversation
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.
Of the 21 files changed here, maybe three of them are actually related to the heart of this PR and touch the __lt__
changes.
They're not bad changes per se, but they are nearly entirely import related changes: sorting of imports, breaking multiple imports, importing just the module not the things needed in the module. They just added extraneous diffs to this PR.
What can we collectively do to avoid this? There's probably some linter / formatting config we can add, maybe some "blessed" vs code related settings we can advertise. But, these changes make it hard to agree that "this PR has one idea or purpose" with the extra, unrelated changes
armi/reactor/components/__init__.py
Outdated
def getCircleInnerDiameter(self, Tc=None, cold=False): | ||
""" | ||
Approximate the component as circular; i.e., inner diameter is zero. | ||
|
||
Parameters | ||
---------- | ||
Tc : float | ||
Ignored for this component | ||
cold : bool, optional | ||
If True, compute the area with as-input dimensions, instead of thermally-expanded. | ||
|
||
Notes | ||
----- | ||
Tc is not used in this method for this particular component. | ||
""" | ||
return 0.0 |
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 seems like an okay thing for a shaped component to have to define on their own. Maybe a DerivedShape
is the only exception.
Saying this because we try
/catch
a NotImplementedError
below so if Component.getCircleInnerDiameter
is required for components, we'd be okay in that context.
But that could be a larger change that is likely better served outside this PR.
Non-blocking comment. If there's traction I can make a ticket
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.
The assumption for the unshaped component is to return the smallest possible bounding circle outer diameter, i.e., assume the component has a disk shape. It seems consistent with that assumption to assume that the inner diameter is 0.0.
The exception is caught in __lt__
, but only for the purpose of producing a clearer error message. The error is still raised and the code crashes. So we still need to be able to sort UnshapedComponent
s.
Sorry, I'm in the middle of working on this. The root of the problem is that I ran into a circular import, and all of the import changes are related to fixing the circular import. It started small and then I went down a rabbit hole -- I'll probably break those changes out into a separate PR now. |
Fix getBoundingCircleOuterDiameter to return a diameter instead of a radius.
@@ -20,8 +20,7 @@ | |||
""" | |||
import math | |||
|
|||
from armi.reactor.components import ShapedComponent | |||
from armi.reactor.components import componentParameters | |||
from armi.reactor.components.component import ShapedComponent, componentParameters |
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.
Mike, can we fix your IDE?
I don't particularly like these changes, and they make your PRs more muddled to read. Like... you didn't actually touch this file.
#sorry
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.
Sure thing. I was able to turn it off, so I'll go through and revert these import changes.
Co-authored-by: John Stilley <[email protected]>
Co-authored-by: John Stilley <[email protected]>
…nto component_sort
What is the change?
Fall back to
getCircleInnerDiameter
for comparison when sorting components whengetBoundingCircleOuterDiameter
is equivalent.Why is the change being made?
Components on a block are sorted by their
getBoundingCircleOuterDiameter
. Sometimes, two components have the same outer diameter, in which case the sorting done by__lt__
will depend on the order of comparison. i.e.,a < b
evaluates toFalse
b < a
also evaluates toFalse
b == a
evaluates toTrue
, even though the two components are not necessarily identical, they only have one identical dimension.sorted([a, b]) != sorted([b, a])
even thoughb
anda
are not identical.Close #1875
Checklist
doc
folder.pyproject.toml
.