Repository navigation
Accept sample numbers stored as floats in wrann - #625
Open
tompollard wants to merge 2 commits into
Open
tompollard wants to merge 2 commits into
tompollard wants to merge 2 commits into
Conversation
wrann failed with "ufunc 'bitwise_and' not supported" when sample was a float array, which is easy to get from a detector or model. Accept float sample numbers if they are all whole numbers, and convert them to integers when writing, without changing the caller's array. Other floats (fractions, NaN, infinity) raise a ValueError. Other dtypes are handled as before.
On x86, np.mod(inf, 1) sets the invalid flag, which the tests turn into a FloatingPointError. Reject NaN and infinity first, and compare finite values with their rounded values instead.
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 #201.
wrannfailed with an unhelpful error whensamplewas a float array, which is easy to get from a detector or model:The float values reached the bit operations in
field2bytes, which only work on integers.20.5, NaN or infinity) raiseValueError: The 'sample' field must only contain whole numbers.This matches the other integer fields (
subtype,chan,numandlabel_store), which already accept whole-number floats.Tests: a float array gives the same file as an integer array (including a gap large enough to need a SKIP), and fractions, NaN and infinity raise a
ValueError. All four fail onmain.