[Numpy-discussion] should rint return int?

2014-04-28 Thread Neal Becker
I notice rint returns float. Shouldn't it return int? Would be useful when float is no longer acceptable as an index. I think conversion to an index using rint is a common idiom. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] should rint return int?

2014-04-28 Thread Chris Barker
On Mon, Apr 28, 2014 at 10:36 AM, Neal Becker ndbeck...@gmail.com wrote: I notice rint returns float. Shouldn't it return int? AFAICT, rint() is the same as round(), except with slightly different rules for the halfway case. So returning a float makes sense, as round() and ceil() and floor()

Re: [Numpy-discussion] should rint return int?

2014-04-28 Thread Robert Kern
On Mon, Apr 28, 2014 at 6:36 PM, Neal Becker ndbeck...@gmail.com wrote: I notice rint returns float. Shouldn't it return int? Would be useful when float is no longer acceptable as an index. I think conversion to an index using rint is a common idiom. C's rint() does not:

Re: [Numpy-discussion] should rint return int?

2014-04-28 Thread Neal Becker
Robert Kern wrote: On Mon, Apr 28, 2014 at 6:36 PM, Neal Becker ndbeck...@gmail.com wrote: I notice rint returns float. Shouldn't it return int? Would be useful when float is no longer acceptable as an index. I think conversion to an index using rint is a common idiom. C's rint() does

Re: [Numpy-discussion] should rint return int?

2014-04-28 Thread Alan G Isaac
On 4/28/2014 3:29 PM, Neal Becker wrote: Well I'd spell it nint, and it works like: Wouldn't it be simpler to add a dtype argument to `rint`? Or does that violate the simple wrapper intent? Alan Isaac ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] should rint return int?

2014-04-28 Thread Robert Kern
On Mon, Apr 28, 2014 at 8:36 PM, Alan G Isaac alan.is...@gmail.com wrote: On 4/28/2014 3:29 PM, Neal Becker wrote: Well I'd spell it nint, and it works like: Wouldn't it be simpler to add a dtype argument to `rint`? Or does that violate the simple wrapper intent? `np.rint()` is a ufunc. --

Re: [Numpy-discussion] should rint return int?

2014-04-28 Thread Nathaniel Smith
On 28 Apr 2014 20:22, Robert Kern robert.k...@gmail.com wrote: C's rint() does not: http://linux.die.net/man/3/rint This is because there are many integers that are representable as floats/doubles/long doubles that are well outside of the range of any C integer type, e.g. 1e20. By the