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

Deprecate bind_parameters in favor of assign_parameters #10792

Merged
merged 12 commits into from
Sep 12, 2023

Conversation

ElePT
Copy link
Contributor

@ElePT ElePT commented Sep 7, 2023

Summary

Fixes #7057 (unless there is any strong argument to keep both methods in Qiskit 1.0).
Fix #8958

Details and comments

bind_parameters was only used in a couple of places internally. I went through these to make sure that we would not need any additional checks for the assigned values (as bind_parameters would fail for ParameterExpressions):

  • Sampler, Estimator, BackendSampler, BackendEstimator
  • _expand_parameters in qiskit/compiler/assembler.py
  • DefaultUnitarySynthesis transpiler pass
  • UnrollForLoops transpiler pass

I don't think these checks would be needed, but let me know if you disagree.

I was also unsure about modifying the qiskit.algorithms related code, as it is going to be removed anyway, but honestly the search and replace was pretty much 0 effort compared to catching the deprecation warnings or creating exceptions in the test case. I have in any case done this in a separate commit in case we think it should be reverted.

@qiskit-bot
Copy link
Collaborator

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

  • @enavarro51
  • @ElePT
  • @Qiskit/terra-core
  • @ajavadia
  • @ikkoham
  • @levbishop
  • @mtreinish
  • @nkanazawa1989
  • @t-imamichi
  • @woodsp-ibm

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

This looks pretty much solid to me, thanks Elena!

test/benchmarks/circuit_construction.py Outdated Show resolved Hide resolved
test/python/circuit/test_parameters.py Show resolved Hide resolved
@ElePT ElePT added the Changelog: Deprecation Include in "Deprecated" section of changelog label Sep 11, 2023
@1ucian0 1ucian0 added this to the 0.45.0 milestone Sep 11, 2023
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

This looks good to me now, thanks Elena. I'm strongly expecting that we'll get some complaints about people wishing we'd use one name over the other, but since assign_parameters is the superset of functionality of bind_parameters, the decision was already made for us.

(And personally I prefer assign anyway haha)

Comment on lines +503 to +505
# TODO: delete once bind_parameters is removed from the codebase
warnings.filterwarnings("ignore", category=DeprecationWarning)

Copy link
Member

Choose a reason for hiding this comment

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

This appears to need the manual override because of the getattr call changing the stack depth of the deprecated access, right? We could rewrite the test to avoid needing this, but it's probably cleanest just to leave it the way you have.

@jakelishman jakelishman added this pull request to the merge queue Sep 12, 2023
Merged via the queue into Qiskit:main with commit 884cfe6 Sep 12, 2023
14 checks passed
garrison added a commit to Qiskit/qiskit-addon-cutting that referenced this pull request Sep 12, 2023
... as `bind_parameters` has been deprecated
(Qiskit/qiskit#10792)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Deprecation Include in "Deprecated" section of changelog
Projects
None yet
4 participants