[Numpy-discussion] Array min from argmin along an axis?

2011-12-13 Thread Ken Basye
Hi folks, I need an efficient way to get both the min and argmin of a 2-d array along one axis. It seemed to me that the way to do this was to get the argmin and then use it to index into the array to get the min, but I can't figure out how to do it. Here's my toy example: >>> x = np.ar

[Numpy-discussion] Object array from list in 1.6.0 (vs. 1.5.1)

2011-06-10 Thread Ken Basye
Dear folks, I have some code that stopped working with 1.6.0 and I'm wondering if there's a better way to replace it than what I came up with. Here's a condensed version: x = [()] # list containing an empty tuple; this isn't the only case, but it's one that must be handled correctly y = np

Re: [Numpy-discussion] NumPy-Discussion Digest, Vol 55, Issue 42

2011-04-17 Thread Ken Basye
I think this does what you want: def dim_weight(x): weights = x[0] volumes = x[1]*x[2]*x[3] return np.where(volumes>5184, volumes / 194.0, weights) Best, Ken On 4/17/11 1:00 PM, Laszlo Nagy wrote: > Message: 1 > Date: Sat, 16 Apr 2011 21:08:55 +0200 > From: Laszlo Nagy > Su

Re: [Numpy-discussion] printoption to allow hexified floats?

2010-12-02 Thread Ken Basye
Ken On 12/2/10 8:14 AM, Robert Kern wrote: > On Wed, Dec 1, 2010 at 13:18, Ken Basye wrote: >> Hi Numpy folks, >> ? ? When working with floats, I prefer to have exact string >> representations in doctests and other reference-based testing; I find it >> helps a lot t

[Numpy-discussion] printoption to allow hexified floats?

2010-12-01 Thread Ken Basye
Hi Numpy folks, When working with floats, I prefer to have exact string representations in doctests and other reference-based testing; I find it helps a lot to avoid chasing cross-platform differences that are really about the string conversion rather than about numerical differences. Sin

Re: [Numpy-discussion] A proposed change to rollaxis(), behavior for negative 'start' values

2010-09-23 Thread Ken Basye
Anne says: This is a tricky one. The current behaviour of rollaxis is to remove the requested axis from the list of axes and then insert it before the axis specified. This is exactly how python's list insertion works: In [1]: a = range(10) In [3]: a.insert(-1,'a') In [4]

[Numpy-discussion] A proposed change to rollaxis() behavior for negative 'start' values

2010-09-21 Thread Ken Basye
that seems to fit what the function does better - 'rollaxis' suggests a behavior like the roll() function which affects other axes, which isn't what happens. Thanks for listening; I'm a big fan of Numpy. Best, Ken Basye ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] reverse cumsum?

2010-07-06 Thread Ken Basye
Hi, Is there a simple way to get a cumsum in reverse order? So far, the best I've come up with is to use fancy indexing twice to reverse things: >>> x = np.arange(10) >>> np.cumsum(x[np.arange(9, -1, -1)])[np.arange(9, -1, -1)] array([45, 45, 44, 42, 39, 35, 30, 24, 17, 9]) If it matters,

[Numpy-discussion] Is this a bug, and if so, who's?

2010-04-21 Thread Ken Basye
Folks, Apologies for asking here, but I ran across this problem yesterday and probably need to file a bug. The problem is I don't know if this is a Numpy bug, a Python bug, or both. Here's an illustration, platform information follows. TIA, Ken ##

Re: [Numpy-discussion] Do ufuncs returned by frompyfunc(), have the out arg?

2010-04-06 Thread Ken Basye
From: Anne Archibald On 6 April 2010 15:42, Ken Basye wrote: > Folks, > I hope this is a simple question. When I created a ufunc with > np.frompyfunc(), I got an error when I called the result with an 'out' > argument: In fact, ordinary ufuncs do not accept nam

[Numpy-discussion] Do ufuncs returned by frompyfunc() have the out arg?

