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

Remove deprecated qubit_set. #5464

Merged
merged 2 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove deprecated qubit_set.
  • Loading branch information
MichaelBroughton committed Jun 7, 2022
commit cc48e6db20b6b301d6677c0d22bfcd446cf74501
6 changes: 1 addition & 5 deletions cirq-core/cirq/devices/unconstrained_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from typing import Any, Dict, TYPE_CHECKING

from cirq import _compat, value, protocols
from cirq import value, protocols
from cirq._doc import document
from cirq.devices import device

Expand All @@ -26,10 +26,6 @@
class _UnconstrainedDevice(device.Device):
"""A device that allows everything, infinitely fast."""

@_compat.deprecated(fix='qubit_set on UnconstrainedDevice is always None.', deadline='v0.15')
def qubit_set(self) -> None:
return None

def duration_of(self, operation: 'cirq.Operation') -> 'cirq.Duration':
return value.Duration(picos=0)

Expand Down
5 changes: 0 additions & 5 deletions cirq-core/cirq/devices/unconstrained_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,3 @@ def test_infinitely_fast():
assert cirq.UNCONSTRAINED_DEVICE.duration_of(cirq.X(cirq.NamedQubit('a'))) == cirq.Duration(
picos=0
)


def test_qubit_set_deprecated():
with cirq.testing.assert_deprecated('None', deadline='v0.15'):
assert cirq.UNCONSTRAINED_DEVICE.qubit_set() is None
8 changes: 2 additions & 6 deletions cirq-core/cirq/ion/ion_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any, FrozenSet, Iterable, Optional, Set, TYPE_CHECKING
from typing import Any, Iterable, Optional, Set, TYPE_CHECKING
import networkx as nx
from cirq import _compat, circuits, value, devices, ops, protocols
from cirq import circuits, value, devices, ops, protocols
from cirq.ion import convert_to_ion_gates

