[Numpy-discussion] (no subject)

2014-09-18 Thread Petr Viktorin
Hello,
Over at Python-ideas, there is a thread [0] about the following discrepancy:

 numpy.array(float('inf')) // 1
inf
 float('inf') // 1
nan

There are reasons for either result, but I believe it would be very
nice if either Python or Numpy changed, so they would give the same
value.
If any of you have reasons to defend Numpy's (or Python's) choice, or
otherwise want to chime in, please post there.

Thanks,
Petr Viktorin


[0] https://mail.python.org/pipermail/python-ideas/2014-September/029365.html
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] float('inf') // 1 = ?

2014-09-18 Thread Petr Viktorin
(Apologies for the lack of subject earlier)

Hello,
Over at Python-ideas, there is a thread [0] about the following discrepancy:

 numpy.array(float('inf')) // 1
inf
 float('inf') // 1
nan

There are reasons for either result, but I believe it would be very
nice if either Python or Numpy changed, so they would give the same
value.
If any of you have reasons to defend Numpy's (or Python's) choice, or
otherwise want to chime in, please post there.

Thanks,
Petr Viktorin


[0] https://mail.python.org/pipermail/python-ideas/2014-September/029365.html
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] float('inf') // 1 = ?

2014-09-18 Thread Petr Viktorin
Sorry for the lack of subject before.

On Thu, Sep 18, 2014 at 6:48 PM, Benjamin Root ben.r...@ou.edu wrote:
 My vote is that NumPy is correct here. I see no reason why
 float('inf') / 1
 and
 float('inf') // 1

 should return different results.

I recommend reading the python-ideas thread; there are some arguments
for both sides.

 On Thu, Sep 18, 2014 at 12:31 PM, Petr Viktorin encu...@gmail.com wrote:

 Hello,
 Over at Python-ideas, there is a thread [0] about the following
 discrepancy:

  numpy.array(float('inf')) // 1
 inf
  float('inf') // 1
 nan

 There are reasons for either result, but I believe it would be very
 nice if either Python or Numpy changed, so they would give the same
 value.
 If any of you have reasons to defend Numpy's (or Python's) choice, or
 otherwise want to chime in, please post there.

 Thanks,
 Petr Viktorin


 [0]
 https://mail.python.org/pipermail/python-ideas/2014-September/029365.html
 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion



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

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


Re: [Numpy-discussion] (no subject)

2014-09-18 Thread Petr Viktorin
On Thu, Sep 18, 2014 at 7:14 PM, Jonathan Helmus jjhel...@gmail.com wrote:
 On 09/18/2014 12:01 PM, Chris Barker wrote:

 Well,

 First of all, numpy and the python math module have a number of differences
 when it comes to handling these kind of special cases -- and I think that:

 1) numpy needs to do what makes the most sense for numpy and NOT mirror the
 math lib.

Sure.

 2) the use-cases of the math lib and numpy are different, so they maybe
 _should_ have different handling of this kind of thing.

If you have a reason for the difference, I'd like to hear it.

 3) I'm not sure that the core devs think these kinds of issues are wrong
 'enough to break backward compatibility in subtle ways.

I'd be perfectly fine with it being documented and tested (in CPython)
as either a design mistake or design choice.

 But it's a fun topic in any case, and maybe numpy's behavior could be
 improved.

 My vote is that NumPy is correct here. I see no reason why
  float('inf') / 1
 and
  float('inf') // 1

 should return different results.


 Well, one argument is that floor division is supposed to return an integer
 value, and that inf is NOT an integer value. The integral part of infinity
 doesn't exist and thus is Not a Number.


 But nan is not an integer value either:

 float('inf') // 1
 nan
 int(float('inf') // 1)
 Traceback (most recent call last):
   File stdin, line 1, in module
 ValueError: cannot convert float NaN to integer

 Perhaps float('inf') // 1 should raise a ValueError directly since there is
 no proper way perform the floor division on infinity.

inf not even a *real* number; a lot of operations don't make
mathematical sense on it. But most are defined anyway, and quite
sanely.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion