Skip to content

Commit

Permalink
removed deprecated PauliTable, StabilizerTable and tests (#10815)
Browse files Browse the repository at this point in the history
* removed deprecated PauliTable, StabilizerTable and tests

* remove deprecated PauliTable

* add release note

* Revert removal of pauli_basis

* fix a test

* Update releasenotes/notes/remove-deprecated-in-quantum-info-0f9bd2b0c093307d.yaml

Co-authored-by: Jake Lishman <[email protected]>

---------

Co-authored-by: ikkoham <[email protected]>
Co-authored-by: Jake Lishman <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2023
1 parent 63283dc commit 6246783
Show file tree
Hide file tree
Showing 21 changed files with 32 additions and 5,282 deletions.
6 changes: 0 additions & 6 deletions qiskit/quantum_info/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
SparsePauliOp
CNOTDihedral
PauliList
PauliTable
StabilizerTable
pauli_basis
.. _quantum_info_states:
Expand Down Expand Up @@ -94,7 +92,6 @@
.. autofunction:: random_clifford
.. autofunction:: random_quantum_channel
.. autofunction:: random_cnotdihedral
.. autofunction:: random_pauli_table
.. autofunction:: random_pauli_list
Analysis
Expand Down Expand Up @@ -130,10 +127,8 @@
Operator,
Pauli,
PauliList,
PauliTable,
ScalarOp,
SparsePauliOp,
StabilizerTable,
anti_commutator,
commutator,
double_commutator,
Expand All @@ -149,7 +144,6 @@
random_hermitian,
random_pauli,
random_pauli_list,
random_pauli_table,
random_quantum_channel,
random_statevector,
random_unitary,
Expand Down
2 changes: 0 additions & 2 deletions qiskit/quantum_info/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
Clifford,
Pauli,
PauliList,
PauliTable,
SparsePauliOp,
StabilizerTable,
pauli_basis,
)
from .utils import anti_commutator, commutator, double_commutator
8 changes: 2 additions & 6 deletions qiskit/quantum_info/operators/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""

from __future__ import annotations

import numpy as np
from numpy.random import default_rng

Expand All @@ -23,12 +24,7 @@

# pylint: disable=unused-import
from .dihedral.random import random_cnotdihedral
from .symplectic.random import (
random_clifford,
random_pauli,
random_pauli_list,
random_pauli_table,
)
from .symplectic.random import random_clifford, random_pauli, random_pauli_list

DEFAULT_RNG = default_rng()

