elephant icon indicating copy to clipboard operation
elephant copied to clipboard

Clip small negative values in van_rossum_distance before np.sqrt

Open CozySocksAlways opened this issue 1 month ago • 2 comments

This PR fixes Issue #679 . Currently van_rossum_distance could return nan due to extremely small negative values because of floating point errors before applying np.sqrt.

Fix Added check before np.sqrt to find small negative values, then replaced them using np.maximum(vr_dist,0). Also outputs runtime warning for transparancy. This ensures that spike trains that should result in a distance of 0 no longer produce nan.

Test Added unit test that reproduces the spike train scenario from the issue, it asserts that the computed distance is 0 and not nan

CozySocksAlways avatar Nov 27 '25 07:11 CozySocksAlways

Coverage Status

coverage: 88.289% (+0.006%) from 88.283% when pulling cd3f15fa452b63d7ab285b8c1539bbae1b489f91 on INM-6:fix/van-rossum-nan into 867a0fcb103923d0013edc4269aa4479acbbdc1a on NeuralEnsemble:master.

coveralls avatar Nov 27 '25 07:11 coveralls

The implementation looks good. I made small suggestions to improve the warnings and structure of the unit test.

kohlerca avatar Dec 12 '25 09:12 kohlerca