Skip to content

Conversation

@CozySocksAlways
Copy link
Contributor

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

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 88.268% (+0.006%) from 88.262%
when pulling 07e3fc5 on INM-6:fix/van-rossum-nan
into 5392583 on NeuralEnsemble:master.

@CozySocksAlways CozySocksAlways marked this pull request as ready for review November 27, 2025 07:59
@mdenker mdenker added this to the v1.2.0 milestone Dec 1, 2025
@CozySocksAlways CozySocksAlways added the bugfix Fix for an indentified bug. label Dec 1, 2025
@kohlerca kohlerca self-requested a review December 2, 2025 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fix for an indentified bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Underflow: Negative value in van_rossum_distance function

3 participants