[Numpy-discussion] How to preserve number of array dimensions when taking a slice?

2009-08-07 Thread Dr. Phillip M. Feldman
I'd like to be able to make a slice of a 3-dimensional array, doing something like the following: Y= X[A, B, C] where A, B, and C are lists of indices. This works, but has an unexpected side-effect. When A, B, or C is a length-1 list, Y has fewer dimensions than X. Is there a way to do the slice

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread josef . pktd
On Fri, Aug 7, 2009 at 10:17 PM, wrote: > Thanks! That helps a lot. Thanks for improving the docs. > >>On Fri, Aug 7, 2009 at 8:54 PM, wrote: >>> On Fri, Aug 7, 2009 at 6:57 PM, wrote: On Fri, Aug 7, 2009 at 6:13 PM, wrote: > On Fri, Aug 7, 2009 at 5:42 PM, wrote: >> On Fri, Aug

[Numpy-discussion] Merging datetime, Yes or No

2009-08-07 Thread Charles R Harris
I ask again, Datetime is getting really stale and hasn't been touched recently. Do the datetime folks want it merged or not, because it's getting to be a bit of work. Chuck ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.o

[Numpy-discussion] numpy.random.pareto, m equal zero

2009-08-07 Thread josef . pktd
Does it make any (statistical) sense to have numpy.random.pareto produce random numbers that start at zero? Can we change it to start at 1 which is the usual default? Notation from http://docs.scipy.org/numpy/docs/numpy.random.mtrand.RandomState.pareto/ The probability density for the Par

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread alan
Thanks! That helps a lot. >On Fri, Aug 7, 2009 at 8:54 PM, wrote: >> On Fri, Aug 7, 2009 at 6:57 PM, wrote: >>> On Fri, Aug 7, 2009 at 6:13 PM, wrote: On Fri, Aug 7, 2009 at 5:42 PM, wrote: > On Fri, Aug 7, 2009 at 5:25 PM, Andrew Hawryluk > wrote: >> Hmm ... good point.

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread josef . pktd
On Fri, Aug 7, 2009 at 8:54 PM, wrote: > On Fri, Aug 7, 2009 at 6:57 PM, wrote: >> On Fri, Aug 7, 2009 at 6:13 PM, wrote: >>> On Fri, Aug 7, 2009 at 5:42 PM, wrote: On Fri, Aug 7, 2009 at 5:25 PM, Andrew Hawryluk wrote: > Hmm ... good point. > It appears to give a probability

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread josef . pktd
On Fri, Aug 7, 2009 at 6:57 PM, wrote: > On Fri, Aug 7, 2009 at 6:13 PM, wrote: >> On Fri, Aug 7, 2009 at 5:42 PM, wrote: >>> On Fri, Aug 7, 2009 at 5:25 PM, Andrew Hawryluk wrote: Hmm ... good point. It appears to give a probability distribution proportional to x**(a-1), but I se

Re: [Numpy-discussion] Optimized half-sizing of images?

2009-08-07 Thread Christopher Barker
To finish off the thread for posterity: Robert Bradshaw wrote: Robert's version operated on a 2-d array, so only one band at a time if you have RGB. So I edited it a bit: import cython import numpy as np cimport numpy as np @cython.boundscheck(False) def halfsize(np.ndarray[np.uint8_t, ndim=3

[Numpy-discussion] concatenate and non-contiguous arrays?

2009-08-07 Thread Christopher Barker
Hi all, I just noticed that np.concatenate does not necessarily produce contiguous arrays. I has figured that it was making a copy, so would produce a C-contiguous array, but not so: In [88]: a = np.arange(60).reshape((4,5,3)) In [89]: b = np.concatenate((a, a[:, -1:, :]), axis=1) In [90]: b

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread josef . pktd
On Fri, Aug 7, 2009 at 6:13 PM, wrote: > On Fri, Aug 7, 2009 at 5:42 PM, wrote: >> On Fri, Aug 7, 2009 at 5:25 PM, Andrew Hawryluk wrote: >>> Hmm ... good point. >>> It appears to give a probability distribution proportional to x**(a-1), >>> but I see no good reason why the domain should be limit

Re: [Numpy-discussion] dot documentation

2009-08-07 Thread Charles R Harris
On Fri, Aug 7, 2009 at 3:24 PM, T J wrote: > Oh. b.shape = (2,). So I suppose the second to last dimension is, in > fact, the last dimension...and 2 == 2. > > nvm > > On Fri, Aug 7, 2009 at 2:19 PM, T J wrote: > > Hi, the documentation for dot says that a value error is raised if: > > > >I

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread josef . pktd
On Fri, Aug 7, 2009 at 5:42 PM, wrote: > On Fri, Aug 7, 2009 at 5:25 PM, Andrew Hawryluk wrote: >> Hmm ... good point. >> It appears to give a probability distribution proportional to x**(a-1), >> but I see no good reason why the domain should be limited to [0,1]. >> >> def test(a): >>    nums = >

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread josef . pktd
On Fri, Aug 7, 2009 at 5:25 PM, Andrew Hawryluk wrote: > Hmm ... good point. > It appears to give a probability distribution proportional to x**(a-1), > but I see no good reason why the domain should be limited to [0,1]. > > def test(a): >    nums = > plt.hist(np.random.power(a,10),bins=100,ec=

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread Andrew Hawryluk
Hmm ... good point. It appears to give a probability distribution proportional to x**(a-1), but I see no good reason why the domain should be limited to [0,1]. def test(a): nums = plt.hist(np.random.power(a,10),bins=100,ec='none',fc='#dd') x = np.linspace(0,1,200) plt.plot(x,nu

Re: [Numpy-discussion] dot documentation

2009-08-07 Thread T J
Oh. b.shape = (2,). So I suppose the second to last dimension is, in fact, the last dimension...and 2 == 2. nvm On Fri, Aug 7, 2009 at 2:19 PM, T J wrote: > Hi,  the documentation for dot says that a value error is raised if: > >    If the last dimension of a is not the same size as the > secon

[Numpy-discussion] dot documentation

2009-08-07 Thread T J
Hi, the documentation for dot says that a value error is raised if: If the last dimension of a is not the same size as the second-to-last dimension of b. (http://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.htm) This doesn't appear to be the case: >>> a = array([[1,2],[3,4]]) >>>

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread alan
I don't think that is it, since the one in numpy has a range restricted to the interval 0-1. Try out hist(np.random.power(5, 100), bins=100) >You might get better results for 'power-law distribution' >http://en.wikipedia.org/wiki/Power_law > >Andrew > >> -Original Message- >> From: nu

Re: [Numpy-discussion] Vectorize ufunc

2009-08-07 Thread Travis Oliphant
The short answer is that it was easier this way. The ufunc is created on the fly and it needs to know several things that are easy to get once the function is called. Sent from my iPhone On Aug 7, 2009, at 11:42 AM, T J wrote: > I was wondering why vectorize doesn't make the ufunc available

[Numpy-discussion] reduce function of vectorize doesn't respect dtype?

2009-08-07 Thread T J
The reduce function of ufunc of a vectorized function doesn't seem to respect the dtype. >>> def a(x,y): return x+y >>> b = vectorize(a) >>> c = array([1,2]) >>> b(c, c) # use once to populate b.ufunc >>> d = b.ufunc.reduce(c) >>> c.dtype, type(d) dtype('int32'), >>> c = array([[1,2,3],[4,5,6]]

[Numpy-discussion] memmap capability

2009-08-07 Thread Tom Kuiper
If this appears twice, forgive me. I sent it previously (7:13 am PDT) via a browser interface to JPL's Office Outlook. I have doubts about this system. This time, from Iceweasel through our SMTP server. There are two things I'd like to do using memmap. I suspect that they are impossible bu

Re: [Numpy-discussion] Power distribution

2009-08-07 Thread Andrew Hawryluk
You might get better results for 'power-law distribution' http://en.wikipedia.org/wiki/Power_law Andrew > -Original Message- > From: numpy-discussion-boun...@scipy.org [mailto:numpy-discussion- > boun...@scipy.org] On Behalf Of a...@ajackson.org > Sent: 7 Aug 2009 11:45 AM > To: Discussio

[Numpy-discussion] Power distribution

2009-08-07 Thread alan
Documenting my way through the statistics modules in numpy, I ran into the Power Distribution. Anyone know what that is? I Googled for it, and found a lot of stuff on electricity, but no reference for a statistical distribution of that name. Does it have a common alias? -- --

[Numpy-discussion] Vectorize ufunc

2009-08-07 Thread T J
I was wondering why vectorize doesn't make the ufunc available at the topmost level >>> def a(x,y): return x + y >>> b = vectorize(a) >>> b.reduce Instead, the ufunc is stored at b.ufunc. Also, b.ufunc.reduce() doesn't seem to exist until I *use* the vectorized function at least once. Can

Re: [Numpy-discussion] Optimized half-sizing of images?

2009-08-07 Thread Christopher Barker
Zachary Pincus wrote: >> We have a need to to generate half-size version of RGB images as >> quickly >> as possible. > > How good do these need to look? You could just throw away every other > pixel... image[::2, ::2]. I do the as good quality as I can get. throwing away pixels gets a bit ugl

Re: [Numpy-discussion] Test failures for rev7299

2009-08-07 Thread David Cournapeau
On Fri, Aug 7, 2009 at 11:51 PM, David Cournapeau wrote: > Christopher Hanley wrote: >> Hi, >> >> I receive the following test errors after building numpy rev7229 from svn: >> > > Yep, a bug slipped in the last commit, I am fixing it right now, Hm, the fix does not look so obvious, so I just rever

Re: [Numpy-discussion] Test failures for rev7299

2009-08-07 Thread David Cournapeau
Christopher Hanley wrote: > Hi, > > I receive the following test errors after building numpy rev7229 from svn: > Yep, a bug slipped in the last commit, I am fixing it right now, David ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http:

[Numpy-discussion] Test failures for rev7299

2009-08-07 Thread Christopher Hanley
Hi, I receive the following test errors after building numpy rev7229 from svn: == FAIL: test_simple_circular (test_multiarray.TestStackedNeighborhoodIter) -- Tra

Re: [Numpy-discussion] Strange Error with NumPy Addendum

2009-08-07 Thread Nanime Puloski
But if it were an unsigned int64, it should be able to hold 2**64 or at least 2**64-1. Am I correct? On Fri, Aug 7, 2009 at 1:03 AM, David Warde-Farley wrote: > On 6-Aug-09, at 7:29 PM, Robert Kern wrote: > > > For that value, yes, but not for long objects in general. We don't > > look at the val

Re: [Numpy-discussion] Fwd: GPU Numpy

2009-08-07 Thread Romain Brette
Sturla Molden a écrit : > Thus, here is my plan: > > 1. a special context-manager class > 2. immutable arrays inside with statement > 3. lazy evaluation: expressions build up a parse tree > 4. dynamic code generation > 5. evaluation on exit > There seems to be some similarity with what we want t

Re: [Numpy-discussion] Optimized half-sizing of images?

2009-08-07 Thread Robert Bradshaw
On Aug 7, 2009, at 12:23 AM, Sebastian Haase wrote: > On Fri, Aug 7, 2009 at 3:46 AM, Zachary > Pincus wrote: >>> We have a need to to generate half-size version of RGB images as >>> quickly >>> as possible. >> >> How good do these need to look? You could just throw away every other >> pixel...

Re: [Numpy-discussion] Optimized half-sizing of images?

2009-08-07 Thread Sebastian Haase
On Fri, Aug 7, 2009 at 3:46 AM, Zachary Pincus wrote: >> We have a need to to generate half-size version of RGB images as >> quickly >> as possible. > > How good do these need to look? You could just throw away every other > pixel... image[::2, ::2]. > > Failing that, you could also try using ndima