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

Removing consider-using-enumerate from lint exclusions and updates #12286

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

joesho112358
Copy link
Contributor

Summary

#9614 - removing consider-using-enumerate

Details and comments

Updates for removing this rule if wanted. Open to suggestions on variable names

@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Apr 20, 2024
@coveralls
Copy link

coveralls commented Apr 20, 2024

Pull Request Test Coverage Report for Build 9295747340

Details

  • 17 of 20 (85.0%) changed or added relevant lines in 6 files are covered.
  • 7 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.003%) to 89.59%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/bloch.py 5 6 83.33%
qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.02%
qiskit/visualization/bloch.py 1 49.83%
crates/qasm2/src/lex.rs 5 91.86%
Totals Coverage Status
Change from base Build 9291000954: -0.003%
Covered Lines: 62318
Relevant Lines: 69559

💛 - Coveralls

@joesho112358 joesho112358 marked this pull request as ready for review April 21, 2024 13:01
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

@joesho112358
Copy link
Contributor Author

@mtreinish as a heads up, the latest commit probably needs your eyes. specifically in the passmanager.py file. i made a change there that i think is in line with the intention, although a bit weird in implementation.

Comment on lines 122 to 125
original_qubits_reverse = {v: k for k, v in original_qubit_indices.items()}
original_qubits = []
for i in range(len(original_qubits_reverse)):
original_qubits.append(original_qubits_reverse[i])
for v, k in original_qubits_reverse.items():
original_qubits.append(k)
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a behavioural change to me. Dictionary iteration order is insertion order, but the previous form was specifically looking up in numerical order of the v items.

The vs are ints here (from 0 to n-1) and the k are Qubit instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, i see it now. ok, i'll have to update this

@joesho112358 joesho112358 marked this pull request as draft May 10, 2024 16:12
@joesho112358 joesho112358 marked this pull request as ready for review May 13, 2024 02:53
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

Overall this LGTM, just one question/comment inline about the changes in passmanager.py

Comment on lines +122 to +124
original_qubits = [None] * len(original_qubit_indices)
for k, v in original_qubit_indices.items():
original_qubits[v] = k
Copy link
Member

Choose a reason for hiding this comment

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

I'm mildly worried about this logic in the failure mode here. If somehow original_qubit_indices was incorrectly constructed and missing an index this wouldn't catch that. We'd never know that there was an entry in the list which was None and I just checked that virtual_permutation_layout.inverse() doesn't error if it gets None on an input element (which itself seems like a bug).. I liked the previous logic because it would error if you original_qubit_indices was incorrectly constructed.

While it's not critical and I think this would not be an issue in practice, I'm just wondering if we need to make this change here? Like if pylint flagging this I'm wondering if a local exclude makes more sense in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be sufficient to add a check after regenerating original_qubits?

        if None in original_qubits:
            raise ValueError("original_qubit_indices is missing an index")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

5 participants