[Numpy-discussion] How to trigger warnings for integer division in python 2
Stuart Berg
stuarteberg at gmail.com
Fri Aug 19 11:29:29 EDT 2016
Hi,
To help people migrate their code bases from Python 2 to Python 3, the
python interpreter has a handy option '-3' that issues warnings at
runtime. One of the warnings is for integer division:
$ echo "print 3/2" > /tmp/foo.py
$ python -3 /tmp/foo.py
/tmp/foo.py:1: DeprecationWarning: classic int division
print 3/2
1
But no warnings are shown for division of numpy arrays, e.g. for a
statement like this:
print np.array([3]) / np.array([2])
I see that np.seterr can be used to issue certain types of division
warnings, but not this one. Is there a way to activate integer division
warnings? It would really help me migrate my application to Python 3.
Thanks,
Stuart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160819/724ddd46/attachment.html>
More information about the NumPy-Discussion
mailing list