Skip to content

Commit

Permalink
fix: Program#out(calibrations=False) will not expand matching calibra…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
MarquessV committed Mar 26, 2024
1 parent feaf775 commit f6b3179
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pyquil/api/_wavefunction_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)
from pyquil.gates import MOVE
from pyquil.paulis import PauliSum, PauliTerm
from pyquil.quil import Program, percolate_declares
from pyquil.quil import Program
from pyquil.quilatom import MemoryReference
from pyquil.wavefunction import Wavefunction

Expand Down Expand Up @@ -93,6 +93,7 @@ def wavefunction(self, quil_program: Program, memory_map: Optional[MemoryMap] =
if memory_map is not None:
quil_program = self.augment_program_with_memory_values(quil_program, memory_map)

print(quil_program.out(calibrations=False))
request = qvm.api.WavefunctionRequest(
quil_program.out(calibrations=False),
self.measurement_noise,
Expand Down Expand Up @@ -230,4 +231,4 @@ def augment_program_with_memory_values(

p += quil_program

return percolate_declares(p)
return p
2 changes: 1 addition & 1 deletion pyquil/quil.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ def out(self, *, calibrations: Optional[bool] = True) -> str:
if calibrations:
return self._program.to_quil()
else:
return self._program.into_simplified().to_quil()
return self.remove_quil_t_instructions().out()

@deprecated(
version="4.0",
Expand Down
22 changes: 22 additions & 0 deletions test/unit/test_quil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,3 +1163,25 @@ def test_cached_frames():
p.inst(frames[1])
program_frames = p.frames
assert program_frames == {frames[0].frame: frames[0], frames[1].frame: frames[1]}


def test_out_without_calibrations():
quilt_program = Program(
"""
DEFCAL J 0:
RX(1.5707963267948966) 0
DEFCAL MEASURE 0 addr:
FENCE 0
"""
)
quil_program = Program(
"""
DECLARE ro BIT[1]
J 0
MEASURE 0 ro
"""
)

combined_program = quilt_program + quil_program

assert combined_program.out(calibrations=False) == quil_program.out()

0 comments on commit f6b3179

Please sign in to comment.