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

Apply new deprecation decorators to visualization folder #9867

Merged
merged 7 commits into from
May 11, 2023

Conversation

Eric-Arellano
Copy link
Collaborator

Summary

See #9676 for the motivation.

Details and comments

@Eric-Arellano Eric-Arellano requested review from a team and nonhermitian as code owners March 29, 2023 14:38
@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:

DeprecationWarning,
2,
)
del reverse_bits
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI the del is to make Pylint happy.

Copy link
Member

Choose a reason for hiding this comment

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

I think we the previous decorator, it was possible to remove the kwarg that was deprecated... a non-blocker for this one.

circ = QuantumCircuit(qubits, clbits)
for reg in qregs:
for reg in qregs or []:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was a bug fix. If qregs is None, then you can't iterate over it.

Copy link
Member

Choose a reason for hiding this comment

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

that's true, but passing neither qregs nor circuit is an invalid calling convention, so it's fine for it just to explode tbh. (It doesn't come up because this is actually just an internal-detail class.)

@Eric-Arellano Eric-Arellano added the Changelog: None Do not include in changelog label Mar 29, 2023
@1ucian0 1ucian0 added the type: qa Issues and PRs that relate to testing and code quality label Mar 30, 2023
@@ -561,12 +561,8 @@ def _generate_latex_source(
style=style,
reverse_bits=reverse_bits,
plot_barriers=plot_barriers,
layout=None,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These lines in this file caused deprecation warnings. There's no need to set them because None is the default.

"arguments for rendering the drawing."
),
)
def __init__( # pylint: disable=bad-docstring-quotes
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I couldn't figure out why Pylint is mad. Sphinx is happy with the docstring, and I confirmed that QCircuitImage.__init__.__doc__ looks good.

It seems low priority to figure this out: what we really care about is Sphinx being happy.

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 like 80% sure it's a bug in pylint, but I don't have the issue to hand. If you search for bad-docstring-quotes in Terra I think there's a couple dozen instances.

@coveralls
Copy link

coveralls commented Mar 30, 2023

Pull Request Test Coverage Report for Build 4863626625

  • 31 of 43 (72.09%) changed or added relevant lines in 7 files are covered.
  • 30 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.03%) to 85.896%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/circuit/latex.py 8 10 80.0%
qiskit/visualization/pulse/matplotlib.py 0 4 0.0%
qiskit/visualization/counts_visualization.py 3 9 33.33%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 93.76%
qiskit/circuit/tools/pi_check.py 1 91.23%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 1 95.14%
qiskit/visualization/pulse/qcstyle.py 2 32.0%
qiskit/pulse/library/waveform.py 3 93.75%
crates/qasm2/src/lex.rs 4 90.89%
crates/qasm2/src/parse.rs 18 96.65%
Totals Coverage Status
Change from base Build 4862959128: -0.03%
Covered Lines: 70988
Relevant Lines: 82644

💛 - Coveralls

@Eric-Arellano
Copy link
Collaborator Author

Bump

@Eric-Arellano Eric-Arellano added this to the 0.24.0 milestone Apr 10, 2023
@1ucian0 1ucian0 self-assigned this Apr 13, 2023
"arguments for rendering the drawing."
),
)
def __init__( # pylint: disable=bad-docstring-quotes
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 like 80% sure it's a bug in pylint, but I don't have the issue to hand. If you search for bad-docstring-quotes in Terra I think there's a couple dozen instances.

qiskit/visualization/circuit/latex.py Outdated Show resolved Hide resolved
circ = QuantumCircuit(qubits, clbits)
for reg in qregs:
for reg in qregs or []:
Copy link
Member

Choose a reason for hiding this comment

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

that's true, but passing neither qregs nor circuit is an invalid calling convention, so it's fine for it just to explode tbh. (It doesn't come up because this is actually just an internal-detail class.)

qiskit/visualization/circuit/matplotlib.py Outdated Show resolved Hide resolved
Comment on lines +49 to +70
def _is_deprecated_data_format(data) -> bool:
if not isinstance(data, list):
data = [data]
for dat in data:
if isinstance(dat, (QuasiDistribution, ProbDistribution)) or isinstance(
next(iter(dat.values())), float
):
return True
return False


@deprecate_arg(
"data",
deprecation_description=(
"Using plot_histogram() ``data`` argument with QuasiDistribution, ProbDistribution, or a "
"distribution dictionary"
),
since="0.22.0",
additional_msg="Instead, use ``plot_distribution()``.",
predicate=_is_deprecated_data_format,
pending=True,
)
Copy link
Member

Choose a reason for hiding this comment

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

This is starting to add non-trivial overhead into any call to the function, since we now loop through all the data now. It's not important for this visualisation function and doesn't need changing, but I think it's something we should be careful about in general.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#9902 should avoid the duplication of being both in the decorator and the function body.

If you'd like, I can prioritize that for next week? Or remove this particular call?

Copy link
Member

Choose a reason for hiding this comment

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

We can just leave this call in place for now - the inefficiency isn't going to be an issue for this particular function call.

@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Apr 20, 2023
@mtreinish mtreinish modified the milestones: 0.24.0, 0.24.1 May 4, 2023
@1ucian0 1ucian0 added this pull request to the merge queue May 11, 2023
Merged via the queue into Qiskit:main with commit e924ea9 May 11, 2023
mergify bot pushed a commit that referenced this pull request May 11, 2023
* Apply new deprecation decorators to visualization folder

* Remove stray backtick

* Fix helper functions setting deprecated args to default of `None`

* Ignore pylint issue

* Don't use deprecator for `circuit is None`

(cherry picked from commit e924ea9)
@Eric-Arellano Eric-Arellano deleted the apply-deprecations-visualization branch May 11, 2023 12:15
1ucian0 added a commit that referenced this pull request May 13, 2023
)

* Apply new deprecation decorators to visualization folder

* Remove stray backtick

* Fix helper functions setting deprecated args to default of `None`

* Ignore pylint issue

* Don't use deprecator for `circuit is None`

(cherry picked from commit e924ea9)

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request May 22, 2023
* Apply new deprecation decorators to visualization folder

* Remove stray backtick

* Fix helper functions setting deprecated args to default of `None`

* Ignore pylint issue

* Don't use deprecator for `circuit is None`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog stable backport potential The bug might be minimal and/or import enough to be port to stable type: qa Issues and PRs that relate to testing and code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants