Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Keith Goodman
On Fri, Dec 11, 2009 at 6:38 PM, Robert Kern wrote: > On Fri, Dec 11, 2009 at 18:38, Keith Goodman wrote: > >> That seems to work. To avoid changing the input >> x = np.array(1) x.shape >>   () y = nan_to_num(x) x.shape >>   (1,) >> >> I moved y = x.copy() further up and switc

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Hoyt Koepke
> One thing to note is that dot uses optimized atlas if available, which > makes it quite faster than equivalent operations you would do using > purely numpy. I doubt that's the reason here, since the arrays are > small, but that's something to keep in mind when performances matter: > use dot where

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread David Cournapeau
On Fri, Dec 11, 2009 at 10:06 PM, Bruce Southey wrote: > > Having said that, the more you can vectorize your function, the more > efficient it will likely be especially with Atlas etc. One thing to note is that dot uses optimized atlas if available, which makes it quite faster than equivalent op

Re: [Numpy-discussion] non-standard standard deviation

2009-12-11 Thread Dr. Phillip M. Feldman
Anne Archibald wrote: > > 2009/11/29 Dr. Phillip M. Feldman : > >> All of the statistical packages that I am currently using and have used >> in >> the past (Matlab, Minitab, R, S-plus) calculate standard deviation using >> the >> sqrt(1/(n-1)) normalization, which gives a result that is unbia

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Robert Kern
On Fri, Dec 11, 2009 at 18:38, Keith Goodman wrote: > That seems to work. To avoid changing the input > >>> x = np.array(1) >>> x.shape >   () >>> y = nan_to_num(x) >>> x.shape >   (1,) > > I moved y = x.copy() further up and switched x's to y's. Here's what > it looks like: > > def nan_to_num(x)

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Keith Goodman
On Fri, Dec 11, 2009 at 4:06 PM, Robert Kern wrote: > On Fri, Dec 11, 2009 at 17:44, Keith Goodman wrote: >> On Fri, Dec 11, 2009 at 2:22 PM, Robert Kern wrote: >>> On Fri, Dec 11, 2009 at 16:09, Keith Goodman wrote: On Fri, Dec 11, 2009 at 1:14 PM, Robert Kern wrote: > On Fri, Dec 11

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Robert Kern
On Fri, Dec 11, 2009 at 18:03, Keith Goodman wrote: > Ack! The "if issubclass(t, _nx.inexact)" fix doesn't work. It solves > the bool problem but it introduces its own problem since numpy.object_ > is not a subclass of inexact: > >>> nan_to_num([np.inf]) >   array([ Inf]) Right. This is the prob

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Robert Kern
On Fri, Dec 11, 2009 at 17:44, Keith Goodman wrote: > On Fri, Dec 11, 2009 at 2:22 PM, Robert Kern wrote: >> On Fri, Dec 11, 2009 at 16:09, Keith Goodman wrote: >>> On Fri, Dec 11, 2009 at 1:14 PM, Robert Kern wrote: On Fri, Dec 11, 2009 at 14:41, Keith Goodman wrote: > On Fri, Dec 11

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Keith Goodman
On Fri, Dec 11, 2009 at 3:44 PM, Keith Goodman wrote: > On Fri, Dec 11, 2009 at 2:22 PM, Robert Kern wrote: >> On Fri, Dec 11, 2009 at 16:09, Keith Goodman wrote: >>> On Fri, Dec 11, 2009 at 1:14 PM, Robert Kern wrote: On Fri, Dec 11, 2009 at 14:41, Keith Goodman wrote: > On Fri, Dec

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Keith Goodman
On Fri, Dec 11, 2009 at 2:22 PM, Robert Kern wrote: > On Fri, Dec 11, 2009 at 16:09, Keith Goodman wrote: >> On Fri, Dec 11, 2009 at 1:14 PM, Robert Kern wrote: >>> On Fri, Dec 11, 2009 at 14:41, Keith Goodman wrote: On Fri, Dec 11, 2009 at 12:08 PM, Bruce Southey wrote: >>> > So I ag

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Robert Kern
On Fri, Dec 11, 2009 at 16:09, Keith Goodman wrote: > On Fri, Dec 11, 2009 at 1:14 PM, Robert Kern wrote: >> On Fri, Dec 11, 2009 at 14:41, Keith Goodman wrote: >>> On Fri, Dec 11, 2009 at 12:08 PM, Bruce Southey wrote: >> So I agree that it should leave the input untouched when a non-floa

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Keith Goodman
On Fri, Dec 11, 2009 at 1:14 PM, Robert Kern wrote: > On Fri, Dec 11, 2009 at 14:41, Keith Goodman wrote: >> On Fri, Dec 11, 2009 at 12:08 PM, Bruce Southey wrote: > >>> So I agree that it should leave the input untouched when a non-float >>> dtype is used for some array-like input. >> >> Would

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Robert Kern
On Fri, Dec 11, 2009 at 14:41, Keith Goodman wrote: > On Fri, Dec 11, 2009 at 12:08 PM, Bruce Southey wrote: >> So I agree that it should leave the input untouched when a non-float >> dtype is used for some array-like input. > > Would only one line need to be changed? Would changing > > if not i

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Keith Goodman
On Fri, Dec 11, 2009 at 12:08 PM, Bruce Southey wrote: > On 12/11/2009 01:33 PM, Robert Kern wrote: >> On Fri, Dec 11, 2009 at 13:11, Bruce Southey  wrote: >> >> >>> As documented, nan_to_num returns a float so it does not return the >>> input unchanged. >>> > Sorry for my mistake: > Given an int

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Bruce Southey
On 12/11/2009 01:33 PM, Robert Kern wrote: > On Fri, Dec 11, 2009 at 13:11, Bruce Southey wrote: > > >> As documented, nan_to_num returns a float so it does not return the >> input unchanged. >> Sorry for my mistake: Given an int input, np.nan_to_num returns an int dtype >>> np.nan_to_n

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Robert Kern
On Fri, Dec 11, 2009 at 13:11, Bruce Southey wrote: > As documented, nan_to_num returns a float so it does not return the > input unchanged. I think that is describing the current behavior rather than documenting the intent of the function. Given the high level purpose of the function, to "[r]ep

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Bruce Southey
On 12/11/2009 10:21 AM, Keith Goodman wrote: > On Fri, Dec 11, 2009 at 12:50 AM, Nicolas Rougier > wrote: > >> Hello, >> >> Using both numpy 1.3.0 and 1.4.0rc1 I got the following exception using >> nan_to_num on a bool array, is that the expected behavior ? >> >> >> > import numpy

