Detecting nan and other errors under program control
-
- Posts: 6
- Joined: Wed Sep 26, 2007 4:42 pm
how to check for nan values
Is there some way to programmatically detect the error when neuron variables go out of bounds? or some way to check if a stored value is NaN? I am running batch jobs of neuron and need a way to disregard bad results. thanks
-
- Posts: 6
- Joined: Wed Sep 26, 2007 4:42 pm
error detection
Is there a way to check for runtime errors/infinite values? Will neuron exit with an error code? Can somebody give me a hint on this please?
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
An ounce of prevention is worth a pound of cure. Examine your code and revise as
necessary to deal with unreasonably large exponents or divide by zero errors. "Usual
suspects" include HH-style ionic conductances whose rate constants are specified by
functions that become 0/0 at half-activation points (easily dealt with via Lhospital's rule).
If you believe that NEURON is generating such errors "internally"--i.e. they aren't
"programmed into" your code--please let us know so we can look for bugs or try to devise
strategies for preventing such occurrences.
necessary to deal with unreasonably large exponents or divide by zero errors. "Usual
suspects" include HH-style ionic conductances whose rate constants are specified by
functions that become 0/0 at half-activation points (easily dealt with via Lhospital's rule).
If you believe that NEURON is generating such errors "internally"--i.e. they aren't
"programmed into" your code--please let us know so we can look for bugs or try to devise
strategies for preventing such occurrences.
Re: Detecting nan and other errors under program control
So is there a way in the hoc language to see if e.g. soma.v(0.5) is not "nan" ?
I need this, because I'm doing parameter searching, and apparently some parameter sets generate results with "nan", in which case I need to detect this.
Thank you,
Werner Van Geit
I need this, because I'm doing parameter searching, and apparently some parameter sets generate results with "nan", in which case I need to detect this.
Thank you,
Werner Van Geit
Re: Detecting nan and other errors under program control
You can compare numbers as strings. Consider
oc>for (a=1; strcmp(s, "inf") != 0; a *= 2) { sprint(s, "%g", a) print a }
The last two things it prints on my machine are:
8.9884657e+307
inf
oc>for (a=1; strcmp(s, "inf") != 0; a *= 2) { sprint(s, "%g", a) print a }
The last two things it prints on my machine are:
8.9884657e+307
inf