Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
drewvandeth committed Aug 29, 2024
1 parent 8884631 commit 0b01428
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
19 changes: 11 additions & 8 deletions src/qiskit_qec/operators/pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# that they have been altered from the originals.
# Part of the QEC framework
"""Module for Pauli"""
from typing import Any, Dict, List, Optional, Union
from typing import Dict, List, Optional, Union

import numpy as np
from qiskit.circuit import Instruction, QuantumCircuit
Expand Down Expand Up @@ -47,7 +47,6 @@ def __init__(
z: Union[List, np.ndarray, None] = None,
phase_exp: Union[int, str, np.ndarray, None] = None,
input_pauli_encoding: Optional[str] = BasePauli.EXTERNAL_PAULI_ENCODING,
label: Optional[str] = None,
input_qubit_order: Optional[str] = "right-to-left",
order: Optional[str] = "xz",
tuple_order: Optional[str] = "zx",
Expand All @@ -61,12 +60,14 @@ def __init__(
data (str | tuple | List | np.ndarray | BasePauli | None): Input data
x (Union[List, np.ndarray, None], optional): X Part. Defaults to None.
z (Union[List, np.ndarray, None], optional): Z Part. Defaults to None.
phase_exp (Union[str, np.ndarray, None], optional): Phase expression of Pauli. Defaults to None.
input_pauli_encoding (str, optional): What encoding is used for the input data. Default = BasePauli.EXTERNAL_PAULI_ENCODING
label ([str], optional): Deprecated. Defaults to None.
phase_exp (Union[str, np.ndarray, None], optional): Phase expression of
Pauli. Defaults to None.
input_pauli_encoding (str, optional): What encoding is used for the input
data. Default = BasePauli.EXTERNAL_PAULI_ENCODING
input_qubit_order (str, optional): Qubit read order. Defaults to "right-to-left".
order (str, optional): Order in which data lists X and Z. Defaults to 'xz'
tuple_order (str, optional): Order in data for X and Z parts of tuples. Defaults to 'zx'
tuple_order (str, optional): Order in data for X and Z parts of tuples.
Defaults to 'zx'
num_qubits (int, optional): Number of qubits to use in Pauli. Defaults to None.
Expand Down Expand Up @@ -94,7 +95,9 @@ def __init__(
>>>Pauli(None, x=[0,1],z=[1,1],phase_exp = '-i')
Pauli('-iYZ')
>>>Pauli(np.array([[0,1,1,1]]),phase_exp="(-i,1)(-1,0)", num_qubits=10, order="zx", input_pauli_encoding='-isXZ')
>>>Pauli(np.array([[0,1,1,1]]),
phase_exp="(-i,1)(-1,0)",
num_qubits=10, order="zx", input_pauli_encoding='-isXZ')
Pauli('-iIIIIIIIIYX')
>>>Pauli(([0,1],[1,1],'-i'), tuple_order='xz')
Expand Down Expand Up @@ -399,7 +402,7 @@ def _fast_getitem_str(self, i):
i (int): index of qubit
Returns:
str: Streing representing the Pauli acting on qubit i,
str: String representing the Pauli acting on qubit i,
(0,0):"I", (1,0):"X", (0,1):"Z", (1,1):"Y"
"""
return Pauli.pltb_str[(self.matrix[0][i], self.matrix[0][i + self.num_qubits])]
Expand Down
12 changes: 7 additions & 5 deletions src/qiskit_qec/operators/pauli_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ def __init__(
input_qubit_order (str, optional): Order to read pdata. Defaults to "right-to-left".
order (str, optional): Order in which data input lists X and Z. Defaults to 'xz'
num_qubits (int, optional): Number of qubits to use in Pauli. Defaults to None.
fast_load (bool, optional): If True class stores individual Pauls for fast element selection.
The fast_load options is much faster when loading elements from the list, say 100ns versus 2.3 us
but does so at the cost of initializing speed and memory. Defaults to True
fast_load (bool, optional): If True class stores individual Pauls for fast element
selection. The fast_load options is much faster when loading elements from the list,
say 100ns versus 2.3 us but does so at the cost of initializing speed and memory.
Defaults to True
Raises:
Expand Down Expand Up @@ -291,7 +292,7 @@ def __getitem__(self, index):
# Single Pauli
try:
return self.paulis[index]
except TypeError as load_error:
except TypeError:
return BasePauli(self.matrix[index], self._phase_exp[index])
elif isinstance(index, (slice, list, np.ndarray)):
# Sub-Table view
Expand All @@ -308,7 +309,7 @@ def getaslist(self, slc: Union[numbers.Integral, slice]) -> List["Pauli"]:
"""
try:
return self.paulis[slc]
except TypeError as load_error:
except TypeError:
return [
BasePauli(self.matrix[index], self._phase_exp[index]) for index in self.num_paulis
]
Expand Down Expand Up @@ -388,6 +389,7 @@ def __len__(self):
return self._num_paulis

def set_fast_load(self, fast_load: bool):
"""Set if class uses the fast_store method. Storing Pauli variables"""
self.fast_load = fast_load
if self.fast_load is True:
self.paulis = [
Expand Down
2 changes: 1 addition & 1 deletion test/operators/test_pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def test_delete(self):
pauli = pauli.delete([0, 2])
self.assertEqual(str(pauli), "IY")

def test_delete(self):
def test_delete2(self):
"""Test delete method"""
pauli = Pauli("IXYZ")
pauli = pauli.delete([1])
Expand Down

0 comments on commit 0b01428

Please sign in to comment.