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

Cleanup of determineTargetComponent #1230

Merged
merged 7 commits into from
Apr 25, 2023

Conversation

albeanth
Copy link
Member

@albeanth albeanth commented Mar 31, 2023

Description

This PR brings in various improvements to axialExpansionChanger.py::ExpansionData::determineTargetComponent.

  1. if Flags do not produce a target component, the component and block types are now checked. This is useful for the case where you have a target component that does not have a flag defined.
    Rolled this back and users should use the block attribute axial expansion target component introduced in Enable Users To Explicitly Specify Target Component for Axial Expansion #777 .
  2. Closes Single component block axial expansion #1197.
  3. Overhauled and improved the unit testing for the method.

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 bug fixes or new features.
  • The documentation is still up-to-date in the doc folder.
  • The dependencies are still up-to-date in setup.py.

- now checks type in addition to flags if flags doesn't produce a target component
- and is smart enough to set teh target component when there's a single solid component
- overhauled and improved the unit testing
@albeanth albeanth added enhancement New feature or request cleanup Code/comment cleanup: Low Priority labels Mar 31, 2023
@albeanth albeanth requested review from onufer and keckler March 31, 2023 22:25
@albeanth albeanth marked this pull request as ready for review March 31, 2023 22:25
Comment on lines 854 to 856
componentWFlag = [
c for c in b if (c.p.type in b.p.type or b.p.type in c.p.type)
]
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand what the underlying assumption is here that makes this a valid thing to do. Basically you're saying that if a component in the block has the same name as the block itself then it should be the target component?

Copy link
Member

Choose a reason for hiding this comment

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

It might be good to consider components by name since there is no guarantee that this will work for all block types and might be fragile. Is it worth considering a refactor for always using a component name or first flags and then name?

Copy link
Member Author

@albeanth albeanth Apr 3, 2023

Choose a reason for hiding this comment

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

@jakehader Can you elaborate on why you think checking block types is fragile? Or more fragile than checking names?

We've had good success (I think) using the flags-based approach, so I would advocate that we keep using that as the primary methodology to obtain the axial expansion target component. Adding a check on type was recently requested to enable the axial expansion changer to work for cases when there is a component defined in the blueprints that does not have a flag registered for it and where there was not a desire to modify the source code to register a new flag.

I'll tag you and @keckler where the corresponding unit test is.

Copy link
Member Author

Choose a reason for hiding this comment

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

After some offline discussions, this type check was rolled back in d9d138b.

For the case in which a block contains a component that does not have Flags defined.
So instead of matching on flags, we match on type.
"""
b = HexBlock("detector", height=10.0)
Copy link
Member Author

Choose a reason for hiding this comment

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

@keckler @jakehader Here is the unit test that leverages the type checking.

This block, "detector", contains a "detector" component. Since "detector" is not a registered flag the flag-based approach won't work. So our options are to either 1) modify source code to add a new flag, or 2) add a new capability to infer target components based on something other than flags. I got feedback that option 2 was more desirable and that checking types could be an option.

The logic for c.p.type in b.p.type or b.p.type in c.p.type is to try and accommodate the case where the strings that define the component and block types aren't exactly the same. In this test, the component type is detector neutron and the block type is neutron. In this case the component type isn't "in" the block type, but the block type is "in" the component type. If the types were reversed, the opposite would be true (i.e., the component type would be "in" the block type).

Hopefully that's not as clear as mud...

Copy link
Member

Choose a reason for hiding this comment

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

Isn't there a third option? To specify the target component on the blueprints using axial expansion target component? I'm just kinda confused why this change is necessary in the first place, but maybe I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that is a third, and very valid, option.

This PR is in response to a series of requests to not have to use that blueprints attribute.

Copy link
Member Author

Choose a reason for hiding this comment

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

After some offline discussions, this type check was rolled back in d9d138b.

@albeanth albeanth changed the title Slight refactor of determineTargetComponent Cleanup of determineTargetComponent Apr 3, 2023
@albeanth albeanth marked this pull request as draft April 19, 2023 22:28
@albeanth
Copy link
Member Author

This PR is ready, but I am converting to draft while we figure out downstream merge dependencies.

@albeanth albeanth marked this pull request as ready for review April 25, 2023 15:07
@albeanth albeanth merged commit 22d61e5 into terrapower:main Apr 25, 2023
@albeanth albeanth deleted the updateDetermineTargetComp branch April 25, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code/comment cleanup: Low Priority enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single component block axial expansion
3 participants