Skip to content

Commit

Permalink
Update test_platform.py
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillermoAbadLopez committed Dec 31, 2024
1 parent bddc5a8 commit 7fb7339
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/platform/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ def test_session_with_multiple_exceptions_in_cleanup(self):
platform.turn_off_instruments.assert_called_once()
platform.disconnect.assert_called_once()

def test_compile_circuit(self, platform: Platform):
@pytest.mark.parametrize("optimize", [True, False])
def test_compile_circuit(self, optimize: bool, platform: Platform):
"""Test the compilation of a qibo Circuit."""

circuit = Circuit(3)
Expand All @@ -536,7 +537,7 @@ def test_compile_circuit(self, platform: Platform):
circuit.add(gates.Y(1))
circuit.add(gates.M(0, 1, 2))

self._compile_and_assert(platform, circuit, 6)
self._compile_and_assert(platform, circuit, 6, optimize=optimize)

def test_compile_circuit_raises_error_if_digital_settings_missing(self, platform: Platform):
"""Test the compilation of a qibo Circuit."""
Expand Down Expand Up @@ -566,10 +567,11 @@ def test_compile_pulse_schedule(self, platform: Platform):

self._compile_and_assert(platform, pulse_schedule, 2)

def _compile_and_assert(self, platform: Platform, program: Circuit | PulseSchedule, len_sequences: int):
sequences, _ = platform.compile(program=program, num_avg=1000, repetition_duration=200_000, num_bins=1)
def _compile_and_assert(self, platform: Platform, program: Circuit | PulseSchedule, len_sequences: int, optimize:bool = False):
sequences, _ = platform.compile(program=program, num_avg=1000, repetition_duration=200_000, num_bins=1, transpile_config={"optimize": optimize})
assert isinstance(sequences, dict)
assert len(sequences) == len_sequences
if not optimize:
assert len(sequences) == len_sequences
for alias, sequences_list in sequences.items():
assert alias in {bus.alias for bus in platform.buses}
assert isinstance(sequences_list, list)
Expand Down

0 comments on commit 7fb7339

Please sign in to comment.