Skip to content

Commit

Permalink
update qcs-sdk-python/quil, update test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Apr 17, 2024
1 parent 01fce9b commit 996790b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lark = "^0.11.1"
rpcq = "^3.10.0"
networkx = ">=2.5"
importlib-metadata = { version = ">=3.7.3,<5", python = "<3.8" }
qcs-sdk-python = "0.17.5"
qcs-sdk-python = "0.17.6"
tenacity = "^8.2.2"
types-python-dateutil = "^2.8.19"
types-retry = "^0.9.9"
Expand Down
15 changes: 8 additions & 7 deletions test/unit/test_quil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,16 +1229,17 @@ def test_program_equality():

# Definitions in Quil are "global" in the sense that the order they are defined in the program does should not
# effect equality.
# Note: pyQuil de-duplicates DEFCAL and DEFCAL MEASURE definitions. If that were not the case, then calibration
# order _would_ matter. During expansion, the last calibration to be defined that matches a signature would be
# applied.
def is_global_state_instruction(i: AbstractInstruction) -> bool:
return isinstance(i, (DefFrame, DefCalibration, DefMeasureCalibration, DefWaveform, DefGate))
return isinstance(i, (DefFrame, DefWaveform, DefGate))

# Construct a copy of the program, inserting global instructions in reverse order. Since their order does not matter
# the new program should be equal to the original program.
new_program = program.filter_instructions(lambda i: not is_global_state_instruction(i))
base_program = program.filter_instructions(lambda i: not is_global_state_instruction(i))
global_instructions = program.filter_instructions(lambda i: is_global_state_instruction(i)).get_all_instructions()
new_program += global_instructions[::-1]
global_reversed_program = base_program + global_instructions[::-1]

assert new_program == program
assert global_reversed_program == program

# Program with reversed instructions that aren't "global" should not be equivalent
non_global_reversed_program = Program(base_program.get_all_instructions()[::-1]) + global_instructions
assert non_global_reversed_program != program

0 comments on commit 996790b

Please sign in to comment.