Expand Down
5 changes: 2 additions & 3 deletions qiskit/quantum_info/operators/symplectic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
"""

from __future__ import annotations

from .clifford import Clifford
from .pauli import Pauli
from .pauli_table import PauliTable
from .pauli_list import PauliList
from .pauli_utils import pauli_basis
from .stabilizer_table import StabilizerTable
from .clifford import Clifford
from .sparse_pauli_op import SparsePauliOp
79 changes: 0 additions & 79 deletions qiskit/quantum_info/operators/symplectic/clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

from .base_pauli import BasePauli
from .clifford_circuits import _append_circuit, _append_operation
from .stabilizer_table import StabilizerTable


class Clifford(BaseOperator, AdjointMixin, Operation):
Expand Down Expand Up @@ -164,10 +163,6 @@ def __init__(self, data, validate=True, copy=True):
num_qubits = data.num_qubits
self.tableau = Clifford.from_circuit(data).tableau

# DEPRECATED: data is StabilizerTable
elif isinstance(data, StabilizerTable):
self.tableau = self._stack_table_phase(data.array, data.phase)
num_qubits = data.num_qubits
# Initialize StabilizerTable directly from the data
else:
if isinstance(data, (list, np.ndarray)) and np.asarray(data, dtype=bool).ndim == 2:
Expand Down Expand Up @@ -246,80 +241,6 @@ def __setitem__(self, key, value):
"""Set a stabilizer Pauli row"""
self.tableau.__setitem__(key, self._stack_table_phase(value.array, value.phase))

@property
@deprecate_func(
since="0.24.0",
additional_msg="Use Clifford.stab and Clifford.destab properties instead.",
is_property=True,
)
def table(self):
"""Return StabilizerTable"""
return StabilizerTable(self.symplectic_matrix, phase=self.phase)

@table.setter
@deprecate_func(
since="0.24.0",
additional_msg="Use Clifford.stab and Clifford.destab properties instead.",
is_property=True,
)
def table(self, value):
"""Set the stabilizer table"""
# Note this setter cannot change the size of the Clifford
# It can only replace the contents of the StabilizerTable with
# another StabilizerTable of the same size.
if not isinstance(value, StabilizerTable):
value = StabilizerTable(value)
self.symplectic_matrix = value._table._array
self.phase = value._table._phase

@property
@deprecate_func(
since="0.24.0",
additional_msg="Use Clifford.stab properties instead.",
is_property=True,
)
def stabilizer(self):
"""Return the stabilizer block of the StabilizerTable."""
array = self.tableau[self.num_qubits : 2 * self.num_qubits, :-1]
phase = self.tableau[self.num_qubits : 2 * self.num_qubits, -1].reshape(self.num_qubits)
return StabilizerTable(array, phase)

@stabilizer.setter
@deprecate_func(
since="0.24.0",
additional_msg="Use Clifford.stab properties instead.",
is_property=True,
)
def stabilizer(self, value):
"""Set the value of stabilizer block of the StabilizerTable"""
if not isinstance(value, StabilizerTable):
value = StabilizerTable(value)
self.tableau[self.num_qubits : 2 * self.num_qubits, :-1] = value.array

@property
@deprecate_func(
since="0.24.0",
additional_msg="Use Clifford.destab properties instead.",
is_property=True,
)
def destabilizer(self):
"""Return the destabilizer block of the StabilizerTable."""
array = self.tableau[0 : self.num_qubits, :-1]
phase = self.tableau[0 : self.num_qubits, -1].reshape(self.num_qubits)
return StabilizerTable(array, phase)

@destabilizer.setter
@deprecate_func(
since="0.24.0",
additional_msg="Use Clifford.destab properties instead.",
is_property=True,
)
def destabilizer(self, value):
"""Set the value of destabilizer block of the StabilizerTable"""
if not isinstance(value, StabilizerTable):
value = StabilizerTable(value)
self.tableau[: self.num_qubits, :-1] = value.array

@property
def symplectic_matrix(self):
"""Return boolean symplectic matrix."""
Expand Down
8 changes: 0 additions & 8 deletions qiskit/quantum_info/operators/symplectic/pauli_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from qiskit.quantum_info.operators.symplectic.base_pauli import BasePauli
from qiskit.quantum_info.operators.symplectic.clifford import Clifford
from qiskit.quantum_info.operators.symplectic.pauli import Pauli
from qiskit.quantum_info.operators.symplectic.pauli_table import PauliTable
from qiskit.quantum_info.operators.symplectic.stabilizer_table import StabilizerTable


class PauliList(BasePauli, LinearMixin, GroupMixin):
Expand Down Expand Up @@ -134,12 +132,6 @@ def __init__(self, data: Pauli | list):
"""
if isinstance(data, BasePauli):
base_z, base_x, base_phase = data._z, data._x, data._phase
elif isinstance(data, StabilizerTable):
# Conversion from legacy StabilizerTable
base_z, base_x, base_phase = self._from_array(data.Z, data.X, 2 * data.phase)
elif isinstance(data, PauliTable):
# Conversion from legacy PauliTable
base_z, base_x, base_phase = self._from_array(data.Z, data.X)
else:
# Conversion as iterable of Paulis
base_z, base_x, base_phase = self._from_paulis(data)
Expand Down
Loading

0 comments on commit 6246783

Please sign in to comment.