Skip to content

Commit

Permalink
fix: Program#calibrate now returns the original instruction if there …
Browse files Browse the repository at this point in the history
…was no match (#1646)

fix: Program#calibrate returns the input instruction if there was no
match
  • Loading branch information
MarquessV authored Sep 7, 2023
1 parent a965a35 commit 9f8a105
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 9f8a105

Please sign in to comment.