def measure_partial_oneshot(qubit, bits, format='sympy'):
 import random
 m = qubit_to_matrix(qubit, format)
 if (format == 'sympy'):
  m = m.normalized()
  possible_outcomes = _get_possible_outcomes(m, bits)
  random_number = random.random()
  total_prob = 0
  for outcome in possible_outcomes:
   total_prob += (outcome.H * outcome)[0]
   if (total_prob >= random_number):
    return matrix_to_qubit(outcome.normalized())
 else:
  raise NotImplementedError("This function can't handle non-sympy matrix formats yet")

def measure_partial_oneshot ( qubit , bits , format = 'sympy' ) : import random m = qubit_to_matrix ( qubit , format ) if ( format == 'sympy' ) : m = m . normalized ( ) possible_outcomes = _get_possible_outcomes ( m , bits ) random_number = random . random ( ) total_prob = 0 for outcome in possible_outcomes : total_prob += ( outcome . H * outcome ) [ 0 ] if ( total_prob >= random_number ) : return matrix_to_qubit ( outcome . normalized ( ) ) else : raise NotImplementedError ( "This function can't handle non-sympy matrix formats yet" )
perform a partial oneshot measurement on the specified qubits .