Re: [Numpy-discussion] numpy migration

2007-04-24 Thread Duncan Smith
Timothy Hochberg wrote: > On 4/23/07, Duncan Smith <[EMAIL PROTECTED]> wrote: > >> >> Hello, >> Since moving to numpy I've had a few problems with my existing >> code. It basically revolves around the numpy scalar types. e.g. >> >> >> >> >>>

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Alan G Isaac
On Tue, 24 Apr 2007, Timothy Hochberg apparently wrote: > Personally I'd opt for completely following Python here, > with the C-like integer division and mod operators > available as appropriately named ufuncs somewhere. It's > a backwards incompatible change though, so it'd have to > wait til

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread David M. Cooke
On Apr 23, 2007, at 21:35 , David M. Cooke wrote: Python defines x // y as returning the floor of the division, and x % y has the same sign as y. However, in C89, it is implementation- defined (i.e., portability-pain-in-the-ass) whether the floor or ceil is used when the signs of x and y di

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Travis Oliphant
> > Personally I'd opt for completely following Python here, with the > C-like integer division and mod operators available as appropriately > named ufuncs somewhere. It's a backwards incompatible change though, > so it'd have to wait till at least a minor realease. I'm supportive of follow

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Warren Focke
On Tue, 24 Apr 2007, Timothy Hochberg wrote: > On 4/24/07, Robert Kern <[EMAIL PROTECTED]> wrote: > > > > Christian Marquardt wrote: > > > > > > Restore the invariant, and follow python. > > > This seems to imply that once upon a time numpy/numeric/numarray followed > python here, but as far as

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Christian Marquardt
On Tue, April 24, 2007 23:31, Christian Marquardt wrote: > On Tue, April 24, 2007 23:08, Robert Kern wrote: >> Christian Marquardt wrote: >>> Restore the invariant, and follow python. >>> >>> This >>> >>>>>> -5 // 6 >>>-1 >>> >>> and >>> >>>>>> array([-5])[0] // 6 >>>0 >>> >>> simpl

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Timothy Hochberg
On 4/24/07, Robert Kern <[EMAIL PROTECTED]> wrote: Christian Marquardt wrote: > Restore the invariant, and follow python. This seems to imply that once upon a time numpy/numeric/numarray followed python here, but as far as I can recall that was never the case. Instead they followed C com

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Christian Marquardt
On Tue, April 24, 2007 23:08, Robert Kern wrote: > Christian Marquardt wrote: >> Restore the invariant, and follow python. >> >> This >> >>>>> -5 // 6 >>-1 >> >> and >> >>>>> array([-5])[0] // 6 >>0 >> >> simply doesn't make sense - in any language, you would expect that >> all basi

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Robert Kern
Christian Marquardt wrote: > Restore the invariant, and follow python. > > This > >>>> -5 // 6 >-1 > > and > >>>> array([-5])[0] // 6 >0 > > simply doesn't make sense - in any language, you would expect that > all basic operators provide you with the same same answer when > app

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Christian Marquardt
Restore the invariant, and follow python. This >>> -5 // 6 -1 and >>> array([-5])[0] // 6 0 simply doesn't make sense - in any language, you would expect that all basic operators provide you with the same same answer when applied to the same number, no? Christian. On Tue, Apri

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread Alan G Isaac
Do restore the invariant. Behave completely like Python if not too costly, otherwise follow C89. A user's view, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Oddity with numpy.int64 integer division

2007-04-24 Thread David M. Cooke
On Apr 23, 2007, at 22:04 , Warren Focke wrote: But even C89 required that x == (x/y)*y + (x%y), and that's not the case here. Missed that. You're right. We pull the same trick Python does with % so that the sign of x % y agrees with the sign of y, but we don't follow Python in guarantee

Re: [Numpy-discussion] numpy migration

2007-04-24 Thread Timothy Hochberg
On 4/24/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote [CHOP] Sorry, cut and paste error, that should have read: : > > >>> i = a[0,0] > >>> 1/i > > 0 You should be getting a warning here. Did one disappear in the cut and paste? Or are you using a nonstandard shell that eats warnings? Or an

Re: [Numpy-discussion] numpy migration

2007-04-24 Thread Timothy Hochberg
On 4/23/07, Duncan Smith <[EMAIL PROTECTED]> wrote: Hello, Since moving to numpy I've had a few problems with my existing code. It basically revolves around the numpy scalar types. e.g. >>> import Numeric as N >>> a = N.array([[0,1],[2,3]]

Re: [Numpy-discussion] using the functions nonzero and where

2007-04-24 Thread Robert Kern
Christopher Barker wrote: > Bill Baxter wrote: >>> In [35]: x = [ 0, 0, 0, 99, 0, 1, 5] >>> In [37]: i=nonzero(x) >>> In [38]: i >>> Out[38]: (array([3, 5, 6]),) > >> Just do i[0]. It's an array, not a string. Try typing "type(i[0])" >> and see what it tells you. > > Which still begs the questi

