[Numpy-discussion] Loading bit strings

2010-03-05 Thread Dan Lenski
Is there a good way in NumPy to convert from a bit string to a boolean array? For example, if I have a 2-byte string s='\xfd\x32', I want to get a 16-length boolean array out of it. Here's what I came up with: A = fromstring(s, dtype=uint8) out = empty(A.size * 8, dtype=bool) for bit in

Re: [Numpy-discussion] using reducing functions without eliminating dimensions?

2009-04-10 Thread Dan Lenski
On Thu, 09 Apr 2009 01:31:33 -0500, Robert Kern wrote: On Thu, Apr 9, 2009 at 01:29, Anne Archibald peridot.face...@gmail.com wrote: What's wrong with np.amin(a,axis=-1)[...,np.newaxis]? It's cumbersome, particularly when you have axis=arbitrary_axis. Quite right. It would nice to be

[Numpy-discussion] using reducing functions without eliminating dimensions?

2009-04-07 Thread Dan Lenski
Hi all, I often want to use some kind of dimension-reducing function (like min(), max(), sum(), mean()) on an array without actually removing the last dimension, so that I can then do operations broadcasting the reduced array back to the size of the full array. Full example: table.shape

Re: [Numpy-discussion] argsort in descending order

2008-09-06 Thread Dan Lenski
On Fri, 05 Sep 2008 07:02:38 -0700, SimonPalmer wrote: another newb question I suspect, but is there a way to instruct argsort to sort in descending order or should I just sort and reverse? Just sort and subtract to get the reverse order. I can think of two reasonable ways to do it with no

Re: [Numpy-discussion] doing zillions of 3x3 determinants fast

2008-08-25 Thread Dan Lenski
On Sun, 24 Aug 2008 23:49:45 -0600, Charles R Harris wrote: On Sun, Aug 24, 2008 at 9:48 PM, Daniel Lenski [EMAIL PROTECTED] wrote: Hi all, I need to take the determinants of a large number of 3x3 matrices, in order to determine for each of N points, in which of M tetrahedral cells they

[Numpy-discussion] weights parameter of np.average() doesn't work (BUG?)

2008-08-24 Thread Dan Lenski
Hi all, Is there a good reason why the weights parameter of np.average() doesn't broadcast properly? This is with the Ubuntu Hardy x86_64 numpy package, version 1.0.4. In [293]: a=arange(100).reshape(10,10) # Things work fine when weights have the exact same shape as a In [297]: average(a,

Re: [Numpy-discussion] reading *big* inhomogenous text matrices *fast*?

2008-08-14 Thread Dan Lenski
On Thu, 14 Aug 2008 04:40:16 +, Daniel Lenski wrote: I assume that list-of-arrays is more memory-efficient since array elements don't have the overhead of full-blown Python objects. But list- of-lists is probably more time-efficient since I think it's faster to convert the whole array at

[Numpy-discussion] reading *big* inhomogenous text matrices *fast*?

2008-08-13 Thread Dan Lenski
Hi all, I'm using NumPy to read and process data from ASCII UCD files. This is a file format for describing unstructured finite-element meshes. Most of the file consists of rectangular, numerical text matrices, easily and efficiently read with loadtxt(). But there is one particularly nasty