Skip to content

Commit

Permalink
fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Jul 29, 2024
1 parent ea9e2af commit b281730
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pyquil/quilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ def left(self) -> MemoryReference:
@left.setter
def left(self, left: MemoryReference) -> None:
quil_rs.Arithmetic.destination.__set__( # type: ignore[attr-defined]
self, quil_rs.ArithmeticOperand.from_memory_reference(left._to_rs_memory_reference())
self, left._to_rs_memory_reference()
)

@property
Expand Down Expand Up @@ -1536,7 +1536,7 @@ def right(self) -> Union[MemoryReference, int, float]:

@right.setter
def right(self, right: MemoryReference) -> None:
quil_rs.Comparison.rhs.__set__(self, right._to_rs_memory_reference()) # type: ignore
quil_rs.Comparison.rhs.__set__(self, quil_rs.ComparisonOperand(right._to_rs_memory_reference())) # type: ignore

def out(self) -> str:
"""Return the instruction as a valid Quil string."""
Expand Down
12 changes: 12 additions & 0 deletions test/unit/__snapshots__/test_quilbase.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
# name: TestArithmeticBinaryOp.test_out[SUB-left1-1]
'SUB b[1] 1'
# ---
# name: TestArithmeticBinaryOp.test_pickle[ADD-left0-right0]
Arithmetic { operator: Add, destination: MemoryReference { name: "a", index: 0 }, source: MemoryReference(MemoryReference { name: "b", index: 0 }) }
# ---
# name: TestArithmeticBinaryOp.test_pickle[DIV-left3-4.2]
Arithmetic { operator: Divide, destination: MemoryReference { name: "c", index: 2 }, source: LiteralReal(4.2) }
# ---
# name: TestArithmeticBinaryOp.test_pickle[MUL-left2-1.0]
Arithmetic { operator: Multiply, destination: MemoryReference { name: "c", index: 2 }, source: LiteralInteger(1) }
# ---
# name: TestArithmeticBinaryOp.test_pickle[SUB-left1-1]
Arithmetic { operator: Subtract, destination: MemoryReference { name: "b", index: 1 }, source: LiteralInteger(1) }
# ---
# name: TestCapture.test_out[Blocking]
'CAPTURE 123 q "FRAMEX" WAVEFORMY ro[0]'
# ---
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_quilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ def test_convert(self, comparison: ClassicalComparison):

def test_pickle(self, comparison: ClassicalComparison):
pickled = pickle.dumps(comparison)
unpickled = pickle.loads(comparison)
unpickled = pickle.loads(pickled)
assert unpickled == comparison


Expand Down Expand Up @@ -1719,10 +1719,10 @@ def test_convert(self, arithmetic: UnaryClassicalInstruction):
rs_classical_arithmetic = _convert_to_rs_instruction(arithmetic)
assert arithmetic == _convert_to_py_instruction(rs_classical_arithmetic)

def test_pickle(self, arithmetic: UnaryClassicalInstruction):
def test_pickle(self, arithmetic: UnaryClassicalInstruction, snapshot: SnapshotAssertion):
pickled = pickle.dumps(arithmetic)
unpickled = pickle.loads(pickled)
assert unpickled == arithmetic
assert unpickled == snapshot


@pytest.mark.parametrize(
Expand Down

0 comments on commit b281730

Please sign in to comment.