Skip to content

Commit

Permalink
Remove qubit_set v0.15 deprecation. (quantumlib#5304)
Browse files Browse the repository at this point in the history
Yet more v0.15 deprecation removals.
  • Loading branch information
MichaelBroughton authored May 3, 2022
1 parent 373bc23 commit 992598f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 62 deletions.
27 changes: 1 addition & 26 deletions cirq-core/cirq/devices/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import abc
from typing import TYPE_CHECKING, Optional, AbstractSet, FrozenSet, Iterable
from typing import TYPE_CHECKING, Optional, FrozenSet, Iterable
import networkx as nx
from cirq import _compat, value

Expand All @@ -24,31 +24,6 @@
class Device(metaclass=abc.ABCMeta):
"""Hardware constraints for validating circuits."""

@_compat.deprecated(fix='Use metadata.qubit_set if applicable.', deadline='v0.15')
def qubit_set(self) -> Optional[AbstractSet['cirq.Qid']]:
"""Returns a set or frozenset of qubits on the device, if possible.
Returns:
If the device has a finite set of qubits, then a set or frozen set
of all qubits on the device is returned.
If the device has no well defined finite set of qubits (e.g.
`cirq.UnconstrainedDevice` has this property), then `None` is
returned.
"""

# Compatibility hack to work with devices that were written before this
# method was defined.
for name in ['qubits', '_qubits']:
if hasattr(self, name):
val = getattr(self, name)
if callable(val):
val = val()
return frozenset(val)

# Default to the qubits being unknown.
return None

@_compat.deprecated(deadline='v0.15', fix='Devices will no longer decompose operations.')
def decompose_operation(self, operation: 'cirq.Operation') -> 'cirq.OP_TREE':
"""Returns a device-valid decomposition for the given operation.
Expand Down
36 changes: 0 additions & 36 deletions cirq-core/cirq/devices/device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,6 @@
import cirq


def test_qubit_set_deprecated():
class RawDevice(cirq.Device):
pass

with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15'):
assert RawDevice().qubit_set() is None

class QubitFieldDevice(cirq.Device):
def __init__(self):
self.qubits = cirq.LineQubit.range(3)

with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15'):
assert QubitFieldDevice().qubit_set() == frozenset(cirq.LineQubit.range(3))

class PrivateQubitFieldDevice(cirq.Device):
def __init__(self):
self._qubits = cirq.LineQubit.range(4)

with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15'):
assert PrivateQubitFieldDevice().qubit_set() == frozenset(cirq.LineQubit.range(4))

class QubitMethodDevice(cirq.Device):
def qubits(self):
return cirq.LineQubit.range(5)

with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15'):
assert QubitMethodDevice().qubit_set() == frozenset(cirq.LineQubit.range(5))

class PrivateQubitMethodDevice(cirq.Device):
def _qubits(self):
return cirq.LineQubit.range(6)

with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15'):
assert PrivateQubitMethodDevice().qubit_set() == frozenset(cirq.LineQubit.range(6))


def test_decompose_operation_deprecated():
q0 = cirq.GridQubit(0, 0)

Expand Down

0 comments on commit 992598f

Please sign in to comment.