-
Notifications
You must be signed in to change notification settings - Fork 35
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
274 building xppauli classes (part of 257) #281
Conversation
@@ -104,6 +108,8 @@ def __init__( | |||
matrix = nmatrix | |||
|
|||
self.matrix = matrix | |||
self.precision = precision | |||
# TODO should _num_paulis be renamed to _num_xppaulis in this and derived classes? |
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.
As we are separating the Pauli and XPPauli classes I would say it is better to change the name as you suggest.
BaseXPPauli: _description_ | ||
""" | ||
|
||
assert a.precision == b.precision, QiskitError( |
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.
This should not be in a "_"-method but a higher method compose
which probably belongs in XPPauli and XPPauliList (different for each). Assertions have the nice property that they have zero impact with DEBUG is set correctly but some people feel that they should not be used for format requirements and are more to detect algorithm and internal faults.
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.
See previous comment.
Replaced assert
with if...raise
.
"""(TODO improve doc): This is the equivalent of XPRound from Mark's | ||
code. It converts the XPPauli operator into unique vector form, ie | ||
phase_exp in Z modulo 2*precision, x in Z_2, z in Z modulo | ||
precision.""" |
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.
Add explicit examples ...
return np.sum(np.logical_or(self.x, self.z), axis=-1) | ||
|
||
def is_diagonal(self): | ||
"""_summary_""" |
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.
docs
qiskit_qec/operators/random.py
Outdated
@@ -196,6 +197,38 @@ def random_clifford(num_qubits, seed=None): | |||
return Clifford(StabilizerTable(table, phase)) | |||
|
|||
|
|||
def random_xppauli(num_qubits, precision=None, seed=None): |
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.
Add type hints
Args: | ||
num_qubits (int): the number of qubits. | ||
precision (int): Precision of XP operators. Must be an integer | ||
greater than or equal to 2. |
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.
Add explicit examples
# TODO | ||
pass | ||
|
||
def compose(self, other, qargs=None, front=False, inplace=False): |
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.
type hints
from Mark's code. It returns the count of qubits where either z or x | ||
component is nonzero.""" | ||
# TODO Since 'distance' has a specific meaning in QECCs, for now, the | ||
# name 'weight' has been used for this function. |
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.
Agree that weight is better than 'distance'
…ppaulilist 3. added test
In addition to implementing review comments, I've also added tests for |
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.
Looking good
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.
LGTM
Summary
Partial fix for #274 (part of #257 ). This PR contains an initial implementation of
XPPauli
andXPPauliList
classes.Details and comments
This is an initial implementation of XP operator algebra (from Mark Webster's package ) for
XPPauli
andXPPauliList
. This is a work in progress.XPPauli
andXPPauliList
and associated test files.random_xppauli
in operators/random.pyBaseXPPauli
(XP* are function names from Mark's code, name in brackets is the new name):XPSetN
(rescale_precision
)XPDistance
(weight
)XPisDiag
(is_diagonal
)XPDegree
(degree
)XPPower
(power
)XPMul
(compose
)XPRound
(unique_vector_rep
)XPD
(antisymmetric_op
)XPSetNSingle
,XPSquare
,XPdeg
).XPPauli
andXPPauliList
. Some tests are yet to be added forXPPauliList
for above implemented functions.Highly appreciate your feedback!