Re: [Numpy-discussion] Reordering indices

2014-05-30 Thread Bob Dowling
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.transpose.html And I completely missed its general case. D'oh! Thank you. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-disc

[Numpy-discussion] Reordering indices

2014-05-30 Thread Bob Dowling
Is there a clean way to create a view on an existing ND-array with its axes in a different order. For example, suppose I have an array of shape (100,200,300,3) and I want to create a view of this where the vector coordinate is axis 0, not axis 3. (So the view will have shape (3,100,200,300).)

Re: [Numpy-discussion] Confused by spec of numpy.linalg.solve

2014-04-01 Thread Bob Dowling
On 04/01/2014 04:25 PM, Nathaniel Smith wrote: > On Tue, Apr 1, 2014 at 3:57 PM, Sebastian Berg > wrote: >> If `a` has exactly one dimension more then `b`, the first case is used. >> Otherwise (..., M, K) is used instead. To make sure you always get the >> expected result, it may be best to make s

[Numpy-discussion] Confused by spec of numpy.linalg.solve

2014-04-01 Thread Bob Dowling
Versions: >>> sys.version '3.3.2 (default, Mar 5 2014, 08:21:05) \n[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)]' >>> numpy.__version__ '1.8.0' Problem: I'm trying to unpick the shape requirements of numpy.linalg.solve(). The help text says: solve(a, b) - a : (..., M, M) array_like C

Re: [Numpy-discussion] Unexpected RuntimeWarning

2012-11-23 Thread Bob Dowling
> You may want to use this: > http://docs.scipy.org/doc/numpy/reference/generated/numpy.piecewise.html Thank you. That's just what I needed. Works a treat: --- start --- import numpy def chebyshev(x, m): '''Calculates Chebyshev functions of the first kind using the trigonometric identi

[Numpy-discussion] Unexpected RuntimeWarning

2012-11-23 Thread Bob Dowling
I have a simple function defined in the following snippet: --- start --- import numpy def chebyshev(x, m): '''Calculates Chebyshev functions of the first kind using the trigonometric identities.''' theta = numpy.where( numpy.abs(x)<=1.0, numpy.arccos(x), n

Re: [Numpy-discussion] possible enhancement to getitem?

2012-06-08 Thread Bob Dowling
On 08/06/12 14:14, Neal Becker wrote: > The fact that this proposed numpy behavior would not match python list > behavior > holds little weight for me. I would still favor this change, unless it added > significant overhead. My opinion, of course. It holds enormous weight for me. My opinion i

Re: [Numpy-discussion] Matrices and arrays of vectors

2012-02-24 Thread Bob Dowling
numpy.dot and numpy.tensordot do exactly what I need. Thank you all (and especially the gentleman who spotted I was rotating in the wrong direction). ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/nu

[Numpy-discussion] Matrices and arrays of vectors

2012-02-24 Thread Bob Dowling
Conceptually, I have a 2-d grid of 2-d vectors. I am representing this as an ndarray of shape (2,M,N). I want to apply a 2x2 matrix individually to each vector in the grid. However, I can't work out the appropriate syntax for getting the matrix multiplication to broadcast over the grid. All

Re: [Numpy-discussion] Lookup array

2011-10-10 Thread Bob Dowling
B[i] in A. In the (very rare) case when B[i] is not > in A C[i] should be equal to -1. May we assume that there are no repeats in A? (i.e. no cases where two different indices are both valid?) -- Bob Dowling ___ NumPy-Discussion mailing list NumPy-

Re: [Numpy-discussion] summing an array

2011-08-19 Thread Bob Dowling
On 19/08/11 15:49, Chris Withers wrote: > On 18/08/2011 07:58, Bob Dowling wrote: >> >> >>> numpy.add.accumulate(a) >> array([ 0, 1, 3, 6, 10]) >> >> >>> numpy.add.accumulate(a, out=a) >> array([ 0, 1, 3, 6, 10]) > > What's th

Re: [Numpy-discussion] summing an array

2011-08-18 Thread Bob Dowling
On 18/08/11 15:19, Chris Withers wrote: > Hopefully a simple newbie question, if I have an array such as : > > array([0, 1, 2, 3, 4]) > > ...what's the best way to cummulatively sum it so that I end up with: > > array([0, 1, 3, 6, 10]) > > How would I do this both in-place and to create a new arr

Re: [Numpy-discussion] ndarray methods vs numpy module functions

2008-06-24 Thread Bob Dowling
> There is not supposed to be a one-to-one correspondence between the > functions in numpy and the methods on an ndarray. There is some > duplication between the two, but that is not a reason to make more > duplication. I would make a plea for consistency, to start with. Those of us who write in

[Numpy-discussion] ndarray methods vs numpy module functions

2008-06-23 Thread Bob Dowling
[ I'm new here and this has the feel of an FAQ but I couldn't find anything at http://www.scipy.org/FAQ . If I should have looked somewhere else a URL would be gratefully received. ] What's the reasoning behind functions like sum() and cumsum() being provided both as module functions (numpy.s