This repository was archived by the owner on Dec 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 376
refactor the Operator class #593
Merged
manoelmarques
merged 81 commits into
qiskit-community:master
from
chunfuchen:enhance/op_rewrite
Aug 2, 2019
Merged
refactor the Operator class #593
manoelmarques
merged 81 commits into
qiskit-community:master
from
chunfuchen:enhance/op_rewrite
Aug 2, 2019
Conversation
This file contains hidden or 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
I will integrate the MatrixOperator from my previous Operator PR. |
2. change the method name 3. support * with scalar
…a into enhance/op_rewrite
…a into enhance/op_rewrite
Matrix to TPB conversion takes an exponential time here. So, I recommend to show a warning message to notify it to users. They may use this path without knowing the situation. |
…a into enhance/op_rewrite
…essage 2. update __eq__ for grouped paulis
pistoia
previously approved these changes
Aug 2, 2019
woodsp-ibm
approved these changes
Aug 2, 2019
This was referenced Sep 10, 2019
mtreinish
pushed a commit
to mtreinish/qiskit-core
that referenced
this pull request
Nov 20, 2020
…nhance/op_rewrite refactor the Operator class
manoelmarques
added a commit
to manoelmarques/qiskit-terra
that referenced
this pull request
Dec 7, 2020
…nhance/op_rewrite refactor the Operator class
manoelmarques
added a commit
to qiskit-community/qiskit-machine-learning
that referenced
this pull request
Feb 27, 2021
…nhance/op_rewrite refactor the Operator class
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Refactor the Operator class and make it more extensible for different grouping approaches.
related to #311 #345 #553 #348
Details and comments
BaseOperator
defines the required methods._paulis
,_basis
and_z2_symmetries
are common info of an operator, and those info are tracked when converting to another type of operator.WeightedPauliOperator
equals to the previouspaulis
mode of the Operator; however, it adds a new property (basis
) for recording the grouping information. By default, each pauli is one group. Therefore, the same codes can be used for tensor-product basis grouping. E.g., two grouping methods Aqua had.TPBGroupedWeightedPauliOperator
is the previousgrouped_paulis
mode of the Operator, for the current grouping approach, the only difference will only be thebasis
field.paulis
property is always a flat list as inWeightedPauliOperator
instead of using the first item to record the basis; and thebasis
field records the indices of paulis belong to that group.Z2Symmetries
, which stores the Z2 symmetries info, includingsymmetries
,sq_list
,sq_paulis
. Then this class can be used to taper an operator.TODO
Discussion
Thus, if a user would like to have a new grouping approach which is similar to TPB, they can simply add new classmethod to grouping the
WeightedPauliOperator
and then re-use all of the codes directly.Nonetheless, if the new grouping approach affects the way to compute expectation against a wavefunction or the way to evolve the operator, users would need to create their own new class which is derived from either
BaseOperator
orWeightedPauliOperator
.