-
Notifications
You must be signed in to change notification settings - Fork 347
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 deprecated property to DefFrame for CHANNEL-DELAY attribute #1729
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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 |
---|---|---|
|
@@ -474,10 +474,10 @@ def test_copy(self, measurement: Measurement): | |
|
||
|
||
@pytest.mark.parametrize( | ||
("frame", "direction", "initial_frequency", "hardware_object", "sample_rate", "center_frequency"), | ||
("frame", "direction", "initial_frequency", "hardware_object", "sample_rate", "center_frequency", "channel_delay"), | ||
[ | ||
(Frame([Qubit(0)], "frame"), None, None, None, None, None), | ||
(Frame([Qubit(1)], "frame"), "direction", 1.39, "hardware_object", 44.1, 440.0), | ||
(Frame([Qubit(0)], "frame"), None, None, None, None, None, None), | ||
(Frame([Qubit(1)], "frame"), "direction", 1.39, "hardware_object", 44.1, 440.0, 0.0), | ||
], | ||
ids=("Frame-Only", "With-Optionals"), | ||
) | ||
|
@@ -491,13 +491,22 @@ def def_frame( | |
hardware_object: Optional[str], | ||
sample_rate: Optional[float], | ||
center_frequency: Optional[float], | ||
): | ||
optional_args = [ | ||
arg | ||
for arg in [direction, initial_frequency, hardware_object, sample_rate, center_frequency] | ||
if arg is not None | ||
] | ||
return DefFrame(frame, *optional_args) | ||
channel_delay: Optional[float], | ||
) -> DefFrame: | ||
optional_args = {k: v | ||
for k, v in locals().items() | ||
if k not in["self", "frame"] and v is not None} | ||
# optional_args = [ | ||
# arg | ||
# for arg in [direction, | ||
# initial_frequency, | ||
# hardware_object, | ||
# sample_rate, | ||
# center_frequency, | ||
# channel_delay]: | ||
# if arg is not None | ||
# ] | ||
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. Do we still need these comments? 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. I've removed them! |
||
return DefFrame(frame, **optional_args) | ||
|
||
def test_out(self, def_frame: DefFrame, snapshot: SnapshotAssertion): | ||
# The ordering of attributes isn't stable and can be printed in different orders across calls. | ||
|
@@ -509,6 +518,7 @@ def test_out(self, def_frame: DefFrame, snapshot: SnapshotAssertion): | |
|
||
def test_str(self, def_frame: DefFrame, snapshot: SnapshotAssertion): | ||
quil_lines = str(def_frame).splitlines() | ||
print(quil_lines) | ||
assert quil_lines[0] == snapshot | ||
assert set(quil_lines[1:]) == snapshot | ||
|
||
|
@@ -518,51 +528,40 @@ def test_frame(self, def_frame: DefFrame, frame: Frame): | |
assert def_frame.frame == Frame([Qubit(123)], "new_frame") | ||
|
||
def test_direction(self, def_frame: DefFrame, direction: Optional[str]): | ||
assert def_frame.direction == direction is None if not direction else def_frame["DIRECTION"] | ||
assert def_frame.direction == direction | ||
def_frame.direction = "tx" | ||
assert def_frame.direction == "tx" | ||
|
||
def test_initial_frequency(self, def_frame: DefFrame, initial_frequency: Optional[float]): | ||
assert ( | ||
def_frame.initial_frequency == initial_frequency is None | ||
if not initial_frequency | ||
else def_frame["INITIAL-FREQUENCY"] | ||
) | ||
assert def_frame.initial_frequency == initial_frequency | ||
def_frame.initial_frequency = 3.14 | ||
assert def_frame.initial_frequency == 3.14 | ||
|
||
def test_hardware_object(self, def_frame: DefFrame, hardware_object: Optional[str]): | ||
assert ( | ||
def_frame.hardware_object == hardware_object is None | ||
if not hardware_object | ||
else def_frame["HARDWARE-OBJECT"] | ||
) | ||
assert def_frame.hardware_object == hardware_object | ||
def_frame.hardware_object = "bfg" | ||
assert def_frame.hardware_object == "bfg" | ||
|
||
def test_hardware_object_json(self, def_frame: DefFrame, hardware_object: Optional[str]): | ||
assert ( | ||
def_frame.hardware_object == hardware_object is None | ||
if not hardware_object | ||
else def_frame["HARDWARE-OBJECT"] | ||
) | ||
assert def_frame.hardware_object == hardware_object | ||
def_frame.hardware_object = '{"string": "str", "int": 1, "float": 3.14}' | ||
assert def_frame.hardware_object == '{"string": "str", "int": 1, "float": 3.14}' | ||
|
||
def test_sample_rate(self, def_frame: DefFrame, sample_rate: Optional[float]): | ||
assert def_frame.sample_rate == sample_rate is None if not sample_rate else def_frame["SAMPLE-RATE"] | ||
assert def_frame.sample_rate == sample_rate | ||
def_frame.sample_rate = 96.0 | ||
assert def_frame.sample_rate == 96.0 | ||
|
||
def test_center_frequency(self, def_frame: DefFrame, center_frequency: Optional[float]): | ||
assert ( | ||
def_frame.center_frequency == center_frequency is None | ||
if not center_frequency | ||
else def_frame.center_frequency | ||
) | ||
assert def_frame.center_frequency == center_frequency | ||
def_frame.center_frequency = 432.0 | ||
assert def_frame.center_frequency == 432.0 | ||
|
||
def test_channel_delay(self, def_frame: DefFrame, channel_delay: Optional[float]): | ||
assert def_frame.channel_delay == channel_delay | ||
def_frame.channel_delay = 571.0 | ||
assert def_frame.channel_delay == 571.0 | ||
|
||
def test_copy(self, def_frame: DefFrame): | ||
assert isinstance(copy.copy(def_frame), DefFrame) | ||
assert isinstance(copy.deepcopy(def_frame), DefFrame) | ||
|
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.
this is probably more python magic than we want or need
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.
I disenchanted it.