Re: [Numpy-discussion] Nice float -> integer conversion?

2011-11-01 Thread Matthew Brett
Hi, On Sat, Oct 15, 2011 at 12:20 PM, Matthew Brett wrote: > Hi, > > On Tue, Oct 11, 2011 at 7:32 PM, Benjamin Root wrote: >> On Tue, Oct 11, 2011 at 2:06 PM, Derek Homeier >> wrote: >>> >>> On 11 Oct 2011, at 20:06, Matthew Brett wrote: >>> >>> > Have I missed a fast way of doing nice float to

Re: [Numpy-discussion] Nice float -> integer conversion?

2011-10-15 Thread Matthew Brett
Hi, On Tue, Oct 11, 2011 at 7:32 PM, Benjamin Root wrote: > On Tue, Oct 11, 2011 at 2:06 PM, Derek Homeier > wrote: >> >> On 11 Oct 2011, at 20:06, Matthew Brett wrote: >> >> > Have I missed a fast way of doing nice float to integer conversion? >> > >> > By nice I mean, rounding to the nearest i

Re: [Numpy-discussion] Nice float -> integer conversion?

2011-10-11 Thread Benjamin Root
On Tue, Oct 11, 2011 at 2:06 PM, Derek Homeier < de...@astro.physik.uni-goettingen.de> wrote: > On 11 Oct 2011, at 20:06, Matthew Brett wrote: > > > Have I missed a fast way of doing nice float to integer conversion? > > > > By nice I mean, rounding to the nearest integer, converting NaN to 0, > >

Re: [Numpy-discussion] Nice float -> integer conversion?

2011-10-11 Thread Matthew Brett
Hi, On Tue, Oct 11, 2011 at 5:30 PM, Derek Homeier wrote: > On 11.10.2011, at 9:18PM, josef.p...@gmail.com wrote: >>> >>> In [42]: c = np.zeros(4, np.int16) >>> In [43]: d = np.zeros(4, np.int32) >>> In [44]: np.around([1.6,np.nan,np.inf,-np.inf], out=c) >>> Out[44]: array([2, 0, 0, 0], dtype=int

Re: [Numpy-discussion] Nice float -> integer conversion?

2011-10-11 Thread Derek Homeier
On 11.10.2011, at 9:18PM, josef.p...@gmail.com wrote: >> >> In [42]: c = np.zeros(4, np.int16) >> In [43]: d = np.zeros(4, np.int32) >> In [44]: np.around([1.6,np.nan,np.inf,-np.inf], out=c) >> Out[44]: array([2, 0, 0, 0], dtype=int16) >> >> In [45]: np.around([1.6,np.nan,np.inf,-np.inf], out=d)

Re: [Numpy-discussion] Nice float -> integer conversion?

2011-10-11 Thread Matthew Brett
Hi, On Tue, Oct 11, 2011 at 3:06 PM, Derek Homeier wrote: > On 11 Oct 2011, at 20:06, Matthew Brett wrote: > >> Have I missed a fast way of doing nice float to integer conversion? >> >> By nice I mean, rounding to the nearest integer, converting NaN to 0, >> inf, -inf to the max and min of the in

Re: [Numpy-discussion] Nice float -> integer conversion?

2011-10-11 Thread josef . pktd
On Tue, Oct 11, 2011 at 3:06 PM, Derek Homeier wrote: > On 11 Oct 2011, at 20:06, Matthew Brett wrote: > >> Have I missed a fast way of doing nice float to integer conversion? >> >> By nice I mean, rounding to the nearest integer, converting NaN to 0, >> inf, -inf to the max and min of the integer

Re: [Numpy-discussion] Nice float -> integer conversion?

2011-10-11 Thread Derek Homeier
On 11 Oct 2011, at 20:06, Matthew Brett wrote: > Have I missed a fast way of doing nice float to integer conversion? > > By nice I mean, rounding to the nearest integer, converting NaN to 0, > inf, -inf to the max and min of the integer range? The astype method > and cast functions don't do what

[Numpy-discussion] Nice float -> integer conversion?

2011-10-11 Thread Matthew Brett
Hi, Have I missed a fast way of doing nice float to integer conversion? By nice I mean, rounding to the nearest integer, converting NaN to 0, inf, -inf to the max and min of the integer range? The astype method and cast functions don't do what I need here: In [40]: np.array([1.6, np.nan, np.inf