[Numpy-discussion] December Webinar: SciPy India with Travis Oliphant

2009-12-11 Thread Amenity Applewhite
Next Friday Enthought will be hosting our monthly Scientific Computing with Python Webinar: Summary of SciPy India Friday December 18 1pm CST/ 7pm UTC Register at GoToMeeting Enthought President Travis Oliphant is currently in Kerala, India as the keynote speaker at SciPy India 2009. Due to a

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Francesc Alted
A Friday 11 December 2009 17:36:54 Bruce Southey escrigué: > On 12/11/2009 10:03 AM, Francesc Alted wrote: > > A Friday 11 December 2009 16:44:29 Dag Sverre Seljebotn escrigué: > >> Jasper van de Gronde wrote: > >>> Dag Sverre Seljebotn wrote: > Jasper van de Gronde wrote: > > I've attache

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Nicolas Rougier
I've created a ticket (#1327). Nicolas On Dec 11, 2009, at 17:21 , Keith Goodman wrote: > On Fri, Dec 11, 2009 at 12:50 AM, Nicolas Rougier > wrote: >> >> Hello, >> >> Using both numpy 1.3.0 and 1.4.0rc1 I got the following exception using >> nan_to_num on a bool array, is that the expected

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Bruce Southey
On 12/11/2009 10:03 AM, Francesc Alted wrote: > A Friday 11 December 2009 16:44:29 Dag Sverre Seljebotn escrigué: > >> Jasper van de Gronde wrote: >> >>> Dag Sverre Seljebotn wrote: >>> Jasper van de Gronde wrote: > I've attached a test file which shows the

Re: [Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Keith Goodman
On Fri, Dec 11, 2009 at 12:50 AM, Nicolas Rougier wrote: > > Hello, > > Using both numpy 1.3.0 and 1.4.0rc1 I got the following exception using > nan_to_num on a bool array, is that the expected behavior ? > > import numpy Z = numpy.zeros((3,3),dtype=bool) numpy.nan_to_num(Z) > Trac

Re: [Numpy-discussion] [Nipy-devel] Impossibility to build nipy on recent numpy?

2009-12-11 Thread Gael Varoquaux
On Thu, Dec 10, 2009 at 05:19:24PM +0100, Gael Varoquaux wrote: > On Thu, Dec 10, 2009 at 10:17:43AM -0600, Robert Kern wrote: > > > OK, so we need to bug report to ubuntu. Anybody feels like doing it, or > > > do I need to go ahead :). > > It's your problem. :-) > That's kinda what I thought. I

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Francesc Alted
A Friday 11 December 2009 16:44:29 Dag Sverre Seljebotn escrigué: > Jasper van de Gronde wrote: > > Dag Sverre Seljebotn wrote: > >> Jasper van de Gronde wrote: > >>> I've attached a test file which shows the problem. It also tries adding > >>> columns instead of rows (in case the memory layout is

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Dag Sverre Seljebotn
Jasper van de Gronde wrote: > Dag Sverre Seljebotn wrote: > >> Jasper van de Gronde wrote: >> >>> I've attached a test file which shows the problem. It also tries adding >>> columns instead of rows (in case the memory layout is playing tricks), >>> but this seems to make no difference. This

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Jasper van de Gronde
Dag Sverre Seljebotn wrote: > Jasper van de Gronde wrote: >> I've attached a test file which shows the problem. It also tries adding >> columns instead of rows (in case the memory layout is playing tricks), >> but this seems to make no difference. This is the output I got: >> >> Dot product: 5.

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Dag Sverre Seljebotn
Jasper van de Gronde wrote: > (Resending without attachment as I don't think my previous message arrived.) > > I just started using numpy and am very, very pleased with the > functionality and cleanness so far. However, I tried what I though would > be a simple optimization and found that the oppos

[Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Jasper van de Gronde
(Resending without attachment as I don't think my previous message arrived.) I just started using numpy and am very, very pleased with the functionality and cleanness so far. However, I tried what I though would be a simple optimization and found that the opposite was true. Specifically, I had a l

[Numpy-discussion] nan_to_num and bool arrays

2009-12-11 Thread Nicolas Rougier
Hello, Using both numpy 1.3.0 and 1.4.0rc1 I got the following exception using nan_to_num on a bool array, is that the expected behavior ? >>> import numpy >>> Z = numpy.zeros((3,3),dtype=bool) >>> numpy.nan_to_num(Z) Traceback (most recent call last): File "", line 1, in File "/usr/lib/py