Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix description + simplify logic #20

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions qubit_simulator/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down