[Numpy-discussion] convert integer into bit array

Pearu Peterson pearu.peterson at gmail.com
Mon May 16 15:01:51 EDT 2011


Hi,

I have used bitarray for that

  http://pypi.python.org/pypi/bitarray/

Here


http://code.google.com/p/pylibtiff/source/browse/#svn%2Ftrunk%2Flibtiff%2Fbitarray-0.3.5-numpy

you can find bitarray with numpy support.

HTH,
Pearu

On Mon, May 16, 2011 at 9:55 PM, Nikolas Tautenhahn <virtual at gmx.de> wrote:

> Hi,
>
> for some research, I need to convert lots of integers into their bit
> representation - but as a bit array, not a string like
> numpy.binary_repr() returns it.
>
> So instead of
> In [22]: numpy.binary_repr(23)
> Out[22]: '10111
>
>
> I'd need:
> numpy.binary_magic(23)
> Out: array([ True, False,  True,  True,  True], dtype=bool)
>
> is there any way to do this efficiently?
>
> best regards,
> Nik
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110516/58067e80/attachment.html>


More information about the NumPy-Discussion mailing list