Skip to content

Fix lint errors, most_likely() tie-breaking bug, and expand test coverage to 36 tests#11

Open
Copilot wants to merge 3 commits intomainfrom
copilot/create-evaluation-plan
Open

Fix lint errors, most_likely() tie-breaking bug, and expand test coverage to 36 tests#11
Copilot wants to merge 3 commits intomainfrom
copilot/create-evaluation-plan

Conversation

Copy link

Copilot AI commented Mar 10, 2026

The repo had three correctness/quality gaps: lint failures blocking CI, a behavioural mismatch between most_likely()'s documented and actual tie-breaking behaviour, and only 28 tests despite the README advertising "35+".

Fixes

quantum_simulator.py

  • Removed unused imports Iterable and List from typing
  • Fixed most_likely() tie-breaking — was returning the lexicographically largest bitstring on ties; now correctly returns the smallest as documented:
    # Before (returns "10" on a tie — wrong)
    return max(self.counts.items(), key=lambda item: (item[1], item[0]))[0]
    
    # After (returns "01" on a tie — matches docstring)
    best_count = max(self.counts.values())
    return min(k for k, v in self.counts.items() if v == best_count)

tests/test_quantum_simulator.py

  • Renamed ambiguous variable Iidentity (E741)
  • Added 8 tests across 4 new classes, bringing the total to 36 and coverage to 99%:
    Class What it covers
    TestEmptyQubits probabilities(qubits=[]) early-return path; measure(qubits=[]) full-state collapse
    TestNonSquareUnitary Non-square matrix guard in _apply_unitary
    TestMostLikelyTieBreaking Two- and three-way tie resolution
    TestAdditionalCircuits Pauli-Y, 5-qubit GHZ, Bell-state partial-measurement collapse
Original prompt

Let's ensure this repo actually does what it says it does. If not or minimal, make a plan and execute a solution please and thank you


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blackroad-site Ready Ready Preview, Comment Mar 10, 2026 9:00am

Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
…rage)

Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
Copilot AI changed the title [WIP] Evaluate repository functionality and implement necessary solutions Fix lint errors, most_likely() tie-breaking bug, and expand test coverage to 36 tests Mar 10, 2026
@blackboxprogramming blackboxprogramming marked this pull request as ready for review March 10, 2026 09:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses CI quality/correctness gaps in the quantum circuit simulator by aligning MeasurementResult.most_likely() behavior with its documented tie-breaking rule, cleaning up lint issues, and expanding test coverage.

Changes:

  • Fix MeasurementResult.most_likely() to break ties by choosing the lexicographically smallest bitstring.
  • Resolve a Ruff E741 lint issue by renaming an ambiguous variable in tests and add new tests for edge cases and additional circuits.
  • (Unintended) adds a .coverage artifact file to the repository.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
quantum_simulator.py Removes unused typing imports and corrects most_likely() tie-breaking logic to match the docstring.
tests/test_quantum_simulator.py Fixes an ambiguous variable name and adds additional tests to improve coverage across edge cases and circuits.
.coverage Adds a local coverage data artifact (should not be committed).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +320 to +322
def test_bell_state_qubit1_collapses_qubit0(self):
"""Measuring qubit 0 of a Bell state collapses qubit 1 to the same value."""
circuit = QuantumCircuit(2)
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name and docstring disagree: the function name says qubit1 collapses qubit0, but the test measures qubit 0 and asserts the full state collapses accordingly. Rename the test to match the behavior being validated to avoid confusion when reading failures.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants