def test_gen_sched_gate_with_finite_duration(self): """Test test_gen_sched_gate generator with finite duration gate.""" drawing_obj = generators.gen_sched_gate(self.u3, self.formatter)[0] self.assertEqual(drawing_obj.data_type, str(types.BoxType.SCHED_GATE.value)) self.assertListEqual(list(drawing_obj.xvals), [100, 120]) self.assertListEqual( list(drawing_obj.yvals), [ -0.5 * self.formatter["box_height.gate"], 0.5 * self.formatter["box_height.gate"] ], ) self.assertListEqual(drawing_obj.bits, [self.qubit]) ref_meta = { "name": "u3", "label": "n/a", "bits": str(self.qubit.register.name), "t0": 100, "duration": 20, "unitary": "[[1.+0.j 0.-0.j]\n [0.+0.j 1.+0.j]]", "parameters": "0, 0, 0", } self.assertDictEqual(ref_meta, drawing_obj.meta) ref_styles = { "zorder": self.formatter["layer.gate"], "facecolor": self.formatter["color.gates"]["u3"], "alpha": self.formatter["alpha.gate"], "linewidth": self.formatter["line_width.gate"], } self.assertDictEqual(ref_styles, drawing_obj.styles)
def test_gen_sched_gate_with_finite_duration(self): """Test test_gen_sched_gate generator with finite duration gate.""" drawing_obj = generators.gen_sched_gate(self.u3, self.formatter)[0] self.assertEqual(drawing_obj.data_type, str(types.BoxType.SCHED_GATE.value)) self.assertListEqual(list(drawing_obj.xvals), [100, 120]) self.assertListEqual(list(drawing_obj.yvals), [ -0.5 * self.formatter['box_height.gate'], 0.5 * self.formatter['box_height.gate'] ]) self.assertListEqual(drawing_obj.bits, [self.qubit]) ref_meta = { 'name': 'u3', 'label': 'n/a', 'bits': str(self.qubit.register.name), 't0': 100, 'duration': 20, 'unitary': '[[1.+0.j 0.-0.j]\n [0.+0.j 1.+0.j]]', 'parameters': '0, 0, 0' } self.assertDictEqual(ref_meta, drawing_obj.meta) ref_styles = { 'zorder': self.formatter['layer.gate'], 'facecolor': self.formatter['color.gates']['u3'], 'alpha': self.formatter['alpha.gate'], 'linewidth': self.formatter['line_width.gate'] } self.assertDictEqual(ref_styles, drawing_obj.styles)
def test_gen_sched_gate_with_zero_duration(self): """Test test_gen_sched_gate generator with zero duration gate.""" drawing_obj = generators.gen_sched_gate(self.u1, self.formatter)[0] self.assertEqual(drawing_obj.data_type, str(types.SymbolType.FRAME.value)) self.assertListEqual(list(drawing_obj.xvals), [100]) self.assertListEqual(list(drawing_obj.yvals), [0]) self.assertListEqual(drawing_obj.bits, [self.qubit]) self.assertEqual(drawing_obj.text, self.formatter["unicode_symbol.frame_change"]) self.assertEqual(drawing_obj.latex, self.formatter["latex_symbol.frame_change"]) ref_styles = { "zorder": self.formatter["layer.frame_change"], "color": self.formatter["color.gates"]["u1"], "size": self.formatter["text_size.frame_change"], "va": "center", "ha": "center", } self.assertDictEqual(ref_styles, drawing_obj.styles)
def test_gen_sched_gate_with_zero_duration(self): """Test test_gen_sched_gate generator with zero duration gate.""" drawing_obj = generators.gen_sched_gate(self.u1, self.formatter)[0] self.assertEqual(drawing_obj.data_type, str(types.SymbolType.FRAME.value)) self.assertListEqual(list(drawing_obj.xvals), [100]) self.assertListEqual(list(drawing_obj.yvals), [0]) self.assertListEqual(drawing_obj.bits, [self.qubit]) self.assertEqual(drawing_obj.text, self.formatter['unicode_symbol.frame_change']) self.assertEqual(drawing_obj.latex, self.formatter['latex_symbol.frame_change']) ref_styles = { 'zorder': self.formatter['layer.frame_change'], 'color': self.formatter['color.gates']['u1'], 'size': self.formatter['text_size.frame_change'], 'va': 'center', 'ha': 'center' } self.assertDictEqual(ref_styles, drawing_obj.styles)
def test_gen_sched_gate_with_delay(self): """Test test_gen_sched_gate generator with delay.""" drawing_obj = generators.gen_sched_gate(self.delay, self.formatter)[0] self.assertEqual(drawing_obj.data_type, str(types.BoxType.DELAY.value))