-
Notifications
You must be signed in to change notification settings - Fork 195
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
Deal with unsigned int to int conversion #1707
Conversation
Cool! This one would be mildly surprising to me to me since the behavior is different from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not seen the other issue but I think that astype preprocessing should behave in exactly the same way as numpy.astype. Just because that is the behavior that our users will probably expect. Is this the case?
Edit: after thinking about it I am less sure. I will need to think.
|
||
|
||
def test_astype(): | ||
traces = (np.random.rand(10000, 4) * 100).astype("float32") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these tests will work better with a user defined traces
Just write something like [1.0 ,3.0, 5.0, ...] or at least let's make them non-deterministic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to leave randomness here. It should work in any case since it's only casting the dtypes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is unlikely to create a problem here but I also don't see why the randomness is required. If it is meant to work as a test then it should be reproducible so you can debug it if it fails. But here, the failure is unlikely to come from randonmess so not a big concern ...
Anyway, not a big deal:
"A foolish consistency is the hobgoblin of little minds"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll set a seed ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@cwindolf @h-mayorquin made a new preprocessor Ready to review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me:
- Comment about docstrings which I think will be useful to have for us to remember and users for knowing what to expect. I think this will be good to add.
- Style comments as suggestions / discussion. Feel free to ignore them.
src/spikeinterface/preprocessing/tests/test_unsigned_to_signed.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good ot me.
I think we could have better implementation using numpy view. No one gave time to give feedback. |
@samuelgarcia it's been open for 3 weeks! |
Wrote some thoughts on #1748 |
Fixes #1702 so you can do the following for a recording of typoe unsigned:
Internally, it takes care of upcasting and removing the
2**(nbits-1)
offset before adding the sign (to avoid overflow errors).Also added some tests ;)