From 6f32d87ed6f904f212abf7430393a056a5a97648 Mon Sep 17 00:00:00 2001 From: sjdilkes Date: Wed, 9 Aug 2023 17:16:36 +0100 Subject: [PATCH] Update backend.py --- pytket/pytket/backends/backend.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pytket/pytket/backends/backend.py b/pytket/pytket/backends/backend.py index cb76d6c9ce..2ec67a4449 100644 --- a/pytket/pytket/backends/backend.py +++ b/pytket/pytket/backends/backend.py @@ -107,7 +107,6 @@ def valid_circuit(self, circuit: Circuit) -> bool: def _check_all_circuits( self, circuits: Iterable[Circuit], nomeasure_warn: Optional[bool] = None ) -> bool: - if nomeasure_warn is None: nomeasure_warn = not ( self._supports_state @@ -172,18 +171,19 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass: ... def get_compiled_circuit( - self, circuit: Circuit, optimisation_level: int = 2 + self, circuit: Circuit, optimisation_level: int = 2, **kwargs ) -> Circuit: """ - Return a single circuit compiled with :py:meth:`default_compilation_pass`. See - :py:meth:`Backend.get_compiled_circuits`. + Return a single circuit compiled with :py:meth:`default_compilation_pass` See + :py:meth:`Backend.get_compiled_circuits`. Valid kwargs are Backend specific. + """ return_circuit = circuit.copy() - self.default_compilation_pass(optimisation_level).apply(return_circuit) + self.default_compilation_pass(optimisation_level, kwargs).apply(return_circuit) return return_circuit def get_compiled_circuits( - self, circuits: Sequence[Circuit], optimisation_level: int = 2 + self, circuits: Sequence[Circuit], optimisation_level: int = 2, **kwargs ) -> List[Circuit]: """Compile a sequence of circuits with :py:meth:`default_compilation_pass` and return the list of compiled circuits (does not act in place). @@ -204,6 +204,8 @@ def get_compiled_circuits( backend, and running the :py:meth:`verify` method on each in turn with your circuit. + Valid kwargs are backend specific. + :param circuits: The circuits to compile. :type circuit: Sequence[Circuit] :param optimisation_level: The level of optimisation to perform during @@ -213,7 +215,9 @@ def get_compiled_circuits( :return: Compiled circuits. :rtype: List[Circuit] """ - return [self.get_compiled_circuit(c, optimisation_level) for c in circuits] + return [ + self.get_compiled_circuit(c, optimisation_level, kwargs) for c in circuits + ] @property @abstractmethod @@ -265,7 +269,6 @@ def process_circuits( valid_check: bool = True, **kwargs: KwargTypes, ) -> List[ResultHandle]: - """ Submit circuits to the backend for running. The results will be stored in the backend's result cache to be retrieved by the corresponding