[Numpy-discussion] Py2exe / numpy troubles

2006-08-29 Thread tristan CORCELLE
Hello,   I am having troubles with py2exe and numpy/matplotlib... Configuration :     Windows XP pro     ActivePython 2.4.2.10     Scipy 0.4.9 Numpy 0.9.8     MatplotLib 0.87.1     Py2exe 0.6.5     WxPython 2.6   I am using the following setup.py file:    #

[Numpy-discussion] possible bug with numpy.object_

2006-08-29 Thread Matt Knox
is the following behaviour expected? or is this a bug with numpy.object_  ?  I'm using numpy 1.0b1   >>> print numpy.array([],numpy.float64).size0 >>> print numpy.array([],numpy.object_).size1 Should the size of an array initialized from an empty list not always be 1 ? or am I just crazy?   Thank

Re: [Numpy-discussion] possible bug with numpy.object_

2006-08-29 Thread Matt Knox
# is the following behaviour expected? or is this a bug with numpy.object_  ?  I'm using numpy 1.0b1#  # >>> print numpy.array([],numpy.float64).size# 0## >>> print numpy.array([],numpy.object_).size# 1## Should the size of an array initialized from an empty list not always be 1 ? or am I just cr

[Numpy-discussion] error in ctypes example from the numpy book?

2006-08-29 Thread W. Bryan Smith
hi,i posted this to the forum, but it looks like the email list gets much more traffic, so here goes.i am attempting to reproduce a portion of the example on using ctypes from the current version of the numpy book (the example can be found on pps 313-16).    here is what i am trying to do:    impor

[Numpy-discussion] Problem with randn

