-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Parameter handling in SparsePauliOp #8620
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
4e6c1c3
Parameter-friendly usage of Numpy methods
jsistos b48e411
remove pdb.set_trace()
jsistos e47f856
Updated target image in mpl backend visualization tests
jsistos 7d922bb
Fixed methods causing failing tests
jsistos fd4fcc6
Merge branch 'main' of https://github.com/Qiskit/qiskit-terra into op…
jsistos 43f8ce0
fixed lint
jsistos 09cf891
Fixed formatting of variable in SparsePauliOP
jsistos fe4c2f3
Fixed dtype casting (object->float, complex->float) tests
jsistos 9c73918
Merge branch 'main' of https://github.com/Qiskit/qiskit-terra into op…
jsistos 3ea8a9d
Fixed failing tests
jsistos 8cec777
Fixed lint
jsistos 4dd2e02
Fixed import order for linter
jsistos 360e5c2
Merge branch 'main' into operator-parameters
ikkoham 38ff348
revert gate.py
ikkoham 1ce842d
revert qdrift.py
ikkoham 8721f12
revert PauliSumOp
ikkoham fbdb649
update SparsePauliOp
ikkoham d01b52e
readable code (Jake's suggestion)
ikkoham 8239318
add tests
ikkoham 23a37d5
add docs
ikkoham ab6392b
fix docs
ikkoham 65d1727
Merge branch 'main' into operator-parameters
ikkoham 6c6219c
fix typo
ikkoham 2833a27
add reno
ikkoham d51ce56
Update documentation
jakelishman 43d913c
Merge remote-tracking branch 'ibm/main' into operator-parameters
jakelishman a28d543
use-parameters
ikkoham f8e418e
bind_parameters_to_one
ikkoham 3f4c390
Merge branch 'main' into operator-parameters
ikkoham 917e9e2
Merge branch 'main' into operator-parameters
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
releasenotes/notes/operator-parameters-c81b7c05bffb740b.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
features: | ||
- | | ||
:class:`.SparsePauliOp`\ s can now be constructed with coefficient arrays | ||
that are general Python objects. This is purely intended for use with Terra's | ||
:class:`.ParameterExpression` objects; other objects may work, but do not | ||
have first-class support. Some :class:`.SparsePauliOp` methods (such as | ||
conversion to other class representations) may not work when using ``object`` | ||
arrays, if the desired target cannot represent these general arrays. | ||
|
||
For example, a :class:`.ParameterExpression` :class:`.SparsePauliOp` could | ||
be constructed by:: | ||
|
||
import numpy as np | ||
from qiskit.circuit import Parameter | ||
from qiskit.quantum_info import SparsePauliOp | ||
|
||
print(SparsePauliOp(["II", "XZ"], np.array([Parameter("a"), Parameter("b")]))) | ||
|
||
which gives | ||
|
||
.. code-block:: text | ||
|
||
SparsePauliOp(['II', 'XZ'], | ||
coeffs=[ParameterExpression(1.0*a), ParameterExpression(1.0*b)]) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might change this to say
object
dtype sparse pauli ops don't support the following methods. Just because I could envision a use case where a different custom class is used. (thinking directly usingsymengine
/sympy
symbols or maybe some other libraries types. But it's not a big deal (and docs can be updated later too).