NumPy, RuntimeWarning: invalid value encountered in power
Sometimes I get this in a long and confusing algorithms. How can I get more information out if it. For instance the exact line where it goes wrong and what the values are at that time. for instance if I have a function like this:
def func(x):
for i in range(100):
" do something with x , y
And I use the function
test = func(x)
> NumPy, RuntimeWarning: invalid value encountered in power
How can see the the values of x,y,i
at the time of failure?
I have looked at this NumPy, RuntimeWarning: invalid value encountered in power which does not answer my question because it explains how to avoid it but how get the specific information I want to.
EDIT I have tried:
x = np.random.randint(100)
try:
test = func( x )
except:
pass
But I don't how to use the pass function to get the desired information? Why is "except: pass" a bad programming practice?