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 mypy errors (results) #8255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix mypy errors (results) #8255

wants to merge 1 commit into from

Conversation

Randl
Copy link
Contributor

@Randl Randl commented Jun 28, 2022

Summary

Following discussion, I'm splitting #8187 by module.

Details and comments

This fixes all the mypy errors in results as for now.

@Randl Randl requested a review from a team as a code owner June 28, 2022 13:49
@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:

  • @Qiskit/terra-core

@@ -32,7 +32,7 @@ def z_diagonal(dim, dtype=float):
return (-1) ** np.mod(parity, 2)


def expval_with_stddev(coeffs: np.ndarray, probs: np.ndarray, shots: int) -> Tuple[float, float]:
def expval_with_stddev(coeffs: np.ndarray, probs: np.ndarray, shots: int) -> List[float]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly instead should return tuple of floats, i.e.,

return expval, calc_stddev

in L59

@javabster javabster added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 28, 2022
@1ucian0 1ucian0 added the mypy Work related to support improving type hints in Qiskti code label Mar 30, 2023
@@ -122,7 +124,7 @@ def expectation_value(
diagonal = str2diag(diagonal)

# Apply transpose of mitigation matrix
coeffs = mit_mat.T.dot(diagonal)
coeffs = mit_mat.T.dot(diagonal) # TODO: won't work if diagonal is Callable or dict?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The case of diagonal being Callable or dict is not explained anywhere in documentation (even though it is mentioned there) and is not tested. Not sure what it means.

"""The device qubits for this mitigator"""
return self._qubits
return self._qubits # TODO: cast to tuple or change return type
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This appears to be just the wrong signature. self._qubits is not necessarily tuple.

@Randl Randl force-pushed the mypy-4 branch 2 times, most recently from 8d9dbde to 79deca9 Compare April 5, 2023 13:40
@coveralls
Copy link

coveralls commented Apr 5, 2023

Pull Request Test Coverage Report for Build 5057927442

  • 48 of 52 (92.31%) changed or added relevant lines in 7 files are covered.
  • 20 unchanged lines in 6 files lost coverage.
  • Overall coverage increased (+0.05%) to 85.917%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/result/mitigation/correlated_readout_mitigator.py 11 12 91.67%
qiskit/result/mitigation/local_readout_mitigator.py 11 12 91.67%
qiskit/result/mitigation/utils.py 8 9 88.89%
qiskit/result/postprocess.py 4 5 80.0%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 93.76%
qiskit/result/mitigation/correlated_readout_mitigator.py 1 88.78%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 1 90.27%
crates/accelerate/src/sabre_swap/mod.rs 2 99.53%
crates/qasm2/src/lex.rs 3 91.39%
crates/qasm2/src/parse.rs 12 96.65%
Totals Coverage Status
Change from base Build 5050064110: 0.05%
Covered Lines: 71198
Relevant Lines: 82868

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 8702741555

Details

  • 48 of 52 (92.31%) changed or added relevant lines in 7 files are covered.
  • 18 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.02%) to 89.338%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/result/mitigation/correlated_readout_mitigator.py 11 12 91.67%
qiskit/result/mitigation/local_readout_mitigator.py 11 12 91.67%
qiskit/result/mitigation/utils.py 8 9 88.89%
qiskit/result/postprocess.py 4 5 80.0%
Files with Coverage Reduction New Missed Lines %
qiskit/result/mitigation/correlated_readout_mitigator.py 1 88.89%
crates/qasm2/src/lex.rs 5 92.37%
crates/qasm2/src/parse.rs 12 96.69%
Totals Coverage Status
Change from base Build 8689749566: -0.02%
Covered Lines: 60168
Relevant Lines: 67349

💛 - Coveralls

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 mypy Work related to support improving type hints in Qiskti code
Projects
Status: mypy
Development

Successfully merging this pull request may close these issues.

None yet

5 participants