Re: [Numpy-discussion] How to trigger warnings for integer division in python 2

2016-08-19 Thread Stuart Berg
> I guess the question is whether we should aim to add at least some of
> these warnings


As you can probably guess, I think such a feature would be very useful :-)
When my team started planning our migration to Python 3, we quickly
realized that the integer division issue was our biggest risk.  It has the
potential for subtle bugs to remain hidden in our code base long after the
migration, whereas most of the other Python 3 changes will be easier to
identify.


> and someone is willing to put in the effort (I suppose it is likely only a
> few places).
>
I am not sure how easy they are on the C side, but probably not difficult
> at all.


OK, good to hear that it shouldn't be difficult.  I've opened the following
issue on the github repo, to continue this discussion and hopefully attract
a volunteer. :-)

https://github.com/numpy/numpy/issues/7949

Best regards,
Stuart
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] How to trigger warnings for integer division in python 2

2016-08-19 Thread Sebastian Berg
On Fr, 2016-08-19 at 11:29 -0400, Stuart Berg wrote:
> 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.
> 

I don't think numpy implements any py3kwarnings. It seems that it would
be possible though. On newer versions we got more strict about using
floats instead of ints, so some of these places might follow up with a
warning quickly.
I guess the question is whether we should aim to add at least some of these 
warnings and someone is willing to put in the effort (I suppose it is likely 
only a few places). I am not sure how easy they are on the C side, but probably 
not difficult at all.

- Sebastian




> Thanks,
> Stuart
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion

signature.asc
Description: This is a digitally signed message part
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] How to trigger warnings for integer division in python 2

2016-08-19 Thread Stuart Berg
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
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion