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

V4 - fix: Program#calibrate now returns the original instruction if there was no match #1646

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyquil/quil.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ def calibrate(
_convert_to_rs_instructions(previously_calibrated_instructions),
)

return _convert_to_py_instructions(calibrated_instructions)
return [instruction] if not calibrated_instructions else _convert_to_py_instructions(calibrated_instructions)

@deprecated(
version="4.0",
Expand Down
6 changes: 6 additions & 0 deletions test/unit/test_quilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ def test_program_calibrate(program_input, gate, program_output):
assert Program(calibrated).out() == program_output.out()


def test_program_calibrate_no_match():
program = Program()
instruction = Gate("RX", [np.pi], [Qubit(0)])
assert program.calibrate(instruction) == [instruction]


@pytest.mark.parametrize(
"program_text",
(
Expand Down
Loading