2006-08-29 Thread Keith Goodman
randn incorrectly returns random numbers only between 0 and 1 in numpy 1.0b1. random.randn works. >> from numpy.matlib import * >> randn(3,4) matrix([[ 0.60856413, 0.35500732, 0.48089868, 0.7044022 ], [ 0.71098538, 0.8506885 , 0.56154652, 0.4243273 ], [ 0.89655777, 0.92339

Re: [Numpy-discussion] possible bug with numpy.object_

2006-08-29 Thread Travis Oliphant
Matt Knox wrote: > is the following behaviour expected? or is this a bug with > numpy.object_ ? I'm using numpy 1.0b1 > > >>> print numpy.array([],numpy.float64).size > 0 > > >>> print numpy.array([],numpy.object_).size > 1 > > Should the size of an array initialized from an empty list not alw

Re: [Numpy-discussion] Is numpy supposed to support the buffer protocol?

2006-08-29 Thread Christopher Barker
Robin Dunn wrote: > BTW Chris, try using buffer(RGB) and buffer(Alpha) in your sample, I > expect that will work with the current code. yup. that does work. I was concerned that it would make a copy, but it looks like it makes a new buffer object, but using the same data buffer, so that should

[Numpy-discussion] py2exe error

2006-08-29 Thread kortmann
>Hi, Travis >I can pack my scripts into an executable with py2exe, but errors occur >once it runs: >No scipy-style subpackage 'random' found in D:\test\dist\numpy. >Ignoring: No module named info >import core -> failed: No module named _internal >import lib -> failed: 'module' object has no attri

[Numpy-discussion] Documentation

2006-08-29 Thread Charles R Harris
Hi All,I've finished moving all the docstrings in arraymethods to add_newdocs. Much of the documentation is still incomplete and needs nicer formatting, so if you are so inclined, or even annoyed with some of the help messages, feel free to fix things up. Chuck -

[Numpy-discussion] For loop tips

2006-08-29 Thread Keith Goodman
I have a very long list that contains many repeated elements. The elements of the list can be either all numbers, or all strings, or all dates [datetime.date]. I want to convert the list into a matrix where each unique element of the list is assigned a consecutive integer starting from zero. I've

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Tim Hochberg
Keith Goodman wrote: > I have a very long list that contains many repeated elements. The > elements of the list can be either all numbers, or all strings, or all > dates [datetime.date]. > > I want to convert the list into a matrix where each unique element of > the list is assigned a consecutive i

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Tim Hochberg
Tim Hochberg wrote: > Keith Goodman wrote: > >> I have a very long list that contains many repeated elements. The >> elements of the list can be either all numbers, or all strings, or all >> dates [datetime.date]. >> >> I want to convert the list into a matrix where each unique element of >> the

[Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Travis Oliphant
Hi all, Classes start for me next Tuesday, and I'm teaching a class for which I will be using NumPy / SciPy extensively. I need to have a release of these two (and hopefully matplotlib) that work with each other. Therefore, I'm going to make a 1.0b5 release of NumPy over the weekend (probabl

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Torgil Svensson
def list2index(L): idx=dict((y,x) for x,y in enumerate(set(L))) return asmatrix(fromiter((idx[x] for x in L),dtype=int)) # old $ python test.py Numbers: 29.4062280655 seconds Characters: 84.6239070892 seconds Dates: 117.560418844 seconds # new $ python test.py Numbers: 1.79700994492 secon

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Alan G Isaac
You can get some speed up for numeric data: def list2index2(L): aL = asarray(L) eL = empty_like(L) for v,k in enumerate(set(L)): eL[aL == k] = v return numpy.asmatrix(eL).T fwiw, Alan Isaac - Using Tomcat but

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Charles R Harris
Hi Travis,On 8/29/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Hi all,Classes start for me next Tuesday, and I'm teaching a class for which Iwill be using NumPy / SciPy extensively.  I need to have a release ofthese two (and hopefully matplotlib) that work with each other. Therefore, I'm going to

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Fernando Perez
On 8/29/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > Speaking of features, I wonder if more of the methods should return > references. For instance, it might be nice to write something like: > > a.sort().searchsorted([...]) > > instead of making two statements out of it. +1 for more 'return

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Rudolph van der Merwe
This definitely gets my vote as well (for what it's worth). R. On 8/29/06, Fernando Perez <[EMAIL PROTECTED]> wrote: > +1 for more 'return self' at the end of methods which currently don't > return anything (well, we get the default None), as long as it's > sensible. I really like this 'message

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Charles R Harris
Hi Fernando,On 8/29/06, Fernando Perez <[EMAIL PROTECTED]> wrote: On 8/29/06, Charles R Harris <[EMAIL PROTECTED]> wrote:> Speaking of features, I wonder if more of the methods should return> references. For instance, it might be nice to write something like: >>  a.sort().searchsorted([...])>> inst

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Tim Hochberg
-0.5 from me if what we're talking about here is having mutating methods return self rather than None. Chaining stuff is pretty, but having methods that mutate self and return self looks like a source of elusive bugs to me. -tim Rudolph van der Merwe wrote: > This definitely gets my vote as

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Keith Goodman
On 8/29/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > Keith Goodman wrote: > > I have a very long list that contains many repeated elements. The > > elements of the list can be either all numbers, or all strings, or all > > dates [datetime.date]. > > > > I want to convert the list into a matrix whe

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Charles R Harris
Hi,On 8/29/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: -0.5 from me if what we're talking about here is having mutating methodsreturn self rather than None. Chaining stuff is pretty, but havingmethods that mutate self and return self looks like a source of elusive bugs to me.-timBut how is that any

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Alan G Isaac
On Tue, 29 Aug 2006, Tim Hochberg apparently wrote: > -0.5 from me if what we're talking about here is having > mutating methods return self rather than None. Chaining > stuff is pretty, but having methods that mutate self and > return self looks like a source of elusive bugs to me. I believe

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Torgil Svensson
something like this? def list2index(L): uL=sorted(set(L)) idx=dict((y,x) for x,y in enumerate(uL)) return uL,asmatrix(fromiter((idx[x] for x in L),dtype=int)) //Torgil On 8/29/06, Keith Goodman <[EMAIL PROTECTED]> wrote: > On 8/29/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > > Keith Go

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Tim Hochberg
Charles R Harris wrote: > Hi, > > On 8/29/06, *Tim Hochberg* <[EMAIL PROTECTED] > > wrote: > > > -0.5 from me if what we're talking about here is having mutating > methods > return self rather than None. Chaining stuff is pretty, but having > methods that

Re: [Numpy-discussion] For loop tips

2006-08-29 Thread Keith Goodman
On 8/29/06, Torgil Svensson <[EMAIL PROTECTED]> wrote: > something like this? > > def list2index(L): >uL=sorted(set(L)) >idx=dict((y,x) for x,y in enumerate(uL)) >return uL,asmatrix(fromiter((idx[x] for x in L),dtype=int)) Wow. That's amazing. Thank you. --

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Charles R Harris
On 8/29/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:> Hi,>> On 8/29/06, *Tim Hochberg* <[EMAIL PROTECTED]> [EMAIL PROTECTED] >> wrote:>>> -0.5 from me if what we're talking about here is having mutating> methods> return self rather than None. Chaining stuff is pre

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Travis Oliphant
Charles R Harris wrote: > > The 1.0rc1 release of NumPy will be mid September I suspect. > > Also, I recognize that the default-axis switch is a burden for > those who > have already transitioned code to use NumPy (for those just > starting out > it's not a big deal because

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Travis Oliphant
Tim Hochberg wrote: >-0.5 from me if what we're talking about here is having mutating methods >return self rather than None. Chaining stuff is pretty, but having >methods that mutate self and return self looks like a source of elusive >bugs to me. > > I'm generally +0 on this idea (it seems

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Christopher Barker
Fernando Perez wrote: > more 'return self' at the end of methods which currently don't > return anything (well, we get the default None), as long as it's > sensible. +1 Though I'm a bit hesitant: if it's really consistent that methods that alter the object in place NEVER return themselves, the

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Tim Hochberg
Charles R Harris wrote: > > > On 8/29/06, *Tim Hochberg* <[EMAIL PROTECTED] > > wrote: > > Charles R Harris wrote: > > Hi, > > > > On 8/29/06, *Tim Hochberg* <[EMAIL PROTECTED] > > >

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread kortmann
>I find it much cleaner to write >x = foo.bar().baz(param).frob() >than >foo.bar() >foo.baz(param) >x = foo.frob() >but perhaps others disagree. Both of these look "clean" but i do not think that moving 3 lines to one line makes code "cleaner" They both do the same thing and if someone that d

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread David M. Cooke
On Tue, 29 Aug 2006 14:03:39 -0700 Tim Hochberg <[EMAIL PROTECTED]> wrote: > Of these, clip, conjugate and round support an 'out' argument like that > supported by ufunces; byteswap has a boolean argument telling it > whether to perform operations in place; and sort always operates in > place

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Charles R Harris
Hi Tim,On 8/29/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:>>> On 8/29/06, *Tim Hochberg* <[EMAIL PROTECTED]> [EMAIL PROTECTED] >> wrote:>> Charles R Harris wrote:> > Hi,> >> > On 8/29/06, *Tim Hochberg* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> > [EMAIL

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread David M. Cooke
On Tue, 29 Aug 2006 13:25:14 -0600 "Charles R Harris" <[EMAIL PROTECTED]> wrote: > Hi Fernando, > > On 8/29/06, Fernando Perez <[EMAIL PROTECTED]> wrote: > > > > On 8/29/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > > Speaking of features, I wonder if more of the methods should return >

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Fernando Perez
On 8/29/06, David M. Cooke <[EMAIL PROTECTED]> wrote: > On Tue, 29 Aug 2006 14:03:39 -0700 > Tim Hochberg <[EMAIL PROTECTED]> wrote: > > b = a.sort() # Returns a copy > > a.sort(out=a) # Sorts a in place > > a.sort(out=c) # Sorts a into c (probably just equivalent to c = a.sort() > > in this cas

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Charles R Harris
Hi,On 8/29/06, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:>I find it much cleaner to write>x = foo.bar().baz(param).frob() >than>foo.bar()>foo.baz(param)>x = foo.frob()>but perhaps others disagree.Both of these look "clean" but i do not think that moving 3 lines to oneline makes code "cleaner"  T

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Alan G Isaac
On Tue, 29 Aug 2006, Tim Hochberg apparently wrote: > b = a.sort() # Returns a copy Given the extant Python vocabulary, this seems like a bad idea to me. (Better to call it 'sorted' in this case.) fwiw, Alan Isaac - Usi

[Numpy-discussion] fromiter shape argument -- was Re: For loop tips

2006-08-29 Thread Torgil Svensson
>return uL,asmatrix(fromiter((idx[x] for x in L),dtype=int)) Is it possible for fromiter to take an optional shape (or count) argument in addition to the dtype argument? If both is given it could preallocate memory and we only have to iterate over L once. //Torgil On 8/29/06, Keith Goodman <

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Tim Hochberg
David M. Cooke wrote: > On Tue, 29 Aug 2006 14:03:39 -0700 > Tim Hochberg <[EMAIL PROTECTED]> wrote: > > >> Of these, clip, conjugate and round support an 'out' argument like that >> supported by ufunces; byteswap has a boolean argument telling it >> whether to perform operations in place; a

[Numpy-discussion] Py2exe / numpy troubles

2006-08-29 Thread tristan CORCELLE
> >1) First Problem: numpy\core\_internal.pyc not included in Library.zip > >C:\Lameness\dist>templatewindow.exe > Traceback (most recent call last): > File "templatewindow.py", line 7, in ? > File "wxmpl.pyc", line 25, in ? > File "matplotlib\numerix\__init__.pyc", line 60, in ? > File "N

[Numpy-discussion] Py2exe / numpy troubles

2006-08-29 Thread kortmann
My Configuration : Windows XP pro, ActivePython 2.4.2.10, Scipy 0.4.9, Numpy 0.9.8, MatplotLib 0.87.1, Py2exe 0.6.5, WxPython 2.6 1) Be very careful on how you generate the file "...\dist\library.zip".I don't know why, but the zip file generated by hand doesn't work. Check its size

Re: [Numpy-discussion] A minor annoyance with MA

2006-08-29 Thread Paul Dubois
Whatever the current state of the implementation, the original intention was that ma be, where it makes sense, a "drop-in" replacement for numpy arrays. Being retired I don't read this list all that carefully but I did see some subjects concerning axis defaults (about the 98th time we have had that

Re: [Numpy-discussion] A minor annoyance with MA

2006-08-29 Thread Travis Oliphant
PGM wrote: >Folks, >I keep running into the following problem since some recent update (I'm >currently running 1.0b3, but the problem occurred roughly around 0.9.8): > > > import numpy.core.ma as MA x=MA.array([[1],[2]],mask=False) x.sum(None) >/usr/lib64/python2.

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Charles R Harris
On 8/29/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: David M. Cooke wrote:> On Tue, 29 Aug 2006 14:03:39 -0700> Tim Hochberg <[EMAIL PROTECTED]> wrote: Of these,  clip, conjugate and round support an 'out' argument like that >> supported by ufunces;  byteswap has a boolean argument telling it>>

[Numpy-discussion] stumped numpy user seeks help

2006-08-29 Thread Mathew Yeates
My head is about to explode. I have an M by N array of floats. Associated with the columns are character labels ['a','b','b','c','d','e','e','e'] note: already sorted so duplicates are contiguous I want to replace the 2 'b' columns with the sum of the 2 columns. Similarly, replace the 3 'e' c

Re: [Numpy-discussion] stumped numpy user seeks help

2006-08-29 Thread Keith Goodman
On 8/29/06, Mathew Yeates <[EMAIL PROTECTED]> wrote: > I have an M by N array of floats. Associated with the columns are > character labels > ['a','b','b','c','d','e','e','e'] note: already sorted so duplicates > are contiguous > > I want to replace the 2 'b' columns with the sum of the 2 columns

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Charles R Harris
On 8/29/06, Charles R Harris <[EMAIL PROTECTED]> wrote: On 8/29/06, Tim Hochberg <[EMAIL PROTECTED] > wrote: David M. Cooke wrote:> On Tue, 29 Aug 2006 14:03:39 -0700> Tim Hochberg <[EMAIL PROTECTED] > wrote: Of these,  clip, conjugate and round support an 'out' argument like that >> supported

Re: [Numpy-discussion] A minor annoyance with MA

2006-08-29 Thread PGM
Travis, > This bug has hopefully been fixed (in SVN).Please let us know if it > still persists. It seems to work quite fine with the latest version of ma. Thanks a lot ! P. - Using Tomcat but need to do more? Need to supp

Re: [Numpy-discussion] Release of 1.0b5 this weekend

2006-08-29 Thread Fernando Perez
On 8/29/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > Hi all, > > Classes start for me next Tuesday, and I'm teaching a class for which I > will be using NumPy / SciPy extensively. I need to have a release of > these two (and hopefully matplotlib) that work with each other. > > Therefore, I'm

Re: [Numpy-discussion] stumped numpy user seeks help

2006-08-29 Thread Charles R Harris
On 8/29/06, Keith Goodman <[EMAIL PROTECTED]> wrote: On 8/29/06, Mathew Yeates <[EMAIL PROTECTED]> wrote:> I have an M by N array of floats. Associated with the columns are> character labels> ['a','b','b','c','d','e','e','e']  note: already sorted so duplicates > are contiguous>> I want to replace

[Numpy-discussion] array indexing problem

2006-08-29 Thread Rahul Kanwar
Hello, I am trying to extract a column from a 2D array here is what is have done: In [3]: a = array([[1,2,3],[1,2,3]]) In [4]: a Out[4]: array([[1, 2, 3], [1, 2, 3]]) In [5]: a[:, 1] Out[5]: array([2, 2]) In [6]: a[:, 1:2] Out[6]: array([[

Re: [Numpy-discussion] array indexing problem

2006-08-29 Thread Bill Baxter
That's just the way it works in numpy. Slices return arrays of lower rank. If you want arrays that behave like they do in linear algebra you can use 'matrix' instead. Check out the Numpy for Matlab users page for more info on array vs. matrix. http://www.scipy.org/NumPy_for_Matlab_Users --bb On

[Numpy-discussion] array indexing problem

2006-08-29 Thread Rahul Kanwar
Hello, I am trying to extract a column from a 2D array here is what is have done: In [3]: a = array([[1,2,3],[1,2,3]]) In [4]: a Out[4]: array([[1, 2, 3], [1, 2, 3]]) In [5]: a[:, 1] Out[5]: array([2, 2]) In [6]: a[:, 1:2] Out[6]: array([[

Re: [Numpy-discussion] array indexing problem

2006-08-29 Thread Charles R Harris
On 8/29/06, Rahul Kanwar <[EMAIL PROTECTED]> wrote: Hello,   I am trying to extract a column from a 2D array here is what is havedone:In [3]: a = array([[1,2,3],[1,2,3]])In [4]: aOut[4]:array([[1, 2, 3],    [1, 2, 3]])In [5]: a[:, 1]Out[5]: array([2,

Re: [Numpy-discussion] array indexing problem

2006-08-29 Thread Robert Kern
Rahul Kanwar wrote: > Hello, > >I am trying to extract a column from a 2D array here is what is have > done: > > > In [3]: a = array([[1,2,3],[1,2,3]]) > > In [4]: a > Out[4]: > array([[1, 2, 3], >[1, 2, 3]]) > > In [5]: a[:, 1] > Out[5]:

[Numpy-discussion] Irregular arrays

2006-08-29 Thread rw679aq02
Many problems are best solved with irregular array structures. These are aggregations not having a rectangular shape. To motivate, here's one example, http://lambda-the-ultimate.org/files/HammingNumbersDeclarative.7z - from http://lambda-the-ultimate.org/node/608#comment-5746 Irregu

Re: [Numpy-discussion] Irregular arrays

2006-08-29 Thread Travis Oliphant
[EMAIL PROTECTED] wrote: > Many problems are best solved with irregular array structures. These > are aggregations not having a rectangular shape. To motivate, here's > one example, > >http://lambda-the-ultimate.org/files/HammingNumbersDeclarative.7z > - from http://lambda-the-ultima