Re: [Numpy-discussion] Buffer interface PEP

2007-03-27 Thread Zachary Pincus
>> Is this saying that either NULL or a pointer to "B" can be supplied >> by getbufferproc to indicate to the caller that the array is unsigned >> bytes? If so, is there a specific reason to put the (minor) >> complexity of handling this case in the caller's hands, instead of >> dealing with it int

[Numpy-discussion] Further matrix oddities: no inner product

2007-03-27 Thread Charles R Harris
In mathematics, and inner product is a sesquilinear form on pairs of vectors, so at the least it should return a scalar. In numpy inner is a sum over the last indices. OK, so we have In [10]: inner(ones(2),ones(2)) Out[10]: 2.0 This doesn't work as an inner product for column vectors, which woul

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Alan G Isaac
>> On Tue, 27 Mar 2007, Robert Kern apparently wrote: >>> Gram-Schmidt orthogonalization > Alan G Isaac wrote: >> I take it from context that you consider it desirable >> to end up with a list of matrices? Robert wrote: > Honestly, I don't care. You asked about iteration, and > I gave y

Re: [Numpy-discussion] use of concatenate with subclass of ndarray

2007-03-27 Thread Pierre GM
On Tuesday 27 March 2007 20:08:04 Bryce Hendrix wrote: > We have a class which is a subclass of ndarray which defines > __array_finalize__ to add an attribute. The class looks something like > this: Ahah, we ran into this problem a few months ago: You should not initialize your "units" attribute i

[Numpy-discussion] use of concatenate with subclass of ndarray

2007-03-27 Thread Bryce Hendrix
We have a class which is a subclass of ndarray which defines __array_finalize__ to add an attribute. The class looks something like this: class UnitArray(ndarray): # ... def __new__(cls, data, dtype=None, copy=True, units=None): # ... arr = array(data, dtype=dtype, copy=copy) res = nd

Re: [Numpy-discussion] Complex 'where' expression

2007-03-27 Thread Tom Denniston
You need to use numpy.logical_and. The and and or operators do not work elementwise on arrays to the best of my understanding. I think it is a limitation on the way logical operators are applied in python or maybe it is an intentional numpy limitation. I'm sure others on the list could explain be

Re: [Numpy-discussion] Buffer interface PEP

2007-03-27 Thread Travis Oliphant
Zachary Pincus wrote: > Hi, > > > Is this saying that either NULL or a pointer to "B" can be supplied > by getbufferproc to indicate to the caller that the array is unsigned > bytes? If so, is there a specific reason to put the (minor) > complexity of handling this case in the caller's han

Re: [Numpy-discussion] masked array with mask an instance of numpy.memmap

2007-03-27 Thread Pierre GM
> Is there something deficient about numpy.core.ma? numpy.core.ma objects are not ndarrays. Therefore, their mask disappear when used as the input of something like numpy.array(data, subok=True), which is quickly problematic. Moreover, they are not especially subclassing-friendly, which was my

Re: [Numpy-discussion] masked array with mask an instance of numpy.memmap

2007-03-27 Thread Glen W. Mabey
On Tue, Mar 27, 2007 at 05:47:24PM -0500, Glen W. Mabey wrote: > Is there something deficient about numpy.core.ma? Okay, I just found sandbox/maskedarray/CHANGELOG . Glen ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy

Re: [Numpy-discussion] masked array with mask an instance of numpy.memmap

2007-03-27 Thread Glen W. Mabey
On Tue, Mar 27, 2007 at 06:35:51PM -0400, Pierre GM wrote: > > > Whoa. You didn't mean numpy SVN, I take it. So, will numpy.median not > > ever take into account the mask? > > Mmh, that should be part of numpy.core.ma instead: let's keep the masked > arrays a bit on the side. > > > And, how re

Re: [Numpy-discussion] masked array with mask an instance of numpy.memmap

2007-03-27 Thread Pierre GM
> Whoa. You didn't mean numpy SVN, I take it. So, will numpy.median not > ever take into account the mask? Mmh, that should be part of numpy.core.ma instead: let's keep the masked arrays a bit on the side. > And, how recently did you upload them? I updated scipy today and I > still get: Ah,

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Alan Isaac
On Tue, 27 Mar 2007, Fernando Perez wrote: > it's probably worth mentioning, as a data point, that the > python language has a well established precedent for > 'iteration over a FOO where a FOO is yielded': > In [1]: s='abc' Yes. And I recall being bitten by this long ago. Now it feels natura

Re: [Numpy-discussion] A unique function...

2007-03-27 Thread Pierre GM
Zach, > There's unique and unique1d, but these don't output the number of > occurences. > There's also bincount, which outputs the number of each element, but > includes zeros for non-present elements and so could be problematic > for certain data. Well, I found it anyway. As I was pretty sure it

Re: [Numpy-discussion] masked array with mask an instance of numpy.memmap

2007-03-27 Thread Glen W. Mabey
On Tue, Mar 27, 2007 at 05:54:05PM -0400, Pierre GM wrote: > On Tuesday 27 March 2007 17:42:18 Glen W. Mabey wrote: > > However, using a memmap for the mask value seems to load the entire > > object into memory, even if it is already of type bool. > > > > How hard would it be to change that behavio

Re: [Numpy-discussion] masked array with mask an instance of numpy.memmap

2007-03-27 Thread Pierre GM
On Tuesday 27 March 2007 17:42:18 Glen W. Mabey wrote: > However, using a memmap for the mask value seems to load the entire > object into memory, even if it is already of type bool. > > How hard would it be to change that behavior? Oh, I have no idea about that... > Also, it seems that median()

[Numpy-discussion] masked array with mask an instance of numpy.memmap

2007-03-27 Thread Glen W. Mabey
I've been using numpy.memmap to access large arrays very nicely, but now I desire to instantiate a masked array that uses memmap objects. Using a memmap instance for the data works just fine and as expected. However, using a memmap for the mask value seems to load the entire object into memory,

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Robert Kern
Alan G Isaac wrote: > On Tue, 27 Mar 2007, Robert Kern apparently wrote: >> Gram-Schmidt orthogonalization > > I take it from context that you consider it desirable > to end up with a list of matrices? Honestly, I don't care. You asked about iteration, and I gave you an example where it was imp

Re: [Numpy-discussion] A unique function...

2007-03-27 Thread Zachary Pincus
Hello, There's unique and unique1d, but these don't output the number of occurences. There's also bincount, which outputs the number of each element, but includes zeros for non-present elements and so could be problematic for certain data. Zach On Mar 27, 2007, at 2:28 PM, Pierre GM wrot

[Numpy-discussion] A unique function...

2007-03-27 Thread Pierre GM
All, I could swear that I ran once into a numpy (or scipy) function that output the unique values of a 1d ndarray along with the number of occurences of each element. If I'm not completely mistaken, it 's a private function initially in Fortran. Does this ring a bell to anyone ? Where could I fi

Re: [Numpy-discussion] Buffer interface PEP

2007-03-27 Thread Zachary Pincus
Hi, I have a specific question and then a general question, and some minor issues for clarification. Specifically, regarding the arguments to getbufferproc: > 166 format > 167address of a format-string (following extended struct > 168syntax) indicating what is in each element of > 169

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Joachim Dahl
On 3/27/07, Zachary Pincus <[EMAIL PROTECTED]> wrote: So we are left with the current behavior: (a) M[i,:] is a matrix. (b) M[i] is a matrix. (c) Iteration over M yields matrices. I find it useful if M[i] indexes the matrix interpreted as a column-vector (vec(M), or M(:) in Matlab notation),

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Fernando Perez
On 3/27/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: > Hi Zach, > > The use case I requested was for iteration over a > matrix where it is desirable that matrices are yielded. I'm personally not really partial to any side of this discussion, given how I don't use matrices at all (I'm content with a

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Zachary Pincus
> The use case I requested was for iteration over a > matrix where it is desirable that matrices are yielded. > That is not what you offered. No, I offered a thorough discussion of why the design of numpy, as I imperfectly understand it, make the trade-offs to achieve your desired goal unpalat

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Alan G Isaac
On Tue, 27 Mar 2007, Robert Kern apparently wrote: > Gram-Schmidt orthogonalization I take it from context that you consider it desirable to end up with a list of matrices? I guess I would find it more natural to work with the arrays, but perhaps that starts just being taste. Thank you, Alan I

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Robert Kern
Alan G Isaac wrote: > Hi Zach, > > The use case I requested was for iteration over a > matrix where it is desirable that matrices are yielded. > That is not what you offered. > > The context for this request is my own experience: > whenever I have needed to iterate over matrices, > I have always

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Alan G Isaac
Hi Zach, The use case I requested was for iteration over a matrix where it is desirable that matrices are yielded. That is not what you offered. The context for this request is my own experience: whenever I have needed to iterate over matrices, I have always wanted the arrays. So I am simply int

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Zachary Pincus
Hello all, I suspect my previous email did not contain the full chain of my reasoning, because I thought that some parts were basically obvious. My point was merely that given some pretty basic fundamental tenants of numpy, Alan's suggestions quickly lead to *serious issues* far worse than

[Numpy-discussion] Buffer interface PEP

2007-03-27 Thread Travis Oliphant
Hi all, I'm having a good discussion with Carl Banks and Greg Ewing over on python-dev about the buffer interface. We are converging on a pretty good design, IMHO. If anybody wants to participate in the discussion, please read the PEP (there are a few things that still need to change) and a

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Bill Spotz
It seems to me that using shapes, (m,1) versus (1,n), to determine whether a vector is column- or row-oriented is a hack (or at least feels like one). If we know we have a vector, then we want to use a single index to obtain a scalar, and that extra "0," or ",0" shouldn't be necessary. It

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Travis Oliphant
Alan Isaac wrote: > On Mon, 26 Mar 2007, Travis Oliphant wrote: > >> It actually has been offered. You just don't accept it. >> Matrices are containers of matrices. >> If M is an (mxn) matrix then M[0] is a (1xn) matrix. >> Viewing this 1xn matrix as a 1-d array loses it's row-vectornes

Re: [Numpy-discussion] Complex 'where' expression

2007-03-27 Thread Robert Kern
Ludwig wrote: > In pseudo code: > > indexes = where(image1 > 0 and image2 > 0 and sigma < quality) > result[indexes] = i # scalar > > > When I run this numpy tells me that the that the truth value of the array > comparison is ambiguous -- but I do not want to compare the whole arrays here, > bu

[Numpy-discussion] Complex 'where' expression

2007-03-27 Thread Ludwig
A bit new to numpy, trying to move over some IDL code. I have a complex array selection expression, where I need an array of indexes as a result, so I can use this as a selection expression to apply changes to a different array. I have two images, image1 and image2, plus an array sigma, the resul

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Colin J. Williams
Alan G Isaac wrote: > On Mon, 26 Mar 2007, "Colin J. Williams" apparently wrote: >> One would expect the iteration over A to return row >> vectors, represented by (1, n) matrices. > > This is again simple assertion. > **Why** would "one" expect this? > Some people clearly do not. > > One perso

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Joachim Dahl
I would like to hear your opinion on developing an explicit sparse/dense 2D matrix class with indexing similar to Matlab, and without significant differences between sparse and dense matrices from the user's perspective... I know that it's not one of Numpy/Scipy's goals to clone Matlab, but I th

Re: [Numpy-discussion] Tuning sparse stuff in NumPy

2007-03-27 Thread Robert Cimrman
David Koch wrote: > On 3/27/07, Robert Cimrman <[EMAIL PROTECTED]> wrote: >> >> >> ok. now which version of scipy (scipy.__version__) do you use (you may >> have posted it, but I missed it)? Not so long ago, there was an effort >> by Nathan Bell and others reimplementing sparsetools + scipy.sparse

Re: [Numpy-discussion] defmatrix.py

2007-03-27 Thread Colin J. Williams
Charles R Harris wrote: > > > On 3/26/07, *Travis Oliphant* <[EMAIL PROTECTED] > > wrote: > > Charles R Harris wrote: > > > > > > > The rule 1-d is always a *row* vector only applies when > converting > > to a > > matrix. >

Re: [Numpy-discussion] defmatrix.py

2007-03-27 Thread Colin J. Williams
Charles R Harris wrote: > > > On 3/26/07, *Travis Oliphant* <[EMAIL PROTECTED] > > wrote: > > > > I think that might be the simplest thing, dot overrides subtypes. > BTW, > > here is another ambiguity > > > > In [6]: dot(array([[1]]),ones(2)) >

Re: [Numpy-discussion] missing use case

2007-03-27 Thread Alan G Isaac
Hi Zachary, I think your response highlights very well the apparent design flaw. Here is your response to my request for a use case where iteration over a matrix should yield matrices: do not iterate! Does some part of you not find that just a little bizarre?! As for offering as a use ca

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Christopher Barker
Zachary Pincus wrote: > rest of linear algebra -- e.g. that m[0] yields a matrix if m is a > matrix-- it almost certainly would violate the principle of least > surprise for iteration over m (intuitively understood to be choosing m > [0] then m[1] and so forth) to yield anything other than a m

Re: [Numpy-discussion] Tuning sparse stuff in NumPy

2007-03-27 Thread David Koch
On 3/27/07, Robert Cimrman <[EMAIL PROTECTED]> wrote: ok. now which version of scipy (scipy.__version__) do you use (you may have posted it, but I missed it)? Not so long ago, there was an effort by Nathan Bell and others reimplementing sparsetools + scipy.sparse to get better usability and per

Re: [Numpy-discussion] Tuning sparse stuff in NumPy

2007-03-27 Thread Robert Cimrman
David Koch wrote: > Ok, > > I did and the results are: > csc * csc: 372.601957083 > csc * csc: 3.90811300278 a typo here? which one is csr? > csr * csc: 15.3202679157 > csr * csr: 3.84498214722 > > Mhm, quite insightful. Note, that in an operation X.transpose() * X, > where X > is csc_matrix,

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Zachary Pincus
> Exactly: that was one other thing I found artificial. > Surely the points will then be wanted as arrays. > > So my view is that we still do not have a use case > for wanting matrices yielded when iterating across > rows of a matrix. It's pretty clear from my perspective: 1-D slices of matrices *

Re: [Numpy-discussion] ATLAS problems

2007-03-27 Thread Simon Burton
The last time I had this problem i ended up running python in gdb and setting breakpoints at the appropriate dgemm calls. That way i could see exactly what numpy was using to do dgemm. Simon. On Tue, 27 Mar 2007 10:20:41 +1000 "Justin Bedo" <[EMAIL PROTECTED]> wrote: > Hi All, > > I'm trying t

Re: [Numpy-discussion] matrix indexing question

2007-03-27 Thread Alan G Isaac
On Tue, 27 Mar 2007, Bill Baxter apparently wrote: > xformedPt = someComplicatedNonLinearThing(pt) > I do stuff like the above quite frequently in my code, > although with arrays rather than matrices. Exactly: that was one other thing I found artificial. Surely the points will then be wanted

Re: [Numpy-discussion] defmatrix.py

2007-03-27 Thread Sven Schreiber
Travis Oliphant schrieb: > O.K. So, the problem is that when I defined matrix multiplication, I > mistakenly believed that dot always interpreted 1-d arrays as row > vectors which it is now clear it doesn't. > > I think this led to the issues. > > So, making dot always return arrays seems li