On 10/03/2014 11:24 PM, Charles R Harris wrote:

> What I want is that the following script would warn three times
> 
> import numpy as np
> 
> z = np.zeros(1, dtype=np.int <http://np.int>)
> 
> def f(x):
>     return x/x
> 
> f(z)
> f(z)
> f(z)
> 
> But it only warns once. That is not helpful when f gets called with an 
> erroneous
> argument from different places.

Add

import warnings
warnings.simplefilter('always', RuntimeWarning)

to get that effect.  And as said before, if Numpy uses its own warning class
it can put this filter in place automatically on import.

You might also argue on python-dev to make RuntimeWarning default to
"always" behavior in CPython, since dubious runtime features should always
warn.

Georg

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to