def bitarray_to_bool(data, length):
 results = []
 for byte in data:
  if six.PY2:
   byte = ord(byte)
  for bit_no in range(7, (-1), (-1)):
   bit = (byte & (1 << bit_no))
   bit = (bit != 0)
   results.append(bit)
   if (len(results) == length):
    break
  if (len(results) == length):
   break
 return np.array(results, dtype=u'b1')

def bitarray_to_bool ( data , length ) : results = [ ] for byte in data : if six . PY2 : byte = ord ( byte ) for bit_no in range ( 7 , ( - 1 ) , ( - 1 ) ) : bit = ( byte & ( 1 << bit_no ) ) bit = ( bit != 0 ) results . append ( bit ) if ( len ( results ) == length ) : break if ( len ( results ) == length ) : break return np . array ( results , dtype = u'b1' )
converts a bit array to a boolean numpy array .