[Numpy-discussion] int to binary

2013-04-29 Thread josef . pktd
Is there a available function to convert an int to binary representation as sequence of 0 and 1? binary_repr produces strings and is not vectorized np.binary_repr(5) '101' np.binary_repr(5, width=4) '0101' np.binary_repr(np.arange(5), width=4) Traceback (most recent call last): File

Re: [Numpy-discussion] int to binary

2013-04-29 Thread Sebastian Berg
On Mon, 2013-04-29 at 11:15 -0400, josef.p...@gmail.com wrote: Is there a available function to convert an int to binary representation as sequence of 0 and 1? Maybe unpackbits/packbits? It only supports the uint8 type, but you can view anything as that (being aware of endianess where

Re: [Numpy-discussion] int to binary

2013-04-29 Thread josef . pktd
On Mon, Apr 29, 2013 at 11:25 AM, Sebastian Berg sebast...@sipsolutions.net wrote: On Mon, 2013-04-29 at 11:15 -0400, josef.p...@gmail.com wrote: Is there a available function to convert an int to binary representation as sequence of 0 and 1? Maybe unpackbits/packbits? It only supports the

Re: [Numpy-discussion] int to binary

2013-04-29 Thread Warren Weckesser
On 4/29/13, josef.p...@gmail.com josef.p...@gmail.com wrote: Is there a available function to convert an int to binary representation as sequence of 0 and 1? binary_repr produces strings and is not vectorized np.binary_repr(5) '101' np.binary_repr(5, width=4) '0101'

Re: [Numpy-discussion] int to binary

2013-04-29 Thread josef . pktd
On Mon, Apr 29, 2013 at 12:24 PM, Warren Weckesser warren.weckes...@gmail.com wrote: On 4/29/13, josef.p...@gmail.com josef.p...@gmail.com wrote: Is there a available function to convert an int to binary representation as sequence of 0 and 1? binary_repr produces strings and is not

Re: [Numpy-discussion] int to binary

2013-04-29 Thread Daniele Nicolodi
On 29/04/2013 17:15, josef.p...@gmail.com wrote: Is there a available function to convert an int to binary representation as sequence of 0 and 1? ... That's the best I could come up with in a few minutes: ... def int2bin(x, width, roll=True): x = np.atleast_1d(x) res =