I have an expression that overflows for specific parameter values. In this case, I got what I should use the asymptotic result, using a pen and paper, and when I have such a case, I just replace it with my analytical expression.
At the moment, my code is doing something like this:
values = ExpressionThatOverFlows()
My problem is that I / O explodes with "warnings." I know that itโs good that he is warning me, but I obviously took care of this, so I want to silence them. Please note that I do not want to silence all types of overflow warnings, only those that are here. I thought something like this would work, but it is not:
try: values = ExpressionThatOverFlows() except Warning: pass
I checked, but it just seems to me how to silence these warnings for the entire session or forever, but this is how I pointed out not what I want.
Thank you for your help, very grateful.
EDIT: Here comes a much smaller code that generates the problem that I have:
from scipy import log1p, exp from numpy import array, isnan a = array([0.2222, 500.3, 0.3, 700.8, 0.111]) values = log1p(-exp(-exp(10**a - 9**a))) print values
Notice how I fix the problem โmanuallyโ at the end, but what happens in I / O:
Warning: overflow encountered in power Warning: overflow encountered in power Warning: invalid value encountered in subtract
I do such calculations in a loop, so I want to disable these messages (since they are already fixed and, in addition, they take a lot of time to print)