Commit e013d5b
Benjamin Moody
adc: optimize replacement of NaNs.
When converting physical to digital sample arrays, we must replace NaN
values with the appropriate invalid-sample sentinel value.
To do this, we need to call np.isnan and use the result as a mask to
replace entries in the output array. (Although the function
np.nan_to_num also exists, it's less efficient: it literally does just
this, but also handles infinities.)
What we don't need to do is to call any() to check whether there are
any true entries - that just means we're iterating through the same
array three times rather than once. Furthermore, np.copyto can
broadcast d_nans across the rows of p_signal, so all the channels can
be handled at once.
Also use copyto in adc_inplace_1d for consistency.1 parent 5a05f7a commit e013d5b
1 file changed
+2
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
542 | | - | |
| 542 | + | |
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
| 553 | + | |
557 | 554 | | |
558 | 555 | | |
559 | 556 | | |
| |||
0 commit comments