Skip to content
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

Simplify length computations / protect from wraparounds #250

Merged
merged 1 commit into from Apr 6, 2020

Conversation

JelleAalbers
Copy link
Member

For late records in pulses longer than 32767 samples (327.67 us at 10 ns, 65.5 us at 2ns resolution), the computation

len(record['data']) * record['record_i']

will result in an integer wraparound to negative values, since the record_i field is a 16 bit integer.

For the situations I tested, it seems this does NOT happen in numba compiled functions, only in pure numpy/python. So most of strax is safe. In any case, such long pulses should be pretty rare.

Nonetheless, I went through the code and removed places where we rely on this computation. There were several places where we did min(samples_per_record, pulse_length - record_i * record_length), but this is identically equal to length.

I also removed an unused and non-working data reduction function (replace_with_spike).

@JelleAalbers JelleAalbers merged commit b58d744 into master Apr 6, 2020
@JelleAalbers JelleAalbers deleted the protect_wraparound branch April 6, 2020 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant