Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Andrew Straw
Torgil Svensson wrote: > OS-specific routines (probably the c-library, haven't looked). I > think python should be consistent regarding this across platforms but > I don't know if different c-libraries generates different strings for > special numbers. Anyone? Windows and Linux certainly genera

Re: [Numpy-discussion] Unwanted attachments on the SciPy home page.

2007-06-25 Thread Robert Kern
Charles R Harris wrote: > Hi Robert, > > Some porn has been uploaded to the attachments page at scipy.org > Removed. Thank you. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interp

[Numpy-discussion] Unwanted attachments on the SciPy home page.

2007-06-25 Thread Charles R Harris
Hi Robert, Some porn has been uploaded to the attachments page at scipy.org Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] Familiar w/ reduce ?

2007-06-25 Thread Pierre GM
All, I have a (m_1+1,m_2+1) matrix of 0 and 1, and I need to compute a second matrix U by recurrence. A double-loop as such # U = empty((m_1+1, m_2+1)) U[:,0] = C[:,0] U[0,:] = C[0,:] for i in range(1,m_1+1): for j in range(1,m_2+1): U[i,j] = C[i,j] * (U[i,j

Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Torgil Svensson
On 6/25/07, Torgil Svensson <[EMAIL PROTECTED]> wrote: > On 6/25/07, Robert Kern <[EMAIL PROTECTED]> wrote: > > NaNs and infs are IEEE-754 concepts. Python does run on non-IEEE-754 > > platforms, > > and I don't think that python-dev will want to entirely exclude them. You > > will > > have to do

Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Robert Kern
Torgil Svensson wrote: > On 6/25/07, Warren Focke <[EMAIL PROTECTED]> wrote: > >> False. No NaN should ever compare equal to anything, even itself. But if >> the system is 754-compliant, it won't. >> >> "isnan(float(str(nan))) == True" would be nice, though. > > Good point. Does this also hold

Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Robert Kern
Torgil Svensson wrote: > On 6/25/07, Robert Kern <[EMAIL PROTECTED]> wrote: >> NaNs and infs are IEEE-754 concepts. Python does run on non-IEEE-754 >> platforms, >> and I don't think that python-dev will want to entirely exclude them. You >> will >> have to do *something* about those platforms. P

Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Torgil Svensson
On 6/25/07, Warren Focke <[EMAIL PROTECTED]> wrote: > False. No NaN should ever compare equal to anything, even itself. But if > the system is 754-compliant, it won't. > > "isnan(float(str(nan))) == True" would be nice, though. > Good point. Does this also hold true for the quiet nan's? //Torg

Re: [Numpy-discussion] effectively computing variograms with numpy

2007-06-25 Thread Hanno Klemm
I will try and dig a bit more in the literature, maybe I find something. Hanno On Jun 25, 2007, at 4:59 PM, Timothy Hochberg wrote: > > > > On 6/25/07, Hanno Klemm < [EMAIL PROTECTED]> wrote: >> Tim, >> >> Thank you very much, the code does what's it expected to do. >> Unfortunately the thing

Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Torgil Svensson
On 6/25/07, Robert Kern <[EMAIL PROTECTED]> wrote: > NaNs and infs are IEEE-754 concepts. Python does run on non-IEEE-754 > platforms, > and I don't think that python-dev will want to entirely exclude them. You will > have to do *something* about those platforms. Possibly, they just won't > suppo

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Giorgio F. Gilestro
BTW, I found nanmean and nanstd in scipy.stats.stats will be good for my case too. On 6/25/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On 6/25/07, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: > > Masked array seems definitely to be the way to go, thanks a lot. > > > > I must say that

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Charles R Harris
On 6/25/07, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: Masked array seems definitely to be the way to go, thanks a lot. I must say that this entire issue doesn't make much sense to me: my understanding is the a NaN is different from an INF, therefore one would assume that really there is no

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Robert Kern
Giorgio F. Gilestro wrote: > Masked array seems definitely to be the way to go, thanks a lot. > > I must say that this entire issue doesn't make much sense to me: my > understanding is the a NaN is different from an INF, therefore one > would assume that really there is no reason why a not-number

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Giorgio F. Gilestro
Masked array seems definitely to be the way to go, thanks a lot. I must say that this entire issue doesn't make much sense to me: my understanding is the a NaN is different from an INF, therefore one would assume that really there is no reason why a not-number should not be ignored by default by a

Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Warren Focke
On Mon, 25 Jun 2007, Torgil Svensson wrote: > handled with sub-classing. At a minimum "float(str(nan))==nan" should > evaluate as True. False. No NaN should ever compare equal to anything, even itself. But if the system is 754-compliant, it won't. "isnan(float(str(nan))) == True" would be n

Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Robert Kern
Torgil Svensson wrote: > On 6/22/07, Robert Kern <[EMAIL PROTECTED]> wrote: >> Making float types parse/emit standard string >> representations for NaNs and infs could probably go in if you were to >> provide an >> implementation and work out all of the bugs and cross-platform issues. > > The flo

Re: [Numpy-discussion] annoying numpy string to float conversion behaviour

2007-06-25 Thread Torgil Svensson
On 6/22/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Making float types parse/emit standard string > representations for NaNs and infs could probably go in if you were to provide > an > implementation and work out all of the bugs and cross-platform issues. The float types already emit string-repr

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Pierre GM
On Monday 25 June 2007 14:15:20 Giorgio F. Gilestro wrote: > Thanks. > Actually those I care the most are average and std. > Is there a way to know the number of NaN in an array? Giorgio, You could use: numpy.isnan(x).sum() But once again masked arrays were designed to handle this kind of situa

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Andrew Straw
Giorgio F. Gilestro wrote: > I find myself in a situation where an array may contain not-Numbers > that I set as NaN. > Yet, whatever operation I do on that array( average, sum...) will > threat the NaN as infinite values rather then ignoring them as I'd > like it'd do. > > Am I missing something?

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Robert Kern
Giorgio F. Gilestro wrote: > Thanks. > Actually those I care the most are average and std. > Is there a way to know the number of NaN in an array? isnan(a).sum() -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad att

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Giorgio F. Gilestro
Thanks. Actually those I care the most are average and std. Is there a way to know the number of NaN in an array? On 6/25/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > > On 6/25/07, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: > > I find myself in a situation where an array may contai

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Timothy Hochberg
On 6/25/07, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: I find myself in a situation where an array may contain not-Numbers that I set as NaN. Yet, whatever operation I do on that array( average, sum...) will threat the NaN as infinite values rather then ignoring them as I'd like it'd do.

[Numpy-discussion] average of array containing NaN

2007-06-25 Thread Giorgio F. Gilestro
I find myself in a situation where an array may contain not-Numbers that I set as NaN. Yet, whatever operation I do on that array( average, sum...) will threat the NaN as infinite values rather then ignoring them as I'd like it'd do. Am I missing something? Is this a bug or a feature? :-)

Re: [Numpy-discussion] effectively computing variograms with numpy

2007-06-25 Thread Timothy Hochberg
On 6/25/07, Hanno Klemm <[EMAIL PROTECTED]> wrote: Tim, Thank you very much, the code does what's it expected to do. Unfortunately the thing is still pretty slow on large data sets. This does seem like the kind of thing that there should be a faster way to compute, particularly since you ar

Re: [Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Pierre GM
On Monday 25 June 2007 10:14:21 Jesper Larsen wrote: > Hi Pierre and others, > I was not aware that the way to use masked arrays was as you describe. I > thought you had to somehow modify the mask (but the method you describe is > of course much more elegant). Thanks for answering my very basic qu

Re: [Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Jesper Larsen
Hi Pierre and others, On Monday 25 June 2007 15:37, Pierre GM wrote: > On Monday 25 June 2007 05:12:01 Jesper Larsen wrote: > > myarray.mask[i] = True > > Mmh. Experience shows that directly accessing the mask can lead to bad > surprises. To mask a series of values in an array, the easiest (and >

Re: [Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Pierre GM
On Monday 25 June 2007 05:12:01 Jesper Larsen wrote: > Hi numpy users, > > I have a masked array. I am looping over the elements of this array and > sometimes want to set a value to missing. Normally this can be done by: > > myarray.mask[i] = True Mmh. Experience shows that directly accessing the

[Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Jesper Larsen
Hi numpy users, I have a masked array. I am looping over the elements of this array and sometimes want to set a value to missing. Normally this can be done by: myarray.mask[i] = True However the mask attribute is not indexable when there are no existing missing values in the array (it is simpl

[Numpy-discussion] arr.dtype.byteorder == '=' --- is this "good code"

2007-06-25 Thread Sebastian Haase
Hi, Suppose I'm on a little-edian system. Could I have a little-endian numpy array arr, where arr.dtype.byteorder would actually be "<" instead of "=" !? There are two kinds of systems: little edian and big endian. But there are three possible byteorder values: "<", ">" and "=" I assume that if

Re: [Numpy-discussion] effectively computing variograms with numpy

2007-06-25 Thread Hanno Klemm
Tim, Thank you very much, the code does what's it expected to do. Unfortunately the thing is still pretty slow on large data sets. I will probably now look for ways to calculate the variogram from some random samples of my data. Thanks for the observation regarding the square array, that would ha

Re: [Numpy-discussion] PCA - Principal Component Analysis

2007-06-25 Thread Giorgio Luciano
I've done a version of nipals algorithm in python (i'ts a translation of a matlab routine in brereton made by Riccardo Leardi). far from perfect (my transport i mean) but working (I've tested on my datasets and it runned ok) you can download it at www.chemometrics.it. Hope it will help and if yo

Re: [Numpy-discussion] PCA - Principal Component Analysis

2007-06-25 Thread Bill Baxter
Except last I checked numpy.linalg doesn't have an efficient method for retrieving only a few PCA components. So yeh, you can do PCA but it will be *really* slow on most of the types of problems that PCA is usually used for. You need something like an ARPACK wrapper, which I think they have in the