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

Error in check for the normalizer method of a single operator generating set #240

Closed
dsvandet opened this issue Jul 19, 2022 · 0 comments · Fixed by #241
Closed

Error in check for the normalizer method of a single operator generating set #240

dsvandet opened this issue Jul 19, 2022 · 0 comments · Fixed by #241
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@dsvandet
Copy link
Collaborator

dsvandet commented Jul 19, 2022

Steps to reproduce the problem

import qiskit_qec.linear.symplectic as symp
a = Pauli('XX')
symp.normalizer(a.matrix)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Untitled-1.ipynb Cell 10' in <cell line: 1>()
----> [1](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#ch0000009untitled?line=0) symp.normalizer(a.matrix)

File ~/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py:2049, in normalizer(matrix, x, z, min_gen)
   [2047](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=2046) if min_gen:
   [2048](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=2047)     matrix = min_generating(matrix)
-> [2049](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=2048) if is_stabilizer_group(matrix):
   [2050](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=2049)     return _normalizer_abelian_group(matrix)
   [2051](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=2050) else:

File ~/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py:1191, in is_stabilizer_group(matrix)
   [1189](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=1188) if not is_symplectic_matrix_form(matrix):
   [1190](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=1189)     raise QiskitError("Input matrix not a GF(2) symplectic matrix")
-> [1191](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=1190) return all_commute(matrix)

File ~/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py:54, in all_commute(matrix)
     [27](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=26) r"""Determines if each possible pair of different rows of the
     [28](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=27) GF(2) symplectic matrix have zero symplectic product. If the rows represent
     [29](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=28) Pauli operators then the this method deterimes if the operators
   (...)
     [51](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=50)     True
     [52](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=51) """
     [53](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=52) test_mat = symplectic_product(matrix, matrix)
---> [54](file:///Users/dsvandet/Software/Public/working/qiskit-qec/qiskit_qec/linear/symplectic.py?line=53) return not test_mat.any()

AttributeError: 'int' object has no attribute 'any'

What is the current behavior?

As above.

What is the expected behavior?

Should return the normalizer of the group generated by $X_0X1$ in the 2-qubit Pauli Group.

How to fix

The problem lies with the check in the normalizer method checking that the input matrix represents a set of commuting operators. The check runs symplectic_product(matrix, matrix) but since matrix is a vector in this example the current returned result is an integer and thus lacks an any method.

Fix: Apply np.asarray() to the result of the symplectic product

Unit tests

I unit test should be added to include this case - single generator (single row matrix)

@dsvandet dsvandet added bug Something isn't working good first issue Good for newcomers labels Jul 19, 2022
@dsvandet dsvandet self-assigned this Jul 19, 2022
@dsvandet dsvandet linked a pull request Jul 19, 2022 that will close this issue
dsvandet added a commit that referenced this issue Jul 26, 2022
* Fix for Issue 240

* Corrected spelling error

* Corrected output type for symplectic_product

Co-authored-by: Iskandar Sitdikov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant