elephant
elephant copied to clipboard
fix/#410, UE cast to int in 'unsafe' mode
This PR addresses Issue #410
The following error occurred in https://github.com/NeuralEnsemble/elephant/blob/0df45812b93229b3186c061cb84ec29fd380e09c/elephant/unitary_event_analysis.py#L585
TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'
This might be fixed by using np.astype(int) instead of np.in64() to cast to int.
np.astype
allows 'unsafe' casting by default, see:
https://numpy.org/doc/stable/reference/generated/numpy.ndarray.astype.html
The numpy documentation suggest the following for casting:
To convert the type of an array, use the .astype() method (preferred) or the type itself as a function. For example:
z.astype(float)
array([0., 1., 2.])
np.int8(z)
array([0, 1, 2], dtype=int8)
See: https://numpy.org/doc/stable/user/basics.types.html
I suggest to follow numpys preferred method, but I don't have a strong opinion on this.
Hey @sanjayankur31 ,
This should fix in PR #410 , please let me know if this solves the issue.
Thanks, it's on my list, just not managed to get to it yet. Will hopefully find some time in the next couple of days.
Seems to fix the issue on arm, all tests pass with this set of changes:
https://koji.fedoraproject.org/koji/taskinfo?taskID=91845461
Fedora's also dropped armv7hl support from the next release (F37), so we shouldn't have armv7hl related issues in the future:
https://www.fedoraproject.org/wiki/Changes/RetireARMv7
Thanks @sanjayankur31 for having a look.
Build report looks good: https://koji.fedoraproject.org/koji/taskinfo?taskID=91845461