def protectedMul(left, right):
try:
return left * right
except OverflowError or ZeroDivisionError or FloatingPointError:
print(left, right)
return 1
Hi Nicola,
Well I cannot tell why you get these overflow errors, but the reason why you're not able to catch them is because your syntax is wrong. You should not use "except A or B or C", but "except (A, B, C)", as outlined in the Python doc : https://docs.python.org/3/tutorial/errors.html#handling-exceptions
Also, to get overflow on doubles, you need to have huge numbers, it would be important to check where they are coming from, assuming it is not a single, isolated case.
Marc-Andre
--
You received this message because you are subscribed to the Google Groups "deap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deap-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deap-users/5633509a-8777-460a-a44e-492f999bc12d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Nicola,
Well I cannot tell why you get these overflow errors, but the reason why you're not able to catch them is because your syntax is wrong. You should not use "except A or B or C", but "except (A, B, C)", as outlined in the Python doc : https://docs.python.org/3/tutorial/errors.html#handling-exceptions
Also, to get overflow on doubles, you need to have huge numbers, it would be important to check where they are coming from, assuming it is not a single, isolated case.
Marc-Andre
On 2019-06-06 13:33, Nicola Menga wrote:
Hi I'm new on deap, I'm getting this error during the evolution of a genetic program script: "RuntimeWarning: overflow encountered in double_scalars return left * right"--Can you help please? Thanks in advance!!I defined a function for multiplication in this way:
def protectedMul(left, right): try: return left * right except OverflowError or ZeroDivisionError or FloatingPointError: print(left, right) return 1
You received this message because you are subscribed to the Google Groups "deap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deap-...@googlegroups.com.