def test_advanced_sequence_exceptions(self): temp_properties = self.instr_props.copy() temp_properties['max_seq_len'] = 5 program = Loop(children=[ Loop(waveform=DummyWaveform(defined_channels={'A'}, duration=1), repetition_count=1) for _ in range(temp_properties['max_seq_len'] + 1) ], repetition_count=2) with self.assertRaises(TaborException): TaborProgram(program.copy_tree_structure(), channels=(None, 'A'), markers=(None, None), device_properties=temp_properties, **self.program_entry_kwargs) temp_properties['min_seq_len'] = 100 temp_properties['max_seq_len'] = 120 with self.assertRaises(TaborException) as exception: TaborProgram(program.copy_tree_structure(), channels=(None, 'A'), markers=(None, None), device_properties=temp_properties, **self.program_entry_kwargs) self.assertEqual( str(exception.exception), 'The algorithm is not smart enough ' 'to make this sequence table longer') program = Loop(children=[ Loop(children=[ Loop(waveform=DummyWaveform(defined_channels={'A'}, duration=1)), Loop( waveform=DummyWaveform(defined_channels={'A'}, duration=1)) ]), Loop(children=[ Loop(waveform=DummyWaveform(defined_channels={'A'}, duration=1)), Loop( waveform=DummyWaveform(defined_channels={'A'}, duration=1)) ]) ]) with self.assertRaises(TaborException) as exception: TaborProgram(program.copy_tree_structure(), channels=(None, 'A'), markers=(None, None), device_properties=temp_properties, **self.program_entry_kwargs) self.assertEqual( str(exception.exception), 'The algorithm is not smart enough ' 'to make this sequence table longer')
def __init__(self, program: Loop, channels: Sequence[ChannelID], markers: Sequence[Tuple[ChannelID, ChannelID]], sample_rate: TimeType, amplitudes: Sequence[float], voltage_transformations: Sequence[Callable], offsets: Sequence[float] = None): assert len(channels) == len(markers) and all(len(marker) == 2 for marker in markers),\ "Driver can currently only handle awgs wth two markers per channel" assert len(channels) == len(amplitudes) self._program = program.copy_tree_structure() self._sample_rate = sample_rate self._amplitudes = tuple(amplitudes) self._offsets = tuple(offsets) if offsets is not None else None self._channels = tuple(channels) self._markers = tuple(markers) self._voltage_transformations = tuple(voltage_transformations) self._sequencing_elements = None self._waveforms = None make_compatible(self._program, 250, 1, sample_rate / 10**9) self._program.flatten_and_balance(1) self._sequencing_elements, self._waveforms = parse_program(program=self._program, channels=self.channels, markers=self.markers, sample_rate=self._sample_rate, amplitudes=self._amplitudes, voltage_transformations=self._voltage_transformations, offsets=self._offsets)