Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
This PR extends the quantum circuit simulator with two additional Pauli gates (Y and Z), expanding the available single-qubit operations beyond the existing Hadamard and Pauli-X gates.
- Added Pauli-Y and Pauli-Z gate methods to the QuantumCircuit class
- Implemented corresponding unitary matrices with correct complex phase factors
- Added comprehensive tests verifying both probability outcomes and phase behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| quantum_simulator.py | Implements pauli_y() and pauli_z() methods with detailed docstrings and defines their matrix representations |
| tests/test_quantum_simulator.py | Adds two test cases verifying Y-gate bit-flip with phase and Z-gate phase modification without probability changes |
| README.md | Updates feature description to include Pauli-X/Y/Z gates in the gate set listing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def test_pauli_y_flips_state_with_phase(): | ||
| circuit = QuantumCircuit(1) | ||
| circuit.pauli_y(0) | ||
| probs = circuit.probabilities() | ||
| assert probs["1"] == pytest.approx(1.0) | ||
| assert probs["0"] == pytest.approx(0.0) | ||
|
|
||
|
|
There was a problem hiding this comment.
test_pauli_y_flips_state_with_phase only asserts computational-basis probabilities after pauli_y(0) on |0⟩, which cannot observe the introduced phase (the same assertions would pass for an incorrect implementation like Pauli-X). To actually validate the phase behaviour, add an interference-based check (e.g., prepare a superposition with hadamard, apply pauli_y, then hadamard again and assert the resulting probabilities), or rename the test to avoid claiming phase coverage.
| def test_pauli_y_flips_state_with_phase(): | |
| circuit = QuantumCircuit(1) | |
| circuit.pauli_y(0) | |
| probs = circuit.probabilities() | |
| assert probs["1"] == pytest.approx(1.0) | |
| assert probs["0"] == pytest.approx(0.0) | |
| def test_pauli_y_flips_state_with_phase(): | |
| # Basic flip behaviour from |0⟩ to |1⟩ | |
| circuit = QuantumCircuit(1) | |
| circuit.pauli_y(0) | |
| probs = circuit.probabilities() | |
| assert probs["1"] == pytest.approx(1.0) | |
| assert probs["0"] == pytest.approx(0.0) | |
| # Interference-based check to validate the Pauli-Y phase: | |
| # H |0⟩ -> (|0⟩ + |1⟩)/√2 | |
| # Y then H should result in |1⟩ with probability 1, | |
| # whereas an incorrect Pauli-X implementation would give |0⟩. | |
| circuit = QuantumCircuit(1) | |
| circuit.hadamard(0) | |
| circuit.pauli_y(0) | |
| circuit.hadamard(0) | |
| probs = circuit.probabilities() | |
| assert probs["1"] == pytest.approx(1.0) | |
| assert probs["0"] == pytest.approx(0.0) |
Summary
Testing
Codex Task