-
Notifications
You must be signed in to change notification settings - Fork 92
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
Update the check for a jagged array during _writeParams
#2051
base: main
Are you sure you want to change the base?
Conversation
…xing the list after jagged was deemed false
_writeParams
@john-science it doesn't return anything cause all it does is write things to the DB. Towards the bottom of the method you see this: |
Okay, one option is to move this private function out to being a regular, private method: armi/armi/bookkeeping/db/database.py Lines 918 to 925 in 85053e3
And then add some unit tests. class Database:
@staticmethod
def _getShape(arr: [np.ndarray, List, Tuple]): |
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.
Nice catch!
…riteanythingforparams-butiwontwritethat
…://github.com/terrapower/armi into iwillwriteanythingforparams-butiwontwritethat
…riteanythingforparams-butiwontwritethat
What is the change?
Scenario where
jagged
evaluates toFalse
has a loophole (with py313 and numpy 2.2.1): single-element numpy arrays mixed into a list with non-array entries fails in_writeParams
. (Edit: it wasn't a loophole...it's that I was previously using a very old version of numpy that allowed jagged arrays, and so the parameter that ended up as a jagged array slipped through the cracks.)This updates the check for
jagged
to account for this scenario by editing_getShape
.Why is the change being made?
I was getting this failure sometimes while running cases (with py313 and numpy 2.2.1):
This is because the logic for determining whether something is a jagged array misses the scenario where single element numpy arrays are mixed with non array/list entries. The code in
_getShape
evaluates to(1,)
for all these array entries AS WELL AS forint
,float
, orNone
, which means thejagged
check evaluates toFalse
. Thennp.array(temp)
fails with the above error. So I have the_getShape
helper function return1
for the latter scenario. Then the set for a list of elements mixed with single element arrays is{(1,), 1}
, and causesjagged
to beTrue
.Jagged or not jagged, that is the question
We can nix the above update and keep
jagged
asFalse
by editing the temp list like so:I'm just assuming we want
jagged
to be true, so went with the solution in the PR. Also, this edits the list after the fact. I don't care either way.Checklist
doc
folder.pyproject.toml
.