Re: [Numpy-discussion] The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

2010-10-27 Thread Rick Muller
Robert, Zachary, Thanks for the quick help. I tried to write a little self-contained example of the crash, but it wasn't working. (I'm sure you've already figured out how this ends.) When I tracked down why it wasn't working, I found my bug. Turned out that cut, which I assumed was just a small s

Re: [Numpy-discussion] The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

2010-10-27 Thread Zachary Pincus
> Help! I'm having a problem in searching through the *elements* if a > 2d array. I have a loop over a numpy array: > > n,m = G.shape > print n,m > for i in xrange(n): > for j in xrange(m): > print type(G), type(G[i,j]), type(float(G[i,j])) > g = float(

Re: [Numpy-discussion] The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

2010-10-27 Thread Robert Kern
On Wed, Oct 27, 2010 at 15:58, Rick Muller wrote: > Help! I'm having a problem in searching through the *elements* if a 2d > array. I have a loop over a numpy array: > >     n,m = G.shape >     print n,m >     for i in xrange(n): >     for j in xrange(m): >     print type(G), type(G[i,

[Numpy-discussion] The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

2010-10-27 Thread Rick Muller
Help! I'm having a problem in searching through the *elements* if a 2d array. I have a loop over a numpy array: n,m = G.shape print n,m for i in xrange(n): for j in xrange(m): print type(G), type(G[i,j]), type(float(G[i,j])) g = float(abs(G[i,j]))

Re: [Numpy-discussion] problems with numdifftools

2010-10-27 Thread Nicolai Heitz
m 27.10.2010 02:02, schrieb Sebastian Walter: > On Wed, Oct 27, 2010 at 12:59 AM, Pauli Virtanen wrote: >> Tue, 26 Oct 2010 14:24:39 -0700, Nicolai Heitz wrote: http://mail.scipy.org/mailman/listinfo/scipy-user >>> I contacted them already but they didn't responded so far and I was >>

Re: [Numpy-discussion] whitespace in git repo

2010-10-27 Thread Friedrich Romstedt
attribute: 'true', 'false', '', '' attributes: text, eol, core.autocrlf filters: left alone. core.safecrlf: left alone. results. normalise: True, False workingdir_fmt: 'lf', 'crlf' # Apply text. # Can be skipped on check-out. if text == 'true': normalise = True elif text == 'false': nor

Re: [Numpy-discussion] whitespace in git repo

2010-10-27 Thread Friedrich Romstedt
2010/10/27 Darren Dale : > I'm losing interest myself. I don't think the issue is so complicated, > there just seems to be a lot of confusing misinformation being posted > here. I apologise for all misinformation I posted. I always double-check before sending. Believe me or not. I think the sub

Re: [Numpy-discussion] whitespace in git repo

2010-10-27 Thread Darren Dale
On Wed, Oct 27, 2010 at 11:31 AM, Friedrich Romstedt wrote: > Hi Darren, > > 2010/10/27 Darren Dale : >>> So the svg changes must come from the 'fix' value for the whitespace action. >>> >>> I don't think it is a good idea to let whitespace be fixed by git and >>> not by your editor :-)  Or do you

Re: [Numpy-discussion] whitespace in git repo

2010-10-27 Thread Friedrich Romstedt
2010/10/27 Charles R Harris : > I'd like to do something here, but I'm waiting for a consensus and for > someone to test things out, maybe with a test repo, to make sure things > operate correctly. The documentation isn't that clear... Okay, I'll do that tomorrow (in ~13 hr). I feel responsible.

Re: [Numpy-discussion] whitespace in git repo

