[Numpy-discussion] Possible bug in indexed masked arrays

2010-04-01 Thread Nathaniel Peterson
Is this behavior of masked arrays intended, or is it a bug? This part works as I would expected: import numpy as np a=np.ma.fix_invalid(np.array([np.nan,-1,0,1])) b=np.ma.fix_invalid(np.array([np.nan,-1,0,1])) idx=(a==b) print(a[idx][3]) # 1.0 Note that a[idx] has shape (4,). But if I change t

[Numpy-discussion] Is this odd?

2010-04-01 Thread Shailendra
Hi All, Below is some array behaviour which i think is odd >>> a=arange(10) >>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> b=nonzero(a<0) >>> b (array([], dtype=int32),) >>> if not b[0]: ... print 'b[0] is false' ... b[0] is false Above case the b[0] is empty so it is fine it is considered fa

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread Charles R Harris
On Thu, Apr 1, 2010 at 8:16 PM, Charles R Harris wrote: > > > On Thu, Apr 1, 2010 at 7:59 PM, David Cournapeau wrote: > >> Anne Archibald wrote: >> >> > >> > First I guess we should check which systems don't have log1p >> >> This is already done - we do use the system log1p on linux (but note >> t

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread Charles R Harris
On Thu, Apr 1, 2010 at 7:59 PM, David Cournapeau wrote: > Anne Archibald wrote: > > > > > First I guess we should check which systems don't have log1p > > This is already done - we do use the system log1p on linux (but note > that log2_1p is not standard AFAIK). I would guess few systems outside >

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread David Cournapeau
Anne Archibald wrote: > > First I guess we should check which systems don't have log1p This is already done - we do use the system log1p on linux (but note that log2_1p is not standard AFAIK). I would guess few systems outside windows don't have log1p, given that msun has an implementation, D

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread Charles R Harris
On Thu, Apr 1, 2010 at 3:51 PM, Anne Archibald wrote: > On 1 April 2010 13:38, Charles R Harris wrote: > > > > > > On Thu, Apr 1, 2010 at 8:37 AM, Charles R Harris < > charlesr.har...@gmail.com> > > wrote: > >> > >> > >> On Thu, Apr 1, 2010 at 12:46 AM, Anne Archibald > >> wrote: > >>> > >>> On

[Numpy-discussion] Asymmetry in Chebyshev.deriv v. Chebyshev.integ

2010-04-01 Thread David Goldsmith
>>> np.version.version '1.4.0' >>> c = np.polynomial.chebyshev.Chebyshev(1) >>> c.deriv(1.0) Chebyshev([ 0.], [-1., 1.]) >>> c.integ(1.0) Traceback (most recent call last): File "", line 1, in File "", line 441, in integ File "C:\Python26\lib\site-packages\numpy\polynomial\chebyshev.py", li

Re: [Numpy-discussion] Can this be done more efficiently using numpy?

