[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] Loading bit strings

2010-03-05 Thread Robert Kern
On Fri, Mar 5, 2010 at 11:11, Dan Lenski dlen...@gmail.com wrote: 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 =

Re: [Numpy-discussion] Loading bit strings

2010-03-05 Thread Zachary Pincus
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. numpy.unpackbits(numpy.fromstring('\xfd\x32', dtype=numpy.uint8))