2010-10-27 Thread Darren Dale
On Wed, Oct 27, 2010 at 8:36 AM, Friedrich Romstedt wrote: > Hi Darren, > > 2010/10/19 Darren Dale : >> I have the following set in my ~/.gitconfig file: >> >>    [apply] >>        whitespace = fix >> >>    [core] >>        autocrlf = input >> >> which is attempting to correct some changes in: >>

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Nathaniel Smith
On Wed, Oct 27, 2010 at 7:34 AM, Neal Becker wrote: > I propose adding is_equal(a,b) function which does true short-ciruciting You could use np.allclose, I guess. (It isn't short-circuiting right now, but you could fix that.) -- Nathaniel ___ NumPy-Dis

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Neal Becker
Pauli Virtanen wrote: > Wed, 27 Oct 2010 09:44:59 -0400, Skipper Seabold wrote: > [clip] >> In [35]: timeit np.any(a!=b) > [clip] >> It seems to at least take less time when the difference is at the >> "beginning," though I'm sure there could be exceptions. > > It performs all the comparisons to

Re: [Numpy-discussion] ANN: NumPy 1.5.1 release candidate 1

2010-10-27 Thread Ralf Gommers
On Wed, Oct 27, 2010 at 1:23 AM, Friedrich Romstedt wrote: > I found some issues on Mac OS X 10.5 ppc in py2.5.4: > > See here: > > http://github.com/friedrichromstedt/numpy/tree/release%2F1.5.1rc1%2Fpy2.5-python.org-macosx10.3/release/logs/osx105rh/ The inf/exp failures should be marked as known

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Alan G Isaac
On 10/27/2010 9:56 AM, Zachary Pincus wrote: > the structure of the python language prevents > meaningful short-circuiting in the case of > np.any(a!=b) Maybe: any((ai != bi) for ai,bi in izip(a.flat,b.flat)) ? fwiw, Alan Isaac ___ NumPy-Discussion mai

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Zachary Pincus
This is silly: the structure of the python language prevents meaningful short-circuiting in the case of np.any(a!=b) While it's true that np.any itself may short-circuit, the 'a!=b' statement itself will be evaluated in its entirety before the result (a boolean array) is passed to np.any. Th

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Pauli Virtanen
Wed, 27 Oct 2010 09:44:59 -0400, Skipper Seabold wrote: [clip] > In [35]: timeit np.any(a!=b) [clip] > It seems to at least take less time when the difference is at the > "beginning," though I'm sure there could be exceptions. It performs all the comparisons to create a temporary boolean array. an

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Skipper Seabold
On Wed, Oct 27, 2010 at 9:37 AM, Johann Cohen-Tanugi wrote: > > > On 10/27/2010 03:31 PM, Neal Becker wrote: >> Johann Cohen-Tanugi wrote: >> >> >>> how about np.any(a!=b)  ?? >>> >>> On 10/27/2010 12:25 PM, Neal Becker wrote: >>> Is there a way to get a short circuit != ? That is,

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Johann Cohen-Tanugi
On 10/27/2010 03:31 PM, Neal Becker wrote: > Johann Cohen-Tanugi wrote: > > >> how about np.any(a!=b) ?? >> >> On 10/27/2010 12:25 PM, Neal Becker wrote: >> >>> Is there a way to get a short circuit != ? >>> >>> That is, compare 2 arrays but stop as soon as the first element >>> compar

[Numpy-discussion] Inconsistency with __index__() for rank-1 arrays?

2010-10-27 Thread Francesc Alted
Hi, I find this a bit misleading: >>> a = np.arange(10) >>> a[np.array(0)] 0 >>> a[np.array([0])] array([0]) >>> a[[0]] array([0]) But, for regular python lists we have: >>> l = a.tolist() >>> l[np.array(0)] 0 >>> l[np.array([0])] 0 i.e. indexing with a rank-0 array and a rank-1 array wit

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Neal Becker
Johann Cohen-Tanugi wrote: > how about np.any(a!=b) ?? > > On 10/27/2010 12:25 PM, Neal Becker wrote: >> Is there a way to get a short circuit != ? >> >> That is, compare 2 arrays but stop as soon as the first element >> comparison fails? >> >> I'm assuming that np.all (a != b) will _not_ do thi

Re: [Numpy-discussion] short circuit != ?

2010-10-27 Thread Johann Cohen-Tanugi
how about np.any(a!=b) ?? On 10/27/2010 12:25 PM, Neal Becker wrote: > Is there a way to get a short circuit != ? > > That is, compare 2 arrays but stop as soon as the first element comparison > fails? > > I'm assuming that np.all (a != b) will _not_ do this, but will first compare > all elements

Re: [Numpy-discussion] whitespace in git repo

2010-10-27 Thread Friedrich Romstedt
Hi Darren, 2010/10/19 Darren Dale : > I have the following set in my ~/.gitconfig file: > >    [apply] >        whitespace = fix > >    [core] >        autocrlf = input > > which is attempting to correct some changes in: > > branding/icons/numpylogo.svg > branding/icons/numpylogoicon.svg > tools/w

[Numpy-discussion] short circuit != ?

2010-10-27 Thread Neal Becker
Is there a way to get a short circuit != ? That is, compare 2 arrays but stop as soon as the first element comparison fails? I'm assuming that np.all (a != b) will _not_ do this, but will first compare all elements. ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] adding 'order=' keyword arg to ravel and others

2010-10-27 Thread Pauli Virtanen
Tue, 26 Oct 2010 22:05:52 -0700, Mark Wiebe wrote: > Because writing "arr.ravel('F')" doesn't seem as descriptive as > "arr.ravel(order='F')", I wrote this simple patch. I added mention of > the order='A' parameter to a few places it is relevant as well. Here's > the branch on github: > > http:/

Re: [Numpy-discussion] problems with numdifftools

2010-10-27 Thread Sebastian Walter
On Wed, Oct 27, 2010 at 12:59 AM, Pauli Virtanen wrote: > Tue, 26 Oct 2010 14:24:39 -0700, Nicolai Heitz wrote: >> >  http://mail.scipy.org/mailman/listinfo/scipy-user >> >> I contacted them already but they didn't responded so far and I was >> forwarded to that list which was supposed to be more