Re: [Numpy-discussion] Combining arrays together

2006-07-03 Thread Bill Baxter
Neat, didn't know about that.  But, grr, always returns matrix regardless of argument types.--bbOn 7/3/06, Alan G Isaac < [EMAIL PROTECTED]> wrote:On Mon, 3 Jul 2006, Bill Baxter apparently wrote: > What's the best way to combine say several 2-d arrays> together into a grid?>>> help(N.bmat)Help on

Re: [Numpy-discussion] Ctypes support in NumPy

2006-07-03 Thread Albert Strasheim
Hello all, Travis Oliphant wrote: > Hey Albert, I read the post you linked to on the ctypes mailing list. > I hope I didn't step on any toes with what I did in NumPy. I was just Certainly not. This is great stuff! > working on a ctypes interface and realized that a lot of the cruft to > conve

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Travis Oliphant
Hmmm. One thing that bothers me is that it seems that those arguing *against* this behavior are relatively long-time users of Python while those arguing *for* it are from what I can tell somewhat new to Python/NumPy. I'm not sure what this means. Is the current behavior a *wart* you get

Re: [Numpy-discussion] Ctypes support in NumPy

2006-07-03 Thread Albert Strasheim
Hello all Travis Oliphant wrote: > > Unfortunately, from the source code this is not true. It would be an > improvement, but the source code shows that the from_param of each type > does something special and only works with particular kinds of > data-types --- basic Python types or ctypes types

Re: [Numpy-discussion] Combining arrays together

