[Numpy-discussion] 0/0 == 0?
Georg Brandl
g.brandl at gmx.net
Sat Oct 4 03:50:37 EDT 2014
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
More information about the NumPy-Discussion
mailing list