-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add kwargs to arguments for Backend.get_compiled_circuit #962
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f32d87
Update backend.py
sjdilkes bb2e2b6
Update backend.py
sjdilkes cda7058
Update changelog.rst
sjdilkes d80c65f
Fix typos, add **
sjdilkes 68d1fae
Update tket_sim_backend.py
sjdilkes 2d4fc4f
Set **kwargs type to KwargTypes where required
sjdilkes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
] | ||||||
|
||||||
@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 | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done