Repository navigation
Conversation
The all-NaN guard in calc_adc_gain_baseline compared pmin == np.nan, which is always False, so a channel containing only NaN values fell through to the regular case and failed with "cannot convert float NaN to integer". Use np.isnan instead. Compute the channel minimum and maximum with np.fmin/np.fmax.reduce, which ignore NaN like nanmin/nanmax but do not warn about all-NaN channels.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #485.
Writing a record where one channel is entirely NaN fails:
Both causes are the ones described in the issue:
calc_adc_gain_baselinecheckedpmin == np.nan, which is always False, so the all-NaN branch never ran. It now usesnp.isnan(pmin).calc_adc_paramsusednp.nanmin/np.nanmax, which warn on all-NaN channels. It now usesnp.fmin.reduce/np.fmax.reduce(as suggested in the issue), which give the same result without the warning, for bothp_signalande_p_signal.An all-NaN channel now gets
adc_gain=1,baseline=1(the existing intent of that branch), is written as the NaN sample value, and reads back as NaN.Testing:
TestSignal.test_all_nan_channel(runs with RuntimeWarning as an error): checkscalc_adc_paramsforp_signalande_p_signal, then awrsamp/rdrecordround trip with one all-NaN channel and one normal channel. It fails onmainand passes with this change.uv run pytest -m "not network": 335 passed.ruff format --check,ruff checkandtowncrier build --draftpass. Changelog entry added inchangelog.d/.