Fix error when saving array with NaNs (occurs with corr_img when use_corr_img is True) #1385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The function
recursively_save_dict_contents_to_group
checks that an ndarray was written correctly to the HDF5 file by callingnp.array_equal
, but it currently does not set the optionequal_nan=True
, meaning that if there are any NaNs in the array, it returns false. Regardless of whether NaNs are expected, this is probably not what we want if we are just doing a fidelity check.I initially tried just changing this to true, but apparently it can fail with a TypeError ("ufunc 'isnan' not supported for the input types") in some cases. So I changed it to only be true if the ndarray is of a floating-point type, which seems to work.
Type of change
Please delete options that are not relevant.
Has your PR been tested?
Have not tested beyond this; may be good to add a unit test for it, which I can come back and do later.