2010-04-01 Thread Vishal Rana
Thanks Didrik! On Thu, Apr 1, 2010 at 1:21 AM, Didrik Pinte wrote: > On Wed, 2010-03-31 at 23:13 -0700, Vishal Rana wrote: > > Hi, > > > > > > A calculation which goes like this... > > > > > > n = 5 > > a = np.arange(1000) > > b = np.arange(n - 1, 1000) > > > > > > l = [] > > for i in range(b.s

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread Anne Archibald
On 1 April 2010 13:38, Charles R Harris wrote: > > > On Thu, Apr 1, 2010 at 8:37 AM, Charles R Harris > wrote: >> >> >> On Thu, Apr 1, 2010 at 12:46 AM, Anne Archibald >> wrote: >>> >>> On 1 April 2010 02:24, Charles R Harris >>> wrote: >>> > >>> > >>> > On Thu, Apr 1, 2010 at 12:04 AM, Anne Ar

Re: [Numpy-discussion] ufuncs on funny strides; also isnan, isfinite, etc on a variety of dtypes

2010-04-01 Thread Anne Archibald
On 1 April 2010 14:30, M Trumpis wrote: > Hi all, > > disclaimer: pardon my vast ignorance on the subject of ufuncs, that > will explain the naivety of the following questions > > This morning I was looking at this line of code, which was running > quite slow for me and making me think > > data_ha

Re: [Numpy-discussion] "Match" two arrays

2010-04-01 Thread Friedrich Romstedt
2010/4/1 Shailendra : > Hi All, > I want to make a function which should be like this [...] We had a thread some time ago, very long and with lots of working code, which seems to me related to this: Thread title: "Iterative Matrix Multiplication" (do a search under "Bug Reports" on numpy.scipy.or

Re: [Numpy-discussion] ufuncs on funny strides; also isnan, isfinite, etc on a variety of dtypes

2010-04-01 Thread M Trumpis
On Thu, Apr 1, 2010 at 11:53 AM, Warren Weckesser wrote: > M Trumpis wrote: >> Hi all, >> >> >> >> And a last mini question, it doesn't appear that any() is doing short >> circuit evaluation. It runs in appx the same time whether an array is >> sparsely nonzero, fully zero, or fully nonzero. >> >

Re: [Numpy-discussion] ufuncs on funny strides; also isnan, isfinite, etc on a variety of dtypes

2010-04-01 Thread Warren Weckesser
M Trumpis wrote: > Hi all, > > > > And a last mini question, it doesn't appear that any() is doing short > circuit evaluation. It runs in appx the same time whether an array is > sparsely nonzero, fully zero, or fully nonzero. > > That's not what I see. Here's an example that shows the a line

[Numpy-discussion] Ufunc memory access optimizations (Was: ufuncs on funny strides ...)

2010-04-01 Thread Pauli Virtanen
to, 2010-04-01 kello 11:30 -0700, M Trumpis kirjoitti: [clip] > Actually I realized later that the main slow-down comes from the fact > that my array was strided in fortran order (ascending strides). But > from the point of view of a ufunc that is operating independently at > each value, why would

[Numpy-discussion] ufuncs on funny strides; also isnan, isfinite, etc on a variety of dtypes

2010-04-01 Thread M Trumpis
Hi all, disclaimer: pardon my vast ignorance on the subject of ufuncs, that will explain the naivety of the following questions This morning I was looking at this line of code, which was running quite slow for me and making me think data_has_nan = numpy.isnan(data_array).any() I knew that the a

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread Charles R Harris
On Thu, Apr 1, 2010 at 8:37 AM, Charles R Harris wrote: > > > On Thu, Apr 1, 2010 at 12:46 AM, Anne Archibald > wrote: > >> On 1 April 2010 02:24, Charles R Harris >> wrote: >> > >> > >> > On Thu, Apr 1, 2010 at 12:04 AM, Anne Archibald < >> peridot.face...@gmail.com> >> > wrote: >> >> >> >> On

Re: [Numpy-discussion] Re Dealloat Numy arrays in C

2010-04-01 Thread Jeremy Lewi
Thanks Robert. I ended up letting Python handle the memory management. In my C-extension I just call Py_INCREF to prevent Python from deallocating it while I'm using it. I then call Py_DECREF once I'm done with it. Jeremy ___ NumPy-Discussion mailing l

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread Charles R Harris
On Thu, Apr 1, 2010 at 12:46 AM, Anne Archibald wrote: > On 1 April 2010 02:24, Charles R Harris wrote: > > > > > > On Thu, Apr 1, 2010 at 12:04 AM, Anne Archibald < > peridot.face...@gmail.com> > > wrote: > >> > >> On 1 April 2010 01:59, Charles R Harris > wrote: > >> > > >> > > >> > On Wed, Ma

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread Charles R Harris
On Thu, Apr 1, 2010 at 3:52 AM, David Cournapeau wrote: > Anne Archibald wrote: > > On 1 April 2010 03:15, David Cournapeau wrote: > >> Anne Archibald wrote: > >> > >>> Particularly given the comments in the boost source code, I'm leery of > >>> this fix; who knows what an optimizing compiler wil

Re: [Numpy-discussion] &quot;Match&quot; two arrays

2010-04-01 Thread eat
Oops. Wrongly timed. > t= np.array(timeit.repeat(perf, repeat= rep, number= 1))/ rep should be t= np.array(timeit.repeat(perf, repeat= rep, number= 1)) eat ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org

Re: [Numpy-discussion] "Match" two arrays

2010-04-01 Thread eat
Shailendra gmail.com> writes: > > Hi All, > I want to make a function which should be like this > > cordinates1=(x1,y1) # x1 and y1 are x-cord and y-cord of a large > number of points > cordinates2=(x2,y2) # similar to condinates1 > indices1,indices2= match_cordinates(cordinates1,cordinates2) >

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread David Cournapeau
Anne Archibald wrote: > On 1 April 2010 03:15, David Cournapeau wrote: >> Anne Archibald wrote: >> >>> Particularly given the comments in the boost source code, I'm leery of >>> this fix; who knows what an optimizing compiler will do with it? >> But the current code *is* wrong: it is not true that

Re: [Numpy-discussion] "Match" two arrays

2010-04-01 Thread Neil Crighton
Shailendra gmail.com> writes: > > Hi All, > I want to make a function which should be like this > > cordinates1=(x1,y1) # x1 and y1 are x-cord and y-cord of a large > number of points > cordinates2=(x2,y2) # similar to condinates1 > indices1,indices2= match_cordinates(cordinates1,cordinates2)

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread Anne Archibald
On 1 April 2010 03:15, David Cournapeau wrote: > Anne Archibald wrote: > >> >> Particularly given the comments in the boost source code, I'm leery of >> this fix; who knows what an optimizing compiler will do with it? > > But the current code *is* wrong: it is not true that u == 1 implies u - > 1

Re: [Numpy-discussion] Can this be done more efficiently using numpy?

2010-04-01 Thread Didrik Pinte
On Wed, 2010-03-31 at 23:13 -0700, Vishal Rana wrote: > Hi, > > > A calculation which goes like this... > > > n = 5 > a = np.arange(1000) > b = np.arange(n - 1, 1000) > > > l = [] > for i in range(b.size): > # Absolute difference of n a elements and nth b element > x = np.abs(a[i:i +

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-04-01 Thread David Cournapeau
Anne Archibald wrote: > > Particularly given the comments in the boost source code, I'm leery of > this fix; who knows what an optimizing compiler will do with it? But the current code *is* wrong: it is not true that u == 1 implies u - 1 == 0 (and that (u-1) != 0 -> u != 1), because the spacing