Skip to content

Commit

Permalink
Remove PasqalConverter deprecation. (#5672)
Browse files Browse the repository at this point in the history
* Remove PasqalConverter deprecation.

* lint.

Co-authored-by: Dave Bacon <dabacon@google.com>
  • Loading branch information
MichaelBroughton and dabacon committed Jul 7, 2022
1 parent 2657c53 commit 041413c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cirq-pasqal/cirq_pasqal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from cirq_pasqal.pasqal_gateset import PasqalGateset

from cirq_pasqal.pasqal_device import PasqalDevice, PasqalVirtualDevice, PasqalConverter
from cirq_pasqal.pasqal_device import PasqalDevice, PasqalVirtualDevice

from cirq_pasqal.pasqal_noise_model import PasqalNoiseModel

Expand Down
2 changes: 1 addition & 1 deletion cirq-pasqal/cirq_pasqal/json_test_data/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
packages=[cirq_pasqal],
test_data_path=pathlib.Path(__file__).parent,
not_yet_serializable=[],
should_not_be_serialized=["PasqalConverter", "PasqalNoiseModel", "PasqalSampler"],
should_not_be_serialized=["PasqalNoiseModel", "PasqalSampler"],
resolver_cache=_class_resolver_dictionary(),
deprecated={},
)
33 changes: 2 additions & 31 deletions cirq-pasqal/cirq_pasqal/pasqal_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
# 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 Callable, List, Sequence, Any, Union, Dict
from typing import Sequence, Any, Union, Dict
import numpy as np
import networkx as nx

import cirq
from cirq import _compat, GridQubit, LineQubit
from cirq import GridQubit, LineQubit
from cirq.ops import NamedQubit
from cirq_pasqal import ThreeDQubit, TwoDQubit, PasqalGateset

Expand Down Expand Up @@ -286,32 +286,3 @@ def _value_equality_values_(self) -> Any:

def _json_dict_(self) -> Dict[str, Any]:
return cirq.protocols.obj_to_dict_helper(self, ['control_radius', 'qubits'])


@_compat.deprecated_class(
deadline='v0.16', fix='Use cirq.optimize_for_target_gateset(circuit, gateset=PasqalGateset()).'
)
class PasqalConverter(cirq.neutral_atoms.ConvertToNeutralAtomGates):
"""A gate converter for compatibility with Pasqal processors.
Modified version of ConvertToNeutralAtomGates, where a new 'convert' method
'pasqal_convert' takes the 'keep' function as an input.
"""

def pasqal_convert(
self, op: cirq.Operation, keep: Callable[[cirq.Operation], bool]
) -> List[cirq.Operation]:
def on_stuck_raise(bad):
return TypeError(
"Don't know how to work with {!r}. "
"It isn't a native PasqalDevice operation, "
"a 1 or 2 qubit gate with a known unitary, "
"or composite.".format(bad)
)

return cirq.protocols.decompose(
op,
keep=keep,
intercepting_decomposer=self._convert_one,
on_stuck_raise=None if self.ignore_failures else on_stuck_raise,
)

0 comments on commit 041413c

Please sign in to comment.