Give better error for non-finite values from nodes #1286
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and context:
This produces a slightly better error message when a node or direct mode ensemble produces non-finite values. By raising a
SimulationError
we make it clear that this is a problem that has to be solved on the user side and not some bug in the simulator (before one would get a FloatingPointError). The error message contains the name of the function (which might be<lambda>
which is not that helpful, but definitely better than before if it is not a lambda).I think for nodes it is correct to produce an error. In case of the direct mode ensemble with the function it would be nice if it would still run because it would run with non-direct mode ensembles. But to me it seems there is no logical value to set the result to and by not throwing an error it might seem like it works as intended, but does not. Like the Zen of Python says: “In the face of ambiguity, refuse the temptation to guess.”
I think we talked before about potentially implementing some sort of approximation of the neuron normalization in direct mode. This might solve this problem fully, but is also a much bigger jobs with some open questions.
Fixes #1280. Closes #1178.
Interactions with other PRs:
none
How has this been tested?
added tests
How long should this take to review?
Types of changes:
Checklist: