def test_gen_filled_waveform_stepwise_acquire(self): """Test gen_filled_waveform_stepwise with acquire instruction.""" acquire = pulse.Acquire( duration=4, channel=pulse.AcquireChannel(0), mem_slot=pulse.MemorySlot(0), discriminator=pulse.Discriminator(name="test_discr"), name="acquire", ) inst_data = create_instruction(acquire, 0, 7e9, 5, 0.1) objs = waveform.gen_filled_waveform_stepwise(inst_data, formatter=self.formatter, device=self.device) # imaginary part is empty and not returned self.assertEqual(len(objs), 1) # type check self.assertEqual(type(objs[0]), drawings.LineData) y_ref = np.array([1, 1]) # data check - data is compressed self.assertListEqual(objs[0].channels, [pulse.AcquireChannel(0)]) self.assertListEqual(list(objs[0].xvals), [5, 9]) np.testing.assert_array_almost_equal(objs[0].yvals, y_ref) # meta data check ref_meta = { "memory slot": "m0", "register slot": "N/A", "discriminator": "test_discr", "kernel": "N/A", "duration (cycle time)": 4, "duration (sec)": 0.4, "t0 (cycle time)": 5, "t0 (sec)": 0.5, "phase": 0, "frequency": 7e9, "qubit": 0, "name": "acquire", "data": "real", } self.assertDictEqual(objs[0].meta, ref_meta) # style check ref_style = { "alpha": self.formatter["alpha.fill_waveform"], "zorder": self.formatter["layer.fill_waveform"], "linewidth": self.formatter["line_width.fill_waveform"], "linestyle": self.formatter["line_style.fill_waveform"], "color": self.formatter["color.waveforms"]["A"][0], } self.assertDictEqual(objs[0].styles, ref_style)
def test_gen_filled_waveform_stepwise_acquire(self): """Test gen_filled_waveform_stepwise with acquire instruction.""" acquire = pulse.Acquire( duration=4, channel=pulse.AcquireChannel(0), mem_slot=pulse.MemorySlot(0), discriminator=pulse.Discriminator(name='test_discr'), name='acquire') inst_data = create_instruction(acquire, 0, 7e9, 5, 0.1) objs = waveform.gen_filled_waveform_stepwise(inst_data, formatter=self.formatter, device=self.device) # imaginary part is empty and not returned self.assertEqual(len(objs), 1) # type check self.assertEqual(type(objs[0]), drawings.LineData) y_ref = np.array([1, 1]) # data check - data is compressed self.assertListEqual(objs[0].channels, [pulse.AcquireChannel(0)]) self.assertListEqual(list(objs[0].xvals), [5, 9]) np.testing.assert_array_almost_equal(objs[0].yvals, y_ref) # meta data check ref_meta = { 'memory slot': 'm0', 'register slot': 'N/A', 'discriminator': 'test_discr', 'kernel': 'N/A', 'duration (cycle time)': 4, 'duration (sec)': 0.4, 't0 (cycle time)': 5, 't0 (sec)': 0.5, 'phase': 0, 'frequency': 7e9, 'qubit': 0, 'name': 'acquire', 'data': 'real' } self.assertDictEqual(objs[0].meta, ref_meta) # style check ref_style = { 'alpha': self.formatter['alpha.fill_waveform'], 'zorder': self.formatter['layer.fill_waveform'], 'linewidth': self.formatter['line_width.fill_waveform'], 'linestyle': self.formatter['line_style.fill_waveform'], 'color': self.formatter['color.waveforms']['A'][0] } self.assertDictEqual(objs[0].styles, ref_style)
def test_gen_filled_waveform_stepwise_acquire(self): """Test gen_filled_waveform_stepwise with acquire instruction.""" acquire = pulse.Acquire( duration=4, channel=pulse.AcquireChannel(0), mem_slot=pulse.MemorySlot(0), discriminator=pulse.Discriminator(name='test_discr'), name='acquire') inst_data = self.create_instruction(acquire, 0, 7e9, 5, 0.1) objs = generators.gen_filled_waveform_stepwise(inst_data) # imaginary part is empty and not returned self.assertEqual(len(objs), 1) # type check self.assertEqual(type(objs[0]), drawing_objects.FilledAreaData) y1_ref = np.array([1, 1, 1, 1, 1, 1, 1, 1]) y2_ref = np.array([0, 0, 0, 0, 0, 0, 0, 0]) # data check self.assertEqual(objs[0].channel, pulse.AcquireChannel(0)) self.assertListEqual(list(objs[0].x), [5, 6, 6, 7, 7, 8, 8, 9]) np.testing.assert_array_almost_equal(objs[0].y1, y1_ref) np.testing.assert_array_almost_equal(objs[0].y2, y2_ref) # meta data check ref_meta = { 'memory slot': 'm0', 'register slot': 'N/A', 'discriminator': 'test_discr', 'kernel': 'N/A', 'duration (cycle time)': 4, 'duration (sec)': 0.4, 't0 (cycle time)': 5, 't0 (sec)': 0.5, 'phase': 0, 'frequency': 7e9, 'name': 'acquire', 'data': 'real' } self.assertDictEqual(objs[0].meta, ref_meta) # style check ref_style = { 'alpha': self.style['formatter.alpha.fill_waveform'], 'zorder': self.style['formatter.layer.fill_waveform'], 'linewidth': self.style['formatter.line_width.fill_waveform'], 'linestyle': self.style['formatter.line_style.fill_waveform'], 'color': self.style['formatter.color.fill_waveform_a'][0] } self.assertDictEqual(objs[0].styles, ref_style)