def test_box_data_with_abstract_coordinate(self): """Test for BoxData with abstract coordinate.""" xs = [types.AbstractCoordinate.LEFT, types.AbstractCoordinate.RIGHT] ys = [types.AbstractCoordinate.BOTTOM, types.AbstractCoordinate.TOP] data1 = drawings.BoxData( data_type="test", xvals=xs, yvals=ys, channels=self.ch_d0, meta=self.meta1, ignore_scaling=True, styles=self.style1, ) data2 = drawings.BoxData( data_type="test", xvals=xs, yvals=ys, channels=self.ch_d1, meta=self.meta2, ignore_scaling=True, styles=self.style2, ) self.assertEqual(data1, data2)
def test_box_data(self): """Test for BoxData.""" xs = [0, 1] ys = [-1, 1] data1 = drawings.BoxData( data_type="test", xvals=xs, yvals=ys, channels=self.ch_d0, meta=self.meta1, ignore_scaling=True, styles=self.style1, ) data2 = drawings.BoxData( data_type="test", xvals=xs, yvals=ys, channels=self.ch_d1, meta=self.meta2, ignore_scaling=True, styles=self.style2, ) self.assertEqual(data1, data2)
def _draw_opaque_waveform( init_time: int, duration: int, pulse_shape: str, pnames: List[str], meta: Dict[str, Any], channel: pulse.channels.PulseChannel, formatter: Dict[str, Any], ) -> List[Union[drawings.LineData, drawings.BoxData, drawings.TextData]]: """A private function that generates drawings of stepwise pulse lines. Args: init_time: Time when the opaque waveform starts. duration: Duration of opaque waveform. This can be None or ParameterExpression. pulse_shape: String that represents pulse shape. pnames: List of parameter names. meta: Metadata dictionary of the waveform. channel: Channel associated with the waveform to draw. formatter: Dictionary of stylesheet settings. Returns: List of drawings. """ fill_objs = [] fc, ec = formatter["color.opaque_shape"] # setup style options box_style = { "zorder": formatter["layer.fill_waveform"], "alpha": formatter["alpha.opaque_shape"], "linewidth": formatter["line_width.opaque_shape"], "linestyle": formatter["line_style.opaque_shape"], "facecolor": fc, "edgecolor": ec, } if duration is None or isinstance(duration, circuit.ParameterExpression): duration = formatter["box_width.opaque_shape"] box_obj = drawings.BoxData( data_type=types.WaveformType.OPAQUE, channels=channel, xvals=[init_time, init_time + duration], yvals=[ -0.5 * formatter["box_height.opaque_shape"], 0.5 * formatter["box_height.opaque_shape"], ], meta=meta, ignore_scaling=True, styles=box_style, ) fill_objs.append(box_obj) # parameter name func_repr = "{func}({params})".format(func=pulse_shape, params=", ".join(pnames)) text_style = { "zorder": formatter["layer.annotate"], "color": formatter["color.annotate"], "size": formatter["text_size.annotate"], "va": "bottom", "ha": "center", } text_obj = drawings.TextData( data_type=types.LabelType.OPAQUE_BOXTEXT, channels=channel, xvals=[init_time + 0.5 * duration], yvals=[0.5 * formatter["box_height.opaque_shape"]], text=func_repr, ignore_scaling=True, styles=text_style, ) fill_objs.append(text_obj) return fill_objs