From 6f80192d31d256c1bb77f13d4d675a621bbc9969 Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Wed, 24 Apr 2019 13:08:04 +0200 Subject: [PATCH] Raise ValueError ourselves instead of relying on sympy.Max --- qupulse/pulses/table_pulse_template.py | 4 ++++ tests/pulses/table_pulse_template_tests.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qupulse/pulses/table_pulse_template.py b/qupulse/pulses/table_pulse_template.py index 1f934b787..2307b87ed 100644 --- a/qupulse/pulses/table_pulse_template.py +++ b/qupulse/pulses/table_pulse_template.py @@ -95,6 +95,10 @@ def __init__(self, entries: Dict[ChannelID, Sequence[EntryInInit]], AtomicPulseTemplate.__init__(self, identifier=identifier, measurements=measurements) ParameterConstrainer.__init__(self, parameter_constraints=parameter_constraints) + if not entries: + raise ValueError("Cannot construct an empty TablePulseTemplate (no entries given). There is currently no " + "specific reason for this. Please submit an issue if you need this 'feature'.") + self._entries = dict((ch, list()) for ch in entries.keys()) for channel, channel_entries in entries.items(): if len(channel_entries) == 0: diff --git a/tests/pulses/table_pulse_template_tests.py b/tests/pulses/table_pulse_template_tests.py index 1bd80b5a1..23acfa189 100644 --- a/tests/pulses/table_pulse_template_tests.py +++ b/tests/pulses/table_pulse_template_tests.py @@ -224,7 +224,7 @@ def test_get_entries_auto_insert(self) -> None: def test_empty_instantiated(self) -> None: with self.assertRaises(TypeError): TablePulseTemplate() - with self.assertRaises(ValueError): + with self.assertRaisesRegex(ValueError, 'empty TablePulseTemplate'): TablePulseTemplate(entries=dict()) def test_get_entries_instantiated_two_equal_entries(self) -> None: