<br><br><div class="gmail_quote">On Tue, May 17, 2011 at 12:04 AM, Nikolas Tautenhahn <span dir="ltr"><<a href="mailto:virtual@gmx.de">virtual@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<div class="im"><br>
> Here<br>
><br>
> <a href="http://code.google.com/p/pylibtiff/source/browse/#svn%2Ftrunk%2Flibtiff%2Fbitarray-0.3.5-numpy" target="_blank">http://code.google.com/p/pylibtiff/source/browse/#svn%2Ftrunk%2Flibtiff%2Fbitarray-0.3.5-numpy</a><br>

><br>
> you can find bitarray with numpy support.<br>
><br>
<br>
</div>Thanks, that looks promising - to get a numpy array, I need to do<br>
<br>
numpy.array(bitarray.bitarray(numpy.binary_repr(i, l)))<br>
<br>
for an integer i and l with i < 2**l, right?<br>
<div><div class="h5"><br></div></div></blockquote><div><br>If l < 64 and little endian is assumed then you can use the<br><br>  fromword(i, l)<br><br>method:<br><br>>>> from libtiff import bitarray<br>>>> barr = bitarray.bitarray(0, 'little')<br>
>>> barr.fromword(3,4)<br>>>> barr<br>    bitarray('1100')<br> <br>that will append 4 bits of the value 3 to the bitarray barr.<br><br>Also check out various bitarray `to*` and `from*` methods.<br>
<br>HTH,<br>Pearu<br></div></div>