-
Notifications
You must be signed in to change notification settings - Fork 4
72 handle measure instructions and bit registers #144
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
Merged
elenbaasc
merged 8 commits into
develop
from
72-handle-measure-instructions-and-bit-registers
Apr 18, 2024
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
23affa8
Initialize measurement logic
juanboschero 398cc81
Configure tests and configure Measurement class
juanboschero d171c71
Configure writer to output Measure objects
juanboschero 4987020
Remove measurment alias, remove classical bit semantics, and apply bl…
juanboschero 2ce437f
Remove measurment alias, remove classical bit semantics, and apply bl…
juanboschero a1cfd4a
Revert quirrel_ir_from_string
juanboschero c609422
Revert changes to ANTLR parser (to be deprecated).
elenbaasc 46984b8
Resolve issues in poetry.lock
elenbaasc 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from opensquirrel.squirrel_ir import * | ||
|
||
|
||
@named_measurement | ||
def measure(q: Qubit) -> Measure: | ||
return Measure(qubit=q, axis=(0, 0, 1)) | ||
|
||
|
||
@named_measurement | ||
def measure_z(q: Qubit) -> Measure: | ||
return Measure(qubit=q, axis=(0, 0, 1)) | ||
|
||
|
||
@named_measurement | ||
def measure_y(q: Qubit) -> Measure: | ||
return Measure(qubit=q, axis=(0, 1, 0)) | ||
|
||
|
||
@named_measurement | ||
def measure_x(q: Qubit) -> Measure: | ||
return Measure(qubit=q, axis=(1, 0, 0)) | ||
juanboschero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
default_measurement_set = [measure_x, measure_y, measure_z, measure] | ||
default_measurement_aliases = { | ||
"measure_x": measure_x, | ||
"measure_y": measure_y, | ||
"measure_z": measure_z, | ||
"measure": measure, | ||
} | ||
juanboschero marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class OperationLibrary: | ||
juanboschero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pass | ||
|
||
|
||
class GateLibrary(OperationLibrary): | ||
def __init__(self, gate_set, gate_aliases): | ||
self.gate_set = gate_set | ||
self.gate_aliases = gate_aliases | ||
|
||
def get_gate_f(self, gate_name: str): | ||
try: | ||
generator_f = next(f for f in self.gate_set if f.__name__ == gate_name) | ||
except StopIteration: | ||
if gate_name not in self.gate_aliases: | ||
raise Exception(f"Unknown gate `{gate_name}`") | ||
generator_f = self.gate_aliases[gate_name] | ||
return generator_f | ||
|
||
|
||
class MeasurementLibrary(OperationLibrary): | ||
def __init__(self, measurement_set, measurement_aliases): | ||
self.measurement_set = measurement_set | ||
self.measurement_aliases = measurement_aliases | ||
|
||
def get_measurement_f(self, measurement_name: str): | ||
try: | ||
generator_f = next(f for f in self.measurement_set if f.__name__ == measurement_name) | ||
except StopIteration: | ||
if measurement_name not in self.measurement_aliases: | ||
raise Exception(f"Unknown measurement `{measurement_name}`") | ||
generator_f = self.measurement_aliases[measurement_name] | ||
return generator_f |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.