genn icon indicating copy to clipboard operation
genn copied to clipboard

more meaningful assertions?

Open tnowotny opened this issue 4 years ago • 1 comments

When trialling the latest version of Manvi's superspike experiments I discovered an error made when cleaning up, where the value of an extra global parameter was set with a wrong name - so it did not exist and triggered failure in this assertion: https://github.com/genn-team/genn/blob/da419e03a8ca03ed484ce61d1e18251f8c2c86fb/pygenn/genn_groups.py#L110 Would it not be nicer to do something like

class GeNNError(Exception):
    pass
...
if param_type is None:
    raise GeNNError("The extra global parameter "+param_name+" does not exist in "+model.name)

tnowotny avatar Dec 23 '20 10:12 tnowotny

Totally agree - asserts should only be for internal errors not things caused by user error. We don't currently define our own exception types so just throwing a RuntimeError would be an improvement.

On Wed, 23 Dec 2020, 10:46 Thomas Nowotny, [email protected] wrote:

When trialling the latest version of Manvi's superspike experiments I discovered an error made when cleaning up, where the value of an extra global parameter was set with a wrong name - so it did not exist and triggered failure in this assertion:

https://github.com/genn-team/genn/blob/da419e03a8ca03ed484ce61d1e18251f8c2c86fb/pygenn/genn_groups.py#L110 Would it not be nicer to do something like

class GeNNError(Exception): pass ...raise GeNNError("The extra global parameter "+param_name+" does not exist in "+model.name)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/genn-team/genn/issues/382, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT2QGWZLM5PDIG7LZGB3C3SWHDA7ANCNFSM4VG2SW5Q .

neworderofjamie avatar Dec 23 '20 10:12 neworderofjamie