2010-04-06 Thread Ken Basye
Folks, I hope this is a simple question. When I created a ufunc with np.frompyfunc(), I got an error when I called the result with an 'out' argument: >>> def foo(x): return x * x + 1 >>> ufoo = np.frompyfunc(foo, 1, 1) >>> arr = np.arange(9).reshape(3,3) >>> ufoo(arr, out=arr) Traceback (

Re: [Numpy-discussion] Extracting values from one array corresponding to argmax elements in another array

2010-04-06 Thread Ken Basye
From: Vincent Schut On 04/05/2010 06:06 PM, Keith Goodman wrote: On Mon, Apr 5, 2010 at 8:44 AM, Ken Basye wrote: Hi Folks, I have two arrays, A and B, with the same shape. I want to find the highest values in A along some axis, then extract the corresponding values from B. I can

[Numpy-discussion] Extracting values from one array corresponding to argmax elements in another array

2010-04-05 Thread Ken Basye
Hi Folks, I have two arrays, A and B, with the same shape. I want to find the highest values in A along some axis, then extract the corresponding values from B. I can get the highest values in A with A.max(axis=0) and the indices of these highest values with A.argmax(axis=0). I'm trying to

Re: [Numpy-discussion] hairy optimization problem

2009-05-07 Thread Ken Basye
Hi Mathew, Here are some things to think about: First, is there a way to decompose 'f' so that it computes only one or a subset of K values, but in 1/N ( K/N) time? If so, you can decompose your problem into N single optimizations. Presumably not, but I think it's worth asking. Second, what

Re: [Numpy-discussion] Numpy Trac site redirecting in a loop?

2009-05-06 Thread Ken Basye
I ran into something like this a couple weeks ago. I use Firefox 3 on MacOS. My work-around was to clear all the cookies from scipy.org, clear all authenticated sessions, then register a completely new account name. I never could get my existing account to stop looping. HTH, Ken Thoma

Re: [Numpy-discussion] Numpy Trac site redirecting in a loop?

2009-04-15 Thread Ken Basye
m, and/or does anyone know how I can fix my side > of things to get me to the site? I don't see this. Can you try emptying your browser's cache? -- Pauli Virtanen Wed, 15 Apr 2009 17:21:59 -0400, Ken Basye wrote: ___ Numpy-discussion ma

[Numpy-discussion] Numpy Trac site redirecting in a loop?

2009-04-15 Thread Ken Basye
Hi all, Just now when I tried to access http://projects.scipy.org/numpy, Firefox complains (after a bit) that there's a redirect loop. Is anyone else seeing this problem, and/or does anyone know how I can fix my side of things to get me to the site? Thanks, Ken

Re: [Numpy-discussion] Compute multiple outer products, without a loop?

2009-02-18 Thread Ken Basye
on of Numerical Python Message-ID: Content-Type: text/plain; charset="iso-8859-1" On Tue, Feb 17, 2009 at 8:30 AM, Ken Basye wrote: Hi, My current code looks like this: (k,d) = m.shape sq = np.zeros((k, d, d), dtype=float) for i in xrange(k):

Re: [Numpy-discussion] Compute multiple outer products without a loop?

2009-02-17 Thread Ken Basye
Hi, My current code looks like this: (k,d) = m.shape sq = np.zeros((k, d, d), dtype=float) for i in xrange(k): sq[i] = np.outer(m[i], m[i]) That is, m is treated as a sequence of k vectors of length d; the k dXd outer products are found and st

[Numpy-discussion] Compute multiple outer products without a loop?

2009-02-16 Thread Ken Basye
Hi List, I need to compute multiple outer products from 2-d data in the following way: Given a and b with shape, e.g, (10, 4), compute the 10 outer products of shape (4, 4) and get them into an array of shape (10, 4, 4). Currently I do this with a loop, but I'd really like some way to do it

[Numpy-discussion] Can I fill an existing array from an iterator?

2009-02-06 Thread Ken Basye
Hi Folks, I wonder if there's a way to fill an existing array from an iterator without creating a temporary array. That is, I'm looking for something that has the effect of >>> target = np.array(xrange(9), dtype = float) >>> target[:] = np.fromiter(repeat(3.14159, 9), dtype=float) withou

[Numpy-discussion] Array printing differences between 64- and 32-bit platforms

2008-10-15 Thread Ken Basye
about introducing a new print setting that forced dtypes to be printed always. Is there any support for that? Any other ideas would also be most welcome. Thanks, Ken Basye ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http

Re: [Numpy-discussion] Array printing and another question

2008-04-11 Thread Ken Basye
bits = (sign << 63) + (exponent << 52) + mantissa return _double.longBitsToDouble(bits) Hans Meine wrote: Am Dienstag, 08. April 2008 17:22:33 schrieb Ken Basye: I've had this happen often enough that I found the first thing I did when an output difference arose was to pr

Re: [Numpy-discussion] Array printing and another question

2008-04-08 Thread Ken Basye
Hi, Thanks, but it's been my experience that formatting FP numbers into decimal causes a lot of false alarms all by itself; that is, you get different decimal representations of the same FP memory value. I've had this happen often enough that I found the first thing I did when an output diffe

[Numpy-discussion] Array printing and another question

2008-04-08 Thread Ken Basye
re, but I now have at least one example of a difference. I should clarify that I'm not talking about processor-family dependency; all my machines are x86 at this point. Indeed, the differences appear across virtual machines running different OSs on the same physical machine. Thanks in