Esempio n. 1
0
 def test_empty(self) -> None:
     circuit = Circuit(1)
     assert circuit.get_dim() == 2
     circuit = Circuit(4)
     assert circuit.get_dim() == 16
     circuit = Circuit(4, [2, 2, 3, 3])
     assert circuit.get_dim() == 36
Esempio n. 2
0
 def test_default(self) -> None:
     circuit = Circuit(1)
     assert circuit.get_size() == 1
     assert circuit.get_dim() == 2
     assert len(circuit.get_radixes()) == 1
     circuit.append_qudit()
     assert circuit.get_size() == 2
     assert circuit.get_dim() == 4
     assert len(circuit.get_radixes()) == 2
     circuit.append_qudit()
     assert circuit.get_size() == 3
     assert circuit.get_dim() == 8
     assert len(circuit.get_radixes()) == 3
Esempio n. 3
0
 def test_qutrit(self) -> None:
     circuit = Circuit(1, [3])
     assert circuit.get_size() == 1
     assert circuit.get_dim() == 3
     assert len(circuit.get_radixes()) == 1
     circuit.insert_qudit(0, 3)
     assert circuit.get_size() == 2
     assert circuit.get_dim() == 9
     assert len(circuit.get_radixes()) == 2
     circuit.insert_qudit(0, 3)
     assert circuit.get_size() == 3
     assert circuit.get_dim() == 27
     assert len(circuit.get_radixes()) == 3
Esempio n. 4
0
 def test_qutrits(self) -> None:
     circuit = Circuit(1, [3])
     assert circuit.get_size() == 1
     assert circuit.get_dim() == 3
     assert len(circuit.get_radixes()) == 1
     circuit.extend_qudits([3, 3])
     assert circuit.get_size() == 3
     assert circuit.get_dim() == 27
     assert len(circuit.get_radixes()) == 3
     circuit.extend_qudits([3, 3])
     assert circuit.get_size() == 5
     assert circuit.get_dim() == 243
     assert len(circuit.get_radixes()) == 5
Esempio n. 5
0
 def test_qubits(self) -> None:
     circuit = Circuit(1, [2])
     assert circuit.get_size() == 1
     assert circuit.get_dim() == 2
     assert len(circuit.get_radixes()) == 1
     circuit.extend_qudits([2, 2])
     assert circuit.get_size() == 3
     assert circuit.get_dim() == 8
     assert len(circuit.get_radixes()) == 3
     circuit.extend_qudits([2, 2])
     assert circuit.get_size() == 5
     assert circuit.get_dim() == 32
     assert len(circuit.get_radixes()) == 5
Esempio n. 6
0
 def test_hybrid(self) -> None:
     circuit = Circuit(1)
     assert circuit.get_size() == 1
     assert circuit.get_dim() == 2
     assert len(circuit.get_radixes()) == 1
     circuit.insert_qudit(0, 4)
     assert circuit.get_size() == 2
     assert circuit.get_dim() == 8
     assert len(circuit.get_radixes()) == 2
     assert circuit.get_radixes()[0] == 4
     assert circuit.get_radixes()[1] == 2
     circuit.insert_qudit(-1, 3)
     assert circuit.get_size() == 3
     assert circuit.get_dim() == 24
     assert len(circuit.get_radixes()) == 3
     assert circuit.get_radixes()[0] == 4
     assert circuit.get_radixes()[1] == 3
     assert circuit.get_radixes()[2] == 2
Esempio n. 7
0
 def test_hybrid(self) -> None:
     circuit = Circuit(1)
     assert circuit.get_size() == 1
     assert circuit.get_dim() == 2
     assert len(circuit.get_radixes()) == 1
     circuit.append_qudit(4)
     assert circuit.get_size() == 2
     assert circuit.get_dim() == 8
     assert len(circuit.get_radixes()) == 2
     assert circuit.get_radixes()[0] == 2
     assert circuit.get_radixes()[1] == 4
     circuit.append_qudit(3)
     assert circuit.get_size() == 3
     assert circuit.get_dim() == 24
     assert len(circuit.get_radixes()) == 3
     assert circuit.get_radixes()[0] == 2
     assert circuit.get_radixes()[1] == 4
     assert circuit.get_radixes()[2] == 3
Esempio n. 8
0
 def test_hybrid(self) -> None:
     circuit = Circuit(1)
     assert circuit.get_size() == 1
     assert circuit.get_dim() == 2
     assert len(circuit.get_radixes()) == 1
     circuit.extend_qudits([3, 4])
     assert circuit.get_size() == 3
     assert circuit.get_dim() == 24
     assert len(circuit.get_radixes()) == 3
     assert circuit.get_radixes()[0] == 2
     assert circuit.get_radixes()[1] == 3
     assert circuit.get_radixes()[2] == 4
     circuit.extend_qudits([3, 2])
     assert circuit.get_size() == 5
     assert circuit.get_dim() == 144
     assert len(circuit.get_radixes()) == 5
     assert circuit.get_radixes()[0] == 2
     assert circuit.get_radixes()[1] == 3
     assert circuit.get_radixes()[2] == 4
     assert circuit.get_radixes()[3] == 3
     assert circuit.get_radixes()[4] == 2
Esempio n. 9
0
 def test_get_dim(self, simple_circuit: Circuit) -> None:
     assert simple_circuit.get_dim() == 4
Esempio n. 10
0
 def test_value(self, r6_qudit_circuit: Circuit) -> None:
     assert r6_qudit_circuit.get_dim() >= 64
Esempio n. 11
0
 def test_type(self, r6_qudit_circuit: Circuit) -> None:
     assert isinstance(r6_qudit_circuit.get_dim(), int)
Esempio n. 12
0
 def test_get_dim(self, toffoli_circuit: Circuit) -> None:
     assert toffoli_circuit.get_dim() == 8
Esempio n. 13
0
 def test_get_dim(self, swap_circuit: Circuit) -> None:
     assert swap_circuit.get_dim() == 4
Esempio n. 14
0
def test_fuzz_simulation(r6_qudit_circuit: Circuit) -> None:
    utry = (r6_qudit_circuit + r6_qudit_circuit.get_dagger()).get_unitary()
    identity = np.identity(r6_qudit_circuit.get_dim())
    assert np.allclose(utry.get_numpy(), identity)