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 PasqalConverter deprecation. #5672

Merged
merged 6 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
)