Re: [Numpy-discussion] Bus Error with string in ndarray with named fields

2007-04-24 Thread Charles R Harris
On 4/20/07, Per B. Sederberg <[EMAIL PROTECTED]> wrote: Hi Folks: I'm getting a very strange bus error in the recent versions of numpy (almost current svn). Here's how you can (hopefully) replicate it: On my MacBook: Python 2.4.3 (#1, Apr 7 2006, 10:54:33) [GCC 4.0.1 (Apple Computer, Inc. b

Re: [Numpy-discussion] using the functions nonzero and where

2007-04-24 Thread Christopher Barker
Bill Baxter wrote: >> In [35]: x = [ 0, 0, 0, 99, 0, 1, 5] >> In [37]: i=nonzero(x) >> In [38]: i >> Out[38]: (array([3, 5, 6]),) > Just do i[0]. It's an array, not a string. Try typing "type(i[0])" > and see what it tells you. Which still begs the question: why does nonzero() return a tuple wi

Re: [Numpy-discussion] using the functions nonzero and where

2007-04-24 Thread Bill Baxter
On 4/21/07, Dennis Cooke <[EMAIL PROTECTED]> wrote: > I'm an ex-Matlab user trying to come up to speed with python and numpy. Howdy. First, I hope you've checked out the page: http://www.scipy.org/NumPy_for_Matlab_Users > I'm > confused on how to use the Numpy functions nonzero() and where().

Re: [Numpy-discussion] using the functions nonzero and where

2007-04-24 Thread Timothy Hochberg
On 4/20/07, Dennis Cooke <[EMAIL PROTECTED]> wrote: I'm an ex-Matlab user trying to come up to speed with python and numpy. I'm confused on how to use the Numpy functions nonzero() and where(). In matlab, the equivalent function (find(a>0) ) would return an array, whereas in numpy, where() or n

Re: [Numpy-discussion] Getting subarray

2007-04-24 Thread Bill Baxter
Easy! a[b==i] --bb On 4/24/07, Tommy Grav <[EMAIL PROTECTED]> wrote: > I have two arrays: > > a = numpy.array([0,1,2,3,4,5,6,7,8,9]) > b = numpy.array([0,0,1,1,2,2,0,1,2,3]) > > I would like to get the part of a that corresponds > to where b is equal to i. > > For example: > > i = 0 => ([0,1,6])

[Numpy-discussion] numpy migration

2007-04-24 Thread Duncan Smith
Hello, Since moving to numpy I've had a few problems with my existing code. It basically revolves around the numpy scalar types. e.g. >>> import Numeric as N >>> a = N.array([[0,1],[2,3]]) >>> a array([[0, 1], [2, 3]]) >>> i = a[0,0]

[Numpy-discussion] Getting subarray

2007-04-24 Thread Tommy Grav
I have two arrays: a = numpy.array([0,1,2,3,4,5,6,7,8,9]) b = numpy.array([0,0,1,1,2,2,0,1,2,3]) I would like to get the part of a that corresponds to where b is equal to i. For example: i = 0 => ([0,1,6]) i = 1 => ([2,3,7]) Cheers Tommy ___ Nump

[Numpy-discussion] using the functions nonzero and where

2007-04-24 Thread Dennis Cooke
I'm an ex-Matlab user trying to come up to speed with python and numpy. I'm confused on how to use the Numpy functions nonzero() and where(). In matlab, the equivalent function (find(a>0) ) would return an array, whereas in numpy, where() or nonzero() will return a single element tuple. For exa

[Numpy-discussion] Bus Error with string in ndarray with named fields

2007-04-24 Thread Per B. Sederberg
Hi Folks: I'm getting a very strange bus error in the recent versions of numpy (almost current svn). Here's how you can (hopefully) replicate it: On my MacBook: Python 2.4.3 (#1, Apr 7 2006, 10:54:33) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" o

Re: [Numpy-discussion] ScipyTest Warning?

2007-04-24 Thread Stefan van der Walt
Hi Mark On Tue, Apr 24, 2007 at 07:28:35AM -, mark wrote: > I have a piece of code that works fine for me, but a friend tries to > run it and gets this warning. > He claims to have updated his Python (2.4), Scipy and numpy. A > Does anybody know what import triggers this Warning? I didn't thin

[Numpy-discussion] ScipyTest Warning?

2007-04-24 Thread mark
Hello All - I have a piece of code that works fine for me, but a friend tries to run it and gets this warning. He claims to have updated his Python (2.4), Scipy and numpy. A Does anybody know what import triggers this Warning? I didn't think I imported ScipyTest. Thanks, Mark Warning (from warni