2006-07-03 Thread Sven Schreiber
Bill Baxter schrieb: > Neat, didn't know about that. But, grr, always returns matrix > regardless of argument types. > --bb > Well Bill mayb you should have stayed with matrices ;-) But I also see no reason why it shouldn't be expected work for 2d-arrays in general. (Or maybe even for more dime

Re: [Numpy-discussion] unique() should return a sorted array

2006-07-03 Thread Robert Cimrman
Sasha wrote: > On 7/2/06, Norbert Nemec <[EMAIL PROTECTED]> wrote: >> ... >> Does anybody know about the internals of the python "set"? How is >> .keys() implemented? I somehow have really doubts about the efficiency >> of this method. >> > Set implementation (Objects/setobject.c) is a copy and pas

Re: [Numpy-discussion] Does zero based indexing drive anyone else crazy?

2006-07-03 Thread Simon Burton
On Sun, 2 Jul 2006 16:36:14 -0700 "Webb Sprague" <[EMAIL PROTECTED]> wrote: > > Given the long history of python and its ancestry in C (for which zero > based indexing made lots of sense since it dovetailed with thinking in > memory offsets in systems programming), there is probably nothing to >

Re: [Numpy-discussion] None as missing value

2006-07-03 Thread Sven Schreiber
Travis Oliphant schrieb: > > You can use a masked array specifically, or use nan's for missing values > and just tell Python you want a floating-point array (because it finds > the None object it's guessing incorrectly you want an "object" array. > > asarray(x, dtype=float) > > array([[ 1.

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Sven Schreiber
I agree with everything in your post, so I'm really happy you're a central figure of numpy! As for rand(), ones() etc.: I don't mind (too much) the double pair of parentheses in ones((5,5)), but I find Robert's proposal in an earlier thread ("If you want a function that takes tuples, use numpy.ran

Re: [Numpy-discussion] Combining arrays together

2006-07-03 Thread Stefan van der Walt
On Mon, Jul 03, 2006 at 11:16:26AM +0900, Bill Baxter wrote: > What's the best way to combine say several 2-d arrays together into a grid? > Here's the best I can see: > > >>> a = eye(2,2) > >>> b = 2*a > >>> c = 3*a > >>> d = 4*a > >>> r_[c_[a,b],c_[c,d]] > array([[1, 0, 2, 0], >[0, 1, 0,

[Numpy-discussion] arbitrary number of newaxis

2006-07-03 Thread Andrew Corrigan
In a function I'm writing, I multiply two arrays together: A and B. where A.ndim == 2 and I don't know B.ndim in advance If I knew B.ndim == 3, then I would write A[:,:,newaxis,newaxis,newaxis]*B[newaxis,newaxis,...] or if I knew that B.ndim == 1 then I would write A[:,:,newaxis*B[newax

Re: [Numpy-discussion] arbitrary number of newaxis

2006-07-03 Thread Sasha
On 7/3/06, Andrew Corrigan <[EMAIL PROTECTED]> wrote: > ... Essentially I want to say something like: > A[:,:,repeat(newaxis, B.ndim)]*B[newaxis,newaxis,...] > > How can I express what I mean, such that it actually works? >>> A[(slice(None),)*2 + (newaxis,)*B.ndim] Using Tomcat but need to do mo

Re: [Numpy-discussion] Ctypes support in NumPy

2006-07-03 Thread Albert Strasheim
Hello all Travis Oliphant wrote: > The ctypes-conversion object has attributes which return c_types aware > objects so that the information can be passed directly to c-code (as an > integer, the number of dimensions can already be passed using c-types). > > The information available and it's corr

Re: [Numpy-discussion] iterate along a ray: linear algebra?

2006-07-03 Thread David Huard
Hi Stephen, I don't know much about image analysis, but in the scipy tutorial (7.2 Filtering), there is an example of an image filter that highlights the edges of an image. If I guess correctly, it finds the smoothing spline of the image and then computes the derivative of the spline. A high deriva

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Tim Hochberg
Travis Oliphant wrote: > Hmmm. One thing that bothers me is that it seems that those > arguing *against* this behavior are relatively long-time users of Python > while those arguing *for* it are from what I can tell somewhat new to > Python/NumPy. I'm not sure what this means. > > Is the

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Alan G Isaac
On Mon, 03 Jul 2006, Sven Schreiber apparently wrote: > Anything that allows me to develop a consistent habit is fine with me! Consistency! That is exactly the issue, especially for those who wish to teach with numpy. I do not want to tell my students to write ones([5,5]) but rand(5,5) and alth

[Numpy-discussion] Error building numpy from svn

2006-07-03 Thread John Carter
Hi, I'm getting errors when I try and build numpy from the svn. I've followed the instructions on Installing Sci/Py/Windows at http://www.scipy.org/Installing_SciPy/Windows?highlight=%28%28%28-%2A%29%28%5Cr%29%3F%5Cn%29%28.%2A%29CategoryInstallation%5Cb%29 I've downloaded, built and tested A

Re: [Numpy-discussion] None as missing value

2006-07-03 Thread Pierre GM
> I was also a bit surprised at the following behavior: >>> a = numpy.asarray([1,1]) >>> a array([1, 1]) >>> a[0]=numpy.nan >>> a array([0, 1]) Seems to affect only the int_ arrays: >>> a = numpy.asarray([1,1], dtype=float_) >>> a array([1., 1.]) >>> a[0]=numpy.nan >>> a array([nan, 1.

Re: [Numpy-discussion] unique() should return a sorted array

2006-07-03 Thread David Huard
Here is a quick benchmark between numpy's unique, unique1d and sasha's unique:x = rand(10)*100x = x.astype('i')%timeit unique(x)10 loops, best of 3: 525 ms per loop%timeit unique_sasha(x) 100 loops, best of 3: 10.7 ms per looptimeit unique1d(x)100 loops, best of 3: 12.6 ms per loopSo I wonder w

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Sasha
On 7/3/06, Alan G Isaac <[EMAIL PROTECTED]> wrote: > > Consistency! That is exactly the issue, > especially for those who wish to teach with numpy. > > I do not want to tell my students to write > ones([5,5]) > but > rand(5,5) > and although relatively new to Python > I actually like the pract

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Christopher Barker
Tim Hochberg wrote: > I also find: > > ones([5, 5], dt) > > clearer than: > >ones(5, 5, dt) > > or, more dramatic, consider: ones([dx, dy], dt) versus ones(dx, dy, dt). > B! And I imagine this is EXACTLY why Numeric was originally designed that way: when there are more arguments to

Re: [Numpy-discussion] Does zero based indexing drive anyone else crazy?

2006-07-03 Thread Christopher Barker
Webb Sprague wrote: > it is far more natural to program if the indices are aligned with the > counts of the elements I suggest that it's only more natural if that's what you're used to -- i.e. you come form other languages that do it that way. I fairly rarely get bitten by indexing 1, rather th

[Numpy-discussion] dtype conversion errors in cumsum

2006-07-03 Thread Nikhil Padmanabhan
Hi, (I saw some discussion of this on the mailing list, but was not sure if there was a solution reached...) If I try to use cumsum on a numpy array with the dtype keyword, I get the wrong answer if dtype does not match that of the array. More specifically, Python 2.4.3 (#1, Apr 3 2006, 18

Re: [Numpy-discussion] None as missing value

2006-07-03 Thread Sven Schreiber
Pierre GM schrieb: >> I was also a bit surprised at the following behavior: a = numpy.asarray([1,1]) a > array([1, 1]) a[0]=numpy.nan a > array([0, 1]) > > Seems to affect only the int_ arrays: > a = numpy.asarray([1,1], dtype=float_) a > array([1., 1.]) a[0]=nu

Re: [Numpy-discussion] Ctypes support in NumPy

2006-07-03 Thread Travis Oliphant
Albert Strasheim wrote: > Stefan and I did some more experiments and it seems like .ctypes.strides > isn't doing the right thing for subarrays. > > For example: > > In [52]: x = N.rand(3,4) > In [57]: [x.ctypes.strides[i] for i in range(x.ndim)] > Out[57]: [32, 8] > > This looks fine. But for this

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Sven Schreiber
Sasha schrieb: > > Consistency is already lost because 1d case allows both ones(5) and > ones([5]) (and even ones((5,)) if anyone can tolerate that > abomination). I don't think those who argue for sequence only are > willing to require ones([5]). Imho consistency is not lost there precisely be

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Sasha
On 7/3/06, Sven Schreiber <[EMAIL PROTECTED]> wrote: > ... > I was arguing that it's inconvenient exactly because it's inconsistent, > so I don't see the tradeoff here. (Given that I'm fairly indifferent > between one or two pairs of parentheses.) > It is convenient to be able to write zeros(5) an

[Numpy-discussion] dtype error in cumsum

2006-07-03 Thread Nikhil Padmanabhan
(I sent the following from my gmail account, but that does not seem to have been accepted by sourceforge -- apologies in advance if it shows up twice) Hi, (I saw some discussion of this on the mailing list, but was not sure if there was a solution reached, so I thought I'd ask again) If

Re: [Numpy-discussion] dtype error in cumsum

2006-07-03 Thread Sasha
It did get through all right. SF is a mess. In any case what you observe is clearly a bug. Looks like uninitialized memory somewhere. Please file a bug report at http://projects.scipy.org/scipy/numpy/newticket . On 7/3/06, Nikhil Padmanabhan <[EMAIL PROTECTED]> wrote: > (I sent the following fro

Re: [Numpy-discussion] iterate along a ray: linear algebra?

2006-07-03 Thread Torgil Svensson
I've done something similar a few years ago (numarray,numeric). I started roughly at the middle and did 64 points from a reference point (xc,yc). This point together with a point at the edge of the image (xp,yp) also defined a reference angle (a0). (ysize,xsize) is the shape of the intensity image.

[Numpy-discussion] A C++ library and the new array interface: the best approach?

2006-07-03 Thread Fernando Perez
Hi all, I'd like to ask for a bit of guidance on the best path to follow regarding the integration of an existing C++ library with numpy, given the recent developments on these topics: 1. the new array interface specification 2. the ctypes discussions 3. pyrex Our situation is the following: a

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Charles R Harris
+1 for tuples,Because dimensions *are* tuples. I think using tuples is a good habit to get into and agree with Robert Kern's comments about using the new random number interface instead of the old compatibility functions rand and randn. Chuck Using Tomcat but need to do more? Need to support web se

Re: [Numpy-discussion] A C++ library and the new array interface: the best approach?

2006-07-03 Thread Travis Oliphant
Fernando Perez wrote: > Hi all, > > but my lack of familiarity with all the details of new type creation got me a > bit lost. I'm sure the information I need is all there, but right now I > don't > really see the forest with all the leaves in my face. I've also read the > various recent threa

[Numpy-discussion] Namespaces in header files [Was: Time for beta1 of NumPy 1.0]

2006-07-03 Thread Lee Taylor
On Thu, 29 Jun 2006, Travis Oliphant wrote: > I think it's time for the first beta-release of NumPy 1.0 > > I'd like to put it out within 2 weeks. Please make any comments or > voice major concerns so that the 1.0 release series can be as stable as > possible. One issue I ran across that I have

Re: [Numpy-discussion] A C++ library and the new array interface: the best approach?

2006-07-03 Thread Andrew Straw
Dear Fernando, A couple of quick thoughts: A) Despite my love of Pyrex, it probably isn't the tool for the job -- it doesn't play particularly well with C++, and it would require you to write custom code for every function wrapped. B) It sounds like you want something that will more-or-less auto

Re: [Numpy-discussion] Does zero based indexing drive anyone else crazy?

2006-07-03 Thread Keith Goodman
On 7/2/06, Webb Sprague <[EMAIL PROTECTED]> wrote: > Given the long history of python and its ancestry in C (for which zero > based indexing made lots of sense since it dovetailed with thinking in > memory offsets in systems programming), there is probably nothing to > be done now. I guess I just

[Numpy-discussion] Research study on CVS - you can help and get paid!

2006-07-03 Thread Eric Gilbert
I am a Computer Science graduate student at the University of Illinois at Urbana-Champaign. I need your help in a study I want to conduct. I have created a project called LifeSource that visualizes CVS repositories. You can find screenshots and info here: http://social.cs.uiuc.edu/people/gil

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Bill Baxter
I just noticed that array.transpose() takes either a tuple or separate arguments.  I'm not trying to imply anything, just I was thinking such a thing had no precedent in numpy, but it turns out it does.And as an aside, the docstring for .transpose() needs fixing. It says: >>> a = array([[1,2],[3,4]

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Robert Kern
Bill Baxter wrote: > How does one use this Trac thing again? I couldn't find a "submit a > bug" link anywhere on the web scipy.org web page. I > found it once before, but now I can't seem to locate it. http://projects.scipy.org/scipy/scipy You need to register first. Click

Re: [Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

2006-07-03 Thread Robert Kern
Robert Kern wrote: > Bill Baxter wrote: >> How does one use this Trac thing again? I couldn't find a "submit a >> bug" link anywhere on the web scipy.org web page. I >> found it once before, but now I can't seem to locate it. > > http://projects.scipy.org/scipy/scipy > > Yo

Re: [Numpy-discussion] MA bug or feature?

2006-07-03 Thread Michael Sorich
On 6/23/06, Paul Dubois <[EMAIL PROTECTED]> wrote: > In the original MA in Numeric, I decided that to constantly check for masks > that didn't actually mask anything was not a good idea. It punishes normal > use with a very expensive check that is rarely going to be true. > > If you are in a settin

Re: [Numpy-discussion] MA bug or feature?

2006-07-03 Thread Pierre GM
Michael, I wonder whether the Mask class you suggest is not a bit overkill. There should be enough tools in the existing MA module to do what we want. And I don't wanna think about compatibility the number of changes in the MA code that'd be required (but I'm lazy)... For the sake of consistenc