def test_bounded(self, n_qubits): tol = 1e-7 operator = rand_super_bcsz(2**n_qubits) assert -tol <= unitarity(operator) <= 1 + tol
ax = f.add_subplot(121) ax2 = f.add_subplot(122) ax2.axis('off') # ~~~~~~~~~~ Set the noise channel here ~~~~~~~~~~~ found_a_good_channel = False limit = 0.4 while found_a_good_channel == False: # two_qubit_noise = unitary_channel(4,0.9,0.01) # A unitary # two_qubit_noise = qt.to_super(qt.cnot()) # CNOT # two_qubit_noise = qt.rand_super_bcsz(4, dims=[[[2, 2], [2, 2]], [[2, 2], [2, 2]]], rank=2) # two_qubit_noise = qt.rand_super_bcsz(4, dims=[[[2, 2], [2, 2]], [[2, 2], [2, 2]]]) two_qubit_noise = qt.rand_super(4, dims=[[[2, 2], [2, 2]], [[2, 2], [2, 2]]]) # two_qubit_noise = qt.super_tensor(qt.rand_super(2),qt.rand_super(2)) if qt.unitarity(two_qubit_noise) > limit: found_a_good_channel = True ax2.text(0.1,0.30, 'Noise is mix of product and unitary: rand_super & rand_unitary') two_qubit_noise.dims = [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] # Prints information about the noise (this is helpful to see if the channel is suitable) print "Unitarity: ", qt.unitarity(two_qubit_noise) #Put those values on the plot ax2.text(0.0,0.9, 'Calculated information about the noise channel:') ax2.text(0.1,0.85, 'Unitarity: %f' % (qt.unitarity(two_qubit_noise))) ax2.text(0.1,0.80, 'Correlated Unitarity: %f' % (correlated_unitarity(two_qubit_noise))) eigenvaluesforchannel=eigens_of_A(two_qubit_noise)
def test_known_cases(self, operator, expected): assert unitarity(operator) == pytest.approx(expected, abs=1e-7)
num_of_data_points = 20 for i in range(num_of_data_points): print "Run: ", i # ~~~~~~~~~~ Set the noise channel here ~~~~~~~~~~~ found_a_good_channel = False limit = 0.3 while found_a_good_channel == False: # two_qubit_noise = unitary_channel(4,0.9,0.01) # A unitary # two_qubit_noise = qt.to_super(qt.cnot()) # CNOT # two_qubit_noise = qt.rand_super_bcsz(4, dims=[[[2, 2], [2, 2]], [[2, 2], [2, 2]]], rank=2) # two_qubit_noise = qt.rand_super_bcsz(4, dims=[[[2, 2], [2, 2]], [[2, 2], [2, 2]]]) two_qubit_noise = pauli_channel_2_qubit(4) # two_qubit_noise = qt.super_tensor(qt.rand_super(2),qt.rand_super(2)) # same=qt.rand_super(2) # two_qubit_noise = qt.super_tensor(same,same) if qt.unitarity(two_qubit_noise) > limit: found_a_good_channel = True two_qubit_noise.dims = [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] # Prints information about the noise (this is helpful to see if the channel is suitable) print "Unitarity: ", qt.unitarity(two_qubit_noise) print "Correlated Unitarity: ", correlated_unitarity(two_qubit_noise) print "True sub-unitarities:" print " AB->AB: ", sub_unitarity_AB_to_AB( two_qubit_noise), "A->A: ", sub_unitarity_A_to_A( two_qubit_noise), " B->B: ", sub_unitarity_B_to_B(two_qubit_noise) # Makes the gates noisy noisy_cliffords = [ two_qubit_noise * qt.to_super(qt.tensor(x, y))