Maybe something like this?
>>> to_num = lambda array: np.sum(array * 2**np.arange(len(array)-1, -1,
-1))
>>> to_num(np.array([1,0,1,0]))
10
2014-04-29 17:42 GMT+02:00 Tom P :
> On 28.04.2014 15:04, mboyd02...@gmail.com wrote:
>
>> I have a numpy array consisting of 1s and zeros for representin
On 28.04.2014 15:04, mboyd02...@gmail.com wrote:
I have a numpy array consisting of 1s and zeros for representing binary numbers:
e.g.
>>> binary
array([ 1., 0., 1., 0.])
I wish the array to be in the form 1010, so it can be manipulated.
I do not want to use built in binary con
On Mon, 28 Apr 2014 06:04:02 -0700, mboyd02255 wrote:
> I have a numpy array consisting of 1s and zeros for representing binary
> numbers:
>
> e.g.
>
> >>> binary
> array([ 1., 0., 1., 0.])
>
> I wish the array to be in the form 1010, so it can be manipulated.
>
> I do not want to