From c02b750ff7150d1084322bde383a0b37289a364d Mon Sep 17 00:00:00 2001 From: Spencer Churchill Date: Mon, 14 Aug 2023 03:47:01 -0700 Subject: [PATCH] fix description + simplify logic --- qubit_simulator/simulator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qubit_simulator/simulator.py b/qubit_simulator/simulator.py index d66ec6c..79fcf64 100644 --- a/qubit_simulator/simulator.py +++ b/qubit_simulator/simulator.py @@ -29,13 +29,13 @@ def _validate_qubit_index( :param target_qubit: Index of the target qubit to validate. :param control_qubit: Index of the control qubit to validate. :raises IndexError: If the qubit index is out of range. - :raises ValueError: If the control qubit and target qubit are the same. """ if target_qubit < 0 or target_qubit >= self.num_qubits: raise IndexError(f"Target qubit index {target_qubit} out of range.") - if control_qubit is not None: - if control_qubit < 0 or control_qubit >= self.num_qubits: - raise IndexError(f"Control qubit index {control_qubit} out of range.") + if control_qubit is not None and ( + control_qubit < 0 or control_qubit >= self.num_qubits + ): + raise IndexError(f"Control qubit index {control_qubit} out of range.") def _apply_gate( self,