Reputation: 25508
The first time I do something that raises a warning in the IPython shell, I see it. But subsequent times I do not. For example,
In [1]: import numpy as np
In [2]: np.uint8(250) * np.uint8(2)
/Users/me/anaconda/envs/py33/bin/ipython:1: RuntimeWarning: overflow encountered in ubyte_scalars
#!/bin/bash /Users/me/anaconda/envs/py33/bin/python.app
Out[2]: 244
In [3]: np.uint8(250) * np.uint8(2)
Out[3]: 244 # No warning!
How do I configure IPython to always show warnings? I've tried:
import warnings
warnings.filterwarnings('always')
But that doesn't make any difference.
Upvotes: 12
Views: 2898
Reputation: 353059
I think this was addressed relatively recently by the IPython team. It wasn't playing well with warnings
because of a somewhat unusual design decision. Turing on always
suffices for me in plain Python, and now if I do the same thing in IPython trunk:
In [1]: import warnings
In [2]: warnings.filterwarnings('always')
In [3]: import numpy as np
In [4]: np.uint8(250) * np.uint8(2)
/home/dsm/sys/root/bin/ipython3.4:1: RuntimeWarning: overflow encountered in ubyte_scalars
#!/home/dsm/sys/root/bin/python3.4
Out[4]: 244
In [5]: np.uint8(250) * np.uint8(2)
/home/dsm/sys/root/bin/ipython3.4:1: RuntimeWarning: overflow encountered in ubyte_scalars
#!/home/dsm/sys/root/bin/python3.4
Out[5]: 244
Upvotes: 12