Hi everyone, I need to use a bitwise array, and I wanted to check what is the common practice using numpy. I expect to read binary strings (like '0011000001') of equal length from file and to save and manipulate them using numpy. I know that numpy have good implementations of bitwise operations, but I was wondering how to encode the data in the first place. As a Python long? As an int ndarray? Which int type? How to save and load such data in such a way that when I load it the information that it is a bit array is stored? Any help would be appreciated. Regards, Muhammad Alkarouri
Hi Muhammad
2009/1/21 Muhammad Alkarouri
I need to use a bitwise array, and I wanted to check what is the common practice using numpy.
You can also take a look at Ilan Schnell's bitarray: http://pypi.python.org/pypi/bitarray/ Cheers Stéfan
--- On Wed, 21/1/09, Stéfan van der Walt
From: Stéfan van der Walt
... You can also take a look at Ilan Schnell's bitarray:
Looks good to me. Thanks for the suggestion. Muhammad
Muhammad Alkarouri wrote:
--- On Wed, 21/1/09, Stéfan van der Walt
wrote: From: Stéfan van der Walt
...
You can also take a look at Ilan Schnell's bitarray:
Looks good to me. Thanks for the suggestion.
You might also make use of the NumPy functions: packbits unpackbits fromfile Read the bits in as uint8 data using fromfile. Then, you can manipulate them either using bit twiddling or with indexing operations after unpacking to boolean arrays. -Travis
participants (3)
-
Muhammad Alkarouri
-
Stéfan van der Walt
-
Travis E. Oliphant