def measure_all_oneshot(qubit, format='sympy'):
 import random
 m = qubit_to_matrix(qubit)
 if (format == 'sympy'):
  m = m.normalized()
  random_number = random.random()
  total = 0
  result = 0
  for i in m:
   total += (i * i.conjugate())
   if (total > random_number):
    break
   result += 1
  return Qubit(IntQubit(result, int((math.log(max(m.shape), 2) + 0.1))))
 else:
  raise NotImplementedError("This function can't handle non-sympy matrix formats yet")

def measure_all_oneshot ( qubit , format = 'sympy' ) : import random m = qubit_to_matrix ( qubit ) if ( format == 'sympy' ) : m = m . normalized ( ) random_number = random . random ( ) total = 0 result = 0 for i in m : total += ( i * i . conjugate ( ) ) if ( total > random_number ) : break result += 1 return Qubit ( IntQubit ( result , int ( ( math . log ( max ( m . shape ) , 2 ) + 0.1 ) ) ) ) else : raise NotImplementedError ( "This function can't handle non-sympy matrix formats yet" )
perform a oneshot ensemble measurement on all qubits .