Fix overflow of Plexon in numpy 2.0 - #1613
Conversation
|
@h-mayorquin merge conflict from #1612. |
|
Solved. |
|
Cool. I'll double check this weekend :) |
zm711
left a comment
There was a problem hiding this comment.
One strategy question @h-mayorquin :)
| bl_header = data[pos : pos + 16].view(DataBlockHeader)[0] | ||
|
|
||
| # To avoid overflow errors when doing arithmetic operations on numpy scalars | ||
| np_scalar_to_python_scalar = lambda x: x.item() if isinstance(x, np.generic) else x |
There was a problem hiding this comment.
Is there a reason not to make this lambda function near the top so it is reusable. Or even define this as a true private function. How are you thinking about using the same lambda function twice being generated in the for loop. It should be relatively low cost although seems a bit of a waste no? We could define the function once and reuse in both the for loops, no?
There was a problem hiding this comment.
I figured you'd have checked. Fair enough. :)
| channel_headers = slowChannelHeaders[chan_index] | ||
|
|
||
| # To avoid overflow errors when doing arithmetic operations on numpy scalars | ||
| np_scalar_to_python_scalar = lambda x: x.item() if isinstance(x, np.generic) else x | ||
| channel_headers = {key: np_scalar_to_python_scalar(channel_headers[key]) for key in channel_headers.dtype.names} | ||
|
|
||
| name = channel_headers["Name"].decode("utf8") | ||
| chan_id = channel_headers["Channel"] |
There was a problem hiding this comment.
Last question.
so below you called it dsp_channel_headers which was really nice. Any interest in changing this to slow_channel_headers, just so we make sure we never accidentally overwrite any variable. I think the explicit makes it cleaner and since we are already fixing up the variable naming might be worth the push?
| bl_header = data[pos : pos + 16].view(DataBlockHeader)[0] | ||
|
|
||
| # To avoid overflow errors when doing arithmetic operations on numpy scalars | ||
| np_scalar_to_python_scalar = lambda x: x.item() if isinstance(x, np.generic) else x |
There was a problem hiding this comment.
I figured you'd have checked. Fair enough. :)
|
merci |

This should fix the errors in #1612.
At least for Plexon.