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
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
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
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
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
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
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
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
def test_get_dim(self, simple_circuit: Circuit) -> None: assert simple_circuit.get_dim() == 4
def test_value(self, r6_qudit_circuit: Circuit) -> None: assert r6_qudit_circuit.get_dim() >= 64
def test_type(self, r6_qudit_circuit: Circuit) -> None: assert isinstance(r6_qudit_circuit.get_dim(), int)
def test_get_dim(self, toffoli_circuit: Circuit) -> None: assert toffoli_circuit.get_dim() == 8
def test_get_dim(self, swap_circuit: Circuit) -> None: assert swap_circuit.get_dim() == 4
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)