Exemplo n.º 1
0
def test_setgetbit():

    # bit-wise copy
    arr = numpy.array(range(256), dtype=numpy.float64)
    arr2 = numpy.zeros(arr.shape, dtype=arr.dtype)
    for i in range(arr.nbytes * 8):
        b = bittools.getbit(arr, i)
        bittools.setbit(arr2, i, b)
    assert (arr == arr2).all(), ` arr, arr2 `

    print 'ok'
Exemplo n.º 2
0
def test_setgetbit():

    # bit-wise copy
    arr = numpy.array(list(range(256)), dtype=numpy.float64)
    arr2 = numpy.zeros(arr.shape, dtype=arr.dtype)
    for i in range(arr.nbytes * 8):
        b = bittools.getbit(arr, i)
        bittools.setbit(arr2, i, b)
    assert (arr==arr2).all(),repr((arr,arr2))

    print('ok')
Exemplo n.º 3
0
def tobinary(arr):
    return ''.join(
        [str(bittools.getbit(arr, i)) for i in range(arr.nbytes * 8)])
Exemplo n.º 4
0
def tobinary(arr):
    return ''.join([str(bittools.getbit (arr,i)) for i in range (arr.nbytes*8)])