if TYPE_CHECKING:
Expand Down Expand Up @@ -78,10 +78,6 @@ def __init__(
def metadata(self) -> devices.DeviceMetadata:
return self._metadata

@_compat.deprecated(fix='Use metadata.qubit_set if applicable.', deadline='v0.15')
def qubit_set(self) -> FrozenSet['cirq.LineQubit']:
return self.qubits

def decompose_circuit(self, circuit: circuits.Circuit) -> circuits.Circuit:
return convert_to_ion_gates.ConvertToIonGates().convert_circuit(circuit)

Expand Down
5 changes: 0 additions & 5 deletions cirq-core/cirq/ion/ion_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,3 @@ def test_at():
assert d.at(-1) is None
assert d.at(0) == cirq.LineQubit(0)
assert d.at(2) == cirq.LineQubit(2)


def test_qubit_set_deprecated():
with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15', count=2):
assert ion_device(3).qubit_set() == frozenset(cirq.LineQubit.range(3))
8 changes: 2 additions & 6 deletions cirq-core/cirq/neutral_atoms/neutral_atom_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import itertools
import collections
from typing import Any, Iterable, cast, DefaultDict, TYPE_CHECKING, FrozenSet
from typing import Any, Iterable, cast, DefaultDict, TYPE_CHECKING
from numpy import sqrt
from cirq import _compat, devices, ops, circuits, value
from cirq import devices, ops, circuits, value
from cirq.devices.grid_qubit import GridQubit
from cirq.ops import raw_types
from cirq.value import Duration
Expand Down Expand Up @@ -105,10 +105,6 @@ def __init__(
def metadata(self) -> devices.GridDeviceMetadata:
return self._metadata

@_compat.deprecated(fix='Use metadata.qubit_set if applicable.', deadline='v0.15')
def qubit_set(self) -> FrozenSet['cirq.GridQubit']:
return self.qubits

def qubit_list(self):
return [qubit for qubit in self.qubits]

Expand Down
5 changes: 0 additions & 5 deletions cirq-core/cirq/neutral_atoms/neutral_atom_devices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,3 @@ def test_repr_pretty():
""".strip(),
)
cirq.testing.assert_repr_pretty(square_device(2, 2), "cirq.NeutralAtomDevice(...)", cycle=True)


def test_qubit_set_deprecated():
with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15', count=2):
assert square_device(2, 2).qubit_set() == frozenset(cirq.GridQubit.square(2, 0, 0))
21 changes: 0 additions & 21 deletions cirq-google/cirq_google/devices/known_devices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
import cirq_google.serialization.common_serializers as cgc


def test_foxtail_qubits():
with cirq.testing.assert_deprecated('Foxtail', deadline='v0.15', count=2):
expected_qubits = []
for i in range(0, 2):
for j in range(0, 11):
expected_qubits.append(cirq.GridQubit(i, j))

assert set(expected_qubits) == cirq_google.Foxtail.qubits
assert len(cirq_google.Foxtail.metadata.qubit_pairs) == 31


def test_foxtail_device_proto():
assert (
str(known_devices.FOXTAIL_PROTO)
Expand Down Expand Up @@ -465,16 +454,6 @@ def test_multiple_gate_sets():
)


def test_json_dict_deprecated():
with cirq.testing.assert_deprecated('Foxtail', deadline='v0.15', count=1):
assert cirq_google.Foxtail._json_dict_() == {'constant': 'cirq_google.Foxtail'}
with cirq.testing.assert_deprecated('Bristlecone', deadline='v0.15', count=1):
assert cirq_google.Bristlecone._json_dict_() == {'constant': 'cirq_google.Bristlecone'}
with cirq.testing.assert_deprecated('Constant', deadline='v0.15', count=1):
with pytest.raises(ValueError, match='xmon device name'):
known_devices._NamedConstantXmonDevice._from_json_dict_('the_unknown_fiddler')


@pytest.mark.parametrize('device', [cirq_google.Sycamore, cirq_google.Sycamore23])
def test_sycamore_devices(device):
q0 = cirq.GridQubit(5, 3)
Expand Down
7 changes: 1 addition & 6 deletions cirq-google/cirq_google/devices/serializable_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
# limitations under the License.
"""Device object for converting from device specification protos"""

from typing import Any, Callable, cast, Dict, Iterable, Optional, List, Set, Tuple, Type, FrozenSet
from typing import Any, Callable, cast, Dict, Iterable, Optional, List, Set, Tuple, Type
import cirq
from cirq import _compat
from cirq_google.serialization import serializable_gate_set
from cirq_google.api import v2

Expand Down Expand Up @@ -119,10 +118,6 @@ def metadata(self) -> cirq.GridDeviceMetadata:
"""Get metadata information for device."""
return self._metadata

@_compat.deprecated(fix='Please use metadata.qubit_set if applicable.', deadline='v0.15')
def qubit_set(self) -> FrozenSet[cirq.Qid]:
return frozenset(self.qubits)

@classmethod
def from_proto(
cls,
Expand Down
8 changes: 0 additions & 8 deletions cirq-google/cirq_google/devices/serializable_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ def test_gate_definition_equality():
eq.add_equality_group(cirq.X)


def test_qubit_set_deprecated():
foxtail = cg.SerializableDevice.from_proto(
proto=cg.devices.known_devices.FOXTAIL_PROTO, gate_sets=[cg.XMON]
)
with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15'):
_ = foxtail.qubit_set()


def test_foxtail():
valid_qubit1 = cirq.GridQubit(0, 0)
valid_qubit2 = cirq.GridQubit(1, 0)
Expand Down
6 changes: 1 addition & 5 deletions cirq-google/cirq_google/devices/xmon_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any, cast, Iterable, List, Optional, Set, TYPE_CHECKING, FrozenSet
from typing import Any, cast, Iterable, List, Optional, Set, TYPE_CHECKING

import cirq
from cirq import _compat
Expand Down Expand Up @@ -64,10 +64,6 @@ def metadata(self) -> cirq.GridDeviceMetadata:
"""Return the metadata for this device"""
return self._metadata

@_compat.deprecated(fix='Use metadata.qubit_set if applicable.', deadline='v0.15')
def qubit_set(self) -> FrozenSet[cirq.GridQubit]:
return self.qubits

def neighbors_of(self, qubit: cirq.GridQubit):
"""Returns the qubits that the given qubit can interact with."""
possibles = [
Expand Down
9 changes: 1 addition & 8 deletions cirq-google/cirq_google/devices/xmon_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ def test_device_metadata():
)


@mock.patch.dict(os.environ, clear='CIRQ_TESTING')
def test_qubit_set_deprecated():
d = square_device(2, 2)
with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15'):
_ = d.qubit_set()


@mock.patch.dict(os.environ, clear='CIRQ_TESTING')
def test_init():
d = square_device(2, 2, holes=[cirq.GridQubit(1, 1)])
Expand Down Expand Up @@ -332,4 +325,4 @@ def test_row_and_col():

@mock.patch.dict(os.environ, clear='CIRQ_TESTING')
def test_qubit_set():
assert cg.Foxtail.qubit_set() == frozenset(cirq.GridQubit.rect(2, 11, 0, 0))
assert cg.Foxtail.metadata.qubit_set == frozenset(cirq.GridQubit.rect(2, 11, 0, 0))
7 changes: 1 addition & 6 deletions cirq-ionq/cirq_ionq/ionq_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
# limitations under the License.
"""Devices for IonQ hardware."""

from typing import AbstractSet, Sequence, Union
from typing import Sequence, Union

import cirq
from cirq import _compat


_VALID_GATES = cirq.Gateset(
Expand Down Expand Up @@ -73,10 +72,6 @@ def __init__(self, qubits: Union[Sequence[cirq.LineQubit], int], atol=1e-8):
def metadata(self) -> cirq.DeviceMetadata:
return self._metadata

@_compat.deprecated(fix='Use metadata.qubit_set if applicable.', deadline='v0.15')
def qubit_set(self) -> AbstractSet['cirq.Qid']:
return self.qubits

def validate_operation(self, operation: cirq.Operation):
if operation.gate is None:
raise ValueError(
Expand Down
6 changes: 1 addition & 5 deletions cirq-pasqal/cirq_pasqal/pasqal_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import FrozenSet, Callable, List, Sequence, Any, Union, Dict
from typing import Callable, List, Sequence, Any, Union, Dict
import numpy as np
import networkx as nx

Expand Down Expand Up @@ -82,10 +82,6 @@ def maximum_qubit_number(self):
def metadata(self):
return self._metadata

@_compat.deprecated(fix='Use metadata.qubit_set() if applicable.', deadline='v0.15')
def qubit_set(self) -> FrozenSet[cirq.Qid]:
return frozenset(self.qubits)

def qubit_list(self):
return [qubit for qubit in self.qubits]

Expand Down
6 changes: 0 additions & 6 deletions cirq-pasqal/cirq_pasqal/pasqal_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ def test_validate_operation_errors():
d.validate_operation(cirq.CZ.on(TwoDQubit(0, 0), TwoDQubit(2, 2)))


def test_qubit_set_deprecated():
d = generic_device(3)
with cirq.testing.assert_deprecated('qubit_set', deadline='v0.15'):
_ = d.qubit_set()


def test_metadata():
d = generic_device(3)
assert d.metadata.qubit_set == frozenset(
Expand Down