Re: [Numpy-discussion] ndarray with double comparison

2011-10-15 Thread Neil
Marc Shivers marc.shivers at gmail.com writes: you could use bitwise comparison with paretheses:  In [8]: (a4)(a8)Out[8]: array([False, False, False, False, False,  True,  True,  True, False,   False, False], dtype=bool) For cases like this I find it very useful to define a function

Re: [Numpy-discussion] ndarray with double comparison

2011-10-15 Thread Chao YUE
Thanks. quite useful!! Chao 2011/10/15 Neil neilcrigh...@gmail.com Marc Shivers marc.shivers at gmail.com writes: you could use bitwise comparison with paretheses: In [8]: (a4)(a8)Out[8]: array([False, False, False, False, False, True, True, True, False, False, False], dtype=bool)

[Numpy-discussion] Float128 integer comparison

2011-10-15 Thread Matthew Brett
Hi, Continuing the exploration of float128 - can anyone explain this behavior? np.float64(9223372036854775808.0) == 9223372036854775808L True np.float128(9223372036854775808.0) == 9223372036854775808L False int(np.float128(9223372036854775808.0)) == 9223372036854775808L True

Re: [Numpy-discussion] float128 casting rounding as if it were float64

2011-10-15 Thread Matthew Brett
Hi, On Wed, Oct 12, 2011 at 11:24 AM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Oct 11, 2011 at 12:17 PM, Matthew Brett matthew.br...@gmail.com wrote: Hi, While struggling with floating point precision, I ran into this: In [52]: a = 2**54+3 In [53]: a Out[53]:

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-15 Thread Matthew Brett
Hi, On Wed, Oct 12, 2011 at 8:31 AM, David Cournapeau courn...@gmail.com wrote: On 10/12/11, V. Armando Solé s...@esrf.fr wrote: On 12/10/2011 10:46, David Cournapeau wrote: On Wed, Oct 12, 2011 at 9:18 AM, V. Armando Solé wrote:   From a pure user perspective, I would not expect the abs

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 ben.r...@ou.edu wrote: 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

[Numpy-discussion] Printing individual array elements with at least 15 significant digits

2011-10-15 Thread Hugo Gagnon
Hello, I need to print individual elements of a float64 array to a text file. However in the file I only get 12 significant digits, the same as with: a = np.zeros(3) a.fill(1./3) print a[0] 0. len(str(a[0])) - 2 12 whereas len(repr(a[0])) - 2 17 which makes more sense since I

Re: [Numpy-discussion] Printing individual array elements with at least 15 significant digits

2011-10-15 Thread Derek Homeier
On 15.10.2011, at 9:21PM, Hugo Gagnon wrote: I need to print individual elements of a float64 array to a text file. However in the file I only get 12 significant digits, the same as with: a = np.zeros(3) a.fill(1./3) print a[0] 0. len(str(a[0])) - 2 12 whereas

Re: [Numpy-discussion] Float128 integer comparison

2011-10-15 Thread Aronne Merrelli
On Sat, Oct 15, 2011 at 1:12 PM, Matthew Brett matthew.br...@gmail.comwrote: Hi, Continuing the exploration of float128 - can anyone explain this behavior? np.float64(9223372036854775808.0) == 9223372036854775808L True np.float128(9223372036854775808.0) == 9223372036854775808L False

Re: [Numpy-discussion] Float128 integer comparison

2011-10-15 Thread Derek Homeier
On 15.10.2011, at 9:42PM, Aronne Merrelli wrote: On Sat, Oct 15, 2011 at 1:12 PM, Matthew Brett matthew.br...@gmail.com wrote: Hi, Continuing the exploration of float128 - can anyone explain this behavior? np.float64(9223372036854775808.0) == 9223372036854775808L True

[Numpy-discussion] float128 in fact float80

2011-10-15 Thread Matthew Brett
Hi, After getting rather confused, I concluded that float128 on a couple of Intel systems I have, is in fact an 80 bit extended precision number: http://en.wikipedia.org/wiki/Extended_precision np.finfo(np.float128).nmant 63 np.finfo(np.float128).nexp 15 That is rather confusing. What is

Re: [Numpy-discussion] float128 casting rounding as if it were float64

2011-10-15 Thread Charles R Harris
On Sat, Oct 15, 2011 at 12:54 PM, Matthew Brett matthew.br...@gmail.comwrote: Hi, On Wed, Oct 12, 2011 at 11:24 AM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Oct 11, 2011 at 12:17 PM, Matthew Brett matthew.br...@gmail.com wrote: Hi, While struggling with