Skip to content

Commit

Permalink
fix: Arithmetic instructions will not raise an error when used in Pro…
Browse files Browse the repository at this point in the history
…grams (#1723)
  • Loading branch information
MarquessV authored Jan 16, 2024
1 parent deafd5d commit a86d028
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyquil/quilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def _convert_to_py_instruction(instr: Any) -> AbstractInstruction:
if instr.is_wait():
return Wait()
return _convert_to_py_instruction(instr.inner())
if isinstance(instr, quil_rs.Arithmetic):
return ArithmeticBinaryOp._from_rs_arithmetic(instr)
if isinstance(instr, quil_rs.Capture):
return Capture._from_rs_capture(instr)
if isinstance(instr, quil_rs.Calibration):
Expand Down
7 changes: 7 additions & 0 deletions test/unit/test_quilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,13 @@ def test_copy(self, arithmetic: ArithmeticBinaryOp):
assert isinstance(copy.copy(arithmetic), type(arithmetic))
assert isinstance(copy.deepcopy(arithmetic), type(arithmetic))

def valid_in_program(self, arithmetic):
try:
p = Program(arithmetic)
p[0] == arithmetic
except Exception:
pytest.fail("ArithmeticBinaryOp not valid in Program")


@pytest.mark.parametrize(
("op", "left", "right"),
Expand Down

0 comments on commit a86d028

Please sign in to comment.