-
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
Assembly getParamOfZFunction
Interpolation Warning
#1997
Comments
For (1), we already test armi/armi/reactor/tests/test_assemblies.py Lines 921 to 938 in e777af7
That test says it tests |
I can look at updating our usage of the If it's just an API change, it's easy to handle. If it comes with numerical differences, it will take much longer to make the change. #fingers-crossed |
Thanks John. The issue was the offending test in question used the smallest test reactor of one assembly made of one block. When passed into the interpolator, it "failed" to interpolate over one z location and returned Nan with a warning. Apparently, this method used to fail when passed an array of one value to interpolate over but that functionality was changed a decade ago to only warn the user. The warnings were noticed in the unit tests, even though the tests passed. The original writers of the test should have known to use a larger test reactor, but neither the assembly method nor the interpolator gave them the information to know that unless they dug into the warnings - which they didn't. It would be helpful to have some guardrails around these kind of methods to avoid similar errors in the future. This is a nice to have, not urgent. |
Ouch. Yeah, switching from armi/armi/reactor/assemblies.py Lines 1137 to 1143 in cd616ed
The NumPy version is much simpler: |
The assembly method
getParamOfZFunction
interpolates a param axially to find it at any value of elevation z by using thescipy.interpolate.interp1d
method. There are two issues with the implementation of this assembly method:It was found in the unit tests of the
armi/physics/neutronics/globalFlux/globalFluxInterface.DoseResultsMapper
after it was moved out of ARMI in Removing DoseResultsMapper #1952, that if an assembly only returns one z location to interpolate over, thescipy.interpolate.interp1d
method will return a Nan value and a Runtime warning stating an invalid value was encountered. This behavior is undesirable as the associated unit tests still passed but with the warnings. The error was resolved by using a test reactor with more than one z location for interpolation. It would be beneficial to include logic in thegetParamOfZFunction
to check for more than one z location in the assembly to interpolate over.The
scipy.interpolate.interp1d
method is now an unmaintained legacy method: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html . The docs recommend updating any use ofinterp1d
withnumpy.interp
, sogetParamOfZFunction
should be updated to use the current recommended interpolation method. It's important to note thatnumpy.interp
doesn't even provide a warning if a single value is passed for interpolation, meaning the check proposed in the first point would still apply to using this interpolation method.The text was updated successfully, but these errors were encountered: