mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
refactor(widget/figure): changed add_plot and add_image to specify what should be content of the widget, instead of widget id
This commit is contained in:
@ -262,7 +262,15 @@ class BECFigure(RPCBase, BECFigureClientMixin):
|
||||
@rpc_call
|
||||
def add_plot(
|
||||
self,
|
||||
widget_id: "str" = None,
|
||||
x_name: "str" = None,
|
||||
y_name: "str" = None,
|
||||
x_entry: "str" = None,
|
||||
y_entry: "str" = None,
|
||||
x: "list | np.ndarray" = None,
|
||||
y: "list | np.ndarray" = None,
|
||||
color: "Optional[str]" = None,
|
||||
label: "Optional[str]" = None,
|
||||
validate: "bool" = True,
|
||||
row: "int" = None,
|
||||
col: "int" = None,
|
||||
config=None,
|
||||
@ -281,17 +289,31 @@ class BECFigure(RPCBase, BECFigureClientMixin):
|
||||
@rpc_call
|
||||
def add_image(
|
||||
self,
|
||||
widget_id: "str" = None,
|
||||
monitor: "str" = None,
|
||||
color_bar: "Literal['simple', 'full']" = "full",
|
||||
color_map: "str" = "magma",
|
||||
data: "np.ndarray" = None,
|
||||
vrange: "tuple[float, float]" = None,
|
||||
row: "int" = None,
|
||||
col: "int" = None,
|
||||
config=None,
|
||||
color_map: "str" = "magma",
|
||||
color_bar: "Literal['simple', 'full']" = "full",
|
||||
vrange: "tuple[float, float]" = None,
|
||||
**axis_kwargs
|
||||
) -> "BECImageShow":
|
||||
"""
|
||||
None
|
||||
Add an image to the figure at the specified position.
|
||||
Args:
|
||||
monitor(str): The name of the monitor to display.
|
||||
color_bar(Literal["simple","full"]): The type of color bar to display.
|
||||
color_map(str): The color map to use for the image.
|
||||
data(np.ndarray): Custom data to display.
|
||||
vrange(tuple[float, float]): The range of values to display.
|
||||
row(int): The row coordinate of the widget in the figure. If not provided, the next empty row will be used.
|
||||
col(int): The column coordinate of the widget in the figure. If not provided, the next empty column will be used.
|
||||
config(dict): Additional configuration for the widget.
|
||||
**axis_kwargs:
|
||||
|
||||
Returns:
|
||||
BECImageShow: The image widget.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
@ -309,7 +331,7 @@ class BECFigure(RPCBase, BECFigureClientMixin):
|
||||
**axis_kwargs
|
||||
) -> "BECWaveform1D":
|
||||
"""
|
||||
Add a 1D waveform plot to the figure.
|
||||
Add a 1D waveform plot to the figure. Always access the first waveform widget in the figure.
|
||||
Args:
|
||||
x_name(str): The name of the device for the x-axis.
|
||||
y_name(str): The name of the device for the y-axis.
|
||||
@ -337,7 +359,7 @@ class BECFigure(RPCBase, BECFigureClientMixin):
|
||||
**axis_kwargs
|
||||
) -> "BECImageShow":
|
||||
"""
|
||||
Add an image to the figure.
|
||||
Add an image to the figure. Always access the first image widget in the figure.
|
||||
Args:
|
||||
monitor(str): The name of the monitor to display.
|
||||
color_bar(Literal["simple","full"]): The type of color bar to display.
|
||||
|
@ -157,7 +157,20 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
|
||||
self._widgets = value
|
||||
|
||||
def add_plot(
|
||||
self, widget_id: str = None, row: int = None, col: int = None, config=None, **axis_kwargs
|
||||
self,
|
||||
x_name: str = None,
|
||||
y_name: str = None,
|
||||
x_entry: str = None,
|
||||
y_entry: str = None,
|
||||
x: list | np.ndarray = None,
|
||||
y: list | np.ndarray = None,
|
||||
color: Optional[str] = None,
|
||||
label: Optional[str] = None,
|
||||
validate: bool = True,
|
||||
row: int = None,
|
||||
col: int = None,
|
||||
config=None,
|
||||
**axis_kwargs,
|
||||
) -> BECWaveform1D:
|
||||
"""
|
||||
Add a Waveform1D plot to the figure at the specified position.
|
||||
@ -168,7 +181,8 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
|
||||
config(dict): Additional configuration for the widget.
|
||||
**axis_kwargs(dict): Additional axis properties to set on the widget after creation.
|
||||
"""
|
||||
return self.add_widget(
|
||||
widget_id = self._generate_unique_widget_id()
|
||||
waveform = self.add_widget(
|
||||
widget_type="Waveform1D",
|
||||
widget_id=widget_id,
|
||||
row=row,
|
||||
@ -177,6 +191,30 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
|
||||
**axis_kwargs,
|
||||
)
|
||||
|
||||
# TODO remove repetition from .plot method
|
||||
|
||||
# User wants to add scan curve
|
||||
if x_name is not None and y_name is not None and x is None and y is None:
|
||||
waveform.add_curve_scan(
|
||||
x_name=x_name,
|
||||
y_name=y_name,
|
||||
x_entry=x_entry,
|
||||
y_entry=y_entry,
|
||||
validate=validate,
|
||||
color=color,
|
||||
label=label,
|
||||
)
|
||||
# User wants to add custom curve
|
||||
elif x is not None and y is not None and x_name is None and y_name is None:
|
||||
waveform.add_curve_custom(
|
||||
x=x,
|
||||
y=y,
|
||||
color=color,
|
||||
label=label,
|
||||
)
|
||||
|
||||
return waveform
|
||||
|
||||
def plot(
|
||||
self,
|
||||
x_name: str = None,
|
||||
@ -191,7 +229,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
|
||||
**axis_kwargs,
|
||||
) -> BECWaveform1D:
|
||||
"""
|
||||
Add a 1D waveform plot to the figure.
|
||||
Add a 1D waveform plot to the figure. Always access the first waveform widget in the figure.
|
||||
Args:
|
||||
x_name(str): The name of the device for the x-axis.
|
||||
y_name(str): The name of the device for the y-axis.
|
||||
@ -249,7 +287,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
|
||||
**axis_kwargs,
|
||||
) -> BECImageShow:
|
||||
"""
|
||||
Add an image to the figure.
|
||||
Add an image to the figure. Always access the first image widget in the figure.
|
||||
Args:
|
||||
monitor(str): The name of the monitor to display.
|
||||
color_bar(Literal["simple","full"]): The type of color bar to display.
|
||||
@ -289,17 +327,35 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
|
||||
|
||||
def add_image(
|
||||
self,
|
||||
widget_id: str = None,
|
||||
monitor: str = None,
|
||||
color_bar: Literal["simple", "full"] = "full",
|
||||
color_map: str = "magma",
|
||||
data: np.ndarray = None,
|
||||
vrange: tuple[float, float] = None,
|
||||
row: int = None,
|
||||
col: int = None,
|
||||
config=None,
|
||||
color_map: str = "magma", # TODO fix passing additional kwargs
|
||||
color_bar: Literal["simple", "full"] = "full",
|
||||
vrange: tuple[float, float] = None,
|
||||
**axis_kwargs,
|
||||
) -> BECImageShow:
|
||||
"""
|
||||
Add an image to the figure at the specified position.
|
||||
Args:
|
||||
monitor(str): The name of the monitor to display.
|
||||
color_bar(Literal["simple","full"]): The type of color bar to display.
|
||||
color_map(str): The color map to use for the image.
|
||||
data(np.ndarray): Custom data to display.
|
||||
vrange(tuple[float, float]): The range of values to display.
|
||||
row(int): The row coordinate of the widget in the figure. If not provided, the next empty row will be used.
|
||||
col(int): The column coordinate of the widget in the figure. If not provided, the next empty column will be used.
|
||||
config(dict): Additional configuration for the widget.
|
||||
**axis_kwargs:
|
||||
|
||||
Returns:
|
||||
BECImageShow: The image widget.
|
||||
"""
|
||||
|
||||
widget_id = self._generate_unique_widget_id()
|
||||
if config is None:
|
||||
widget_id = self._generate_unique_widget_id()
|
||||
config = ImageConfig(
|
||||
widget_class="BECImageShow",
|
||||
gui_id=widget_id,
|
||||
@ -308,7 +364,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
|
||||
color_bar=color_bar,
|
||||
vrange=vrange,
|
||||
)
|
||||
return self.add_widget(
|
||||
image = self.add_widget(
|
||||
widget_type="ImShow",
|
||||
widget_id=widget_id,
|
||||
row=row,
|
||||
@ -316,6 +372,23 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
|
||||
config=config,
|
||||
**axis_kwargs,
|
||||
)
|
||||
# TODO remove repetition from .image method
|
||||
if monitor is not None and data is None:
|
||||
image.add_monitor_image(
|
||||
monitor=monitor, color_map=color_map, vrange=vrange, color_bar=color_bar
|
||||
)
|
||||
elif data is not None and monitor is None:
|
||||
image.add_custom_image(
|
||||
name="custom", data=data, color_map=color_map, vrange=vrange, color_bar=color_bar
|
||||
)
|
||||
elif data is None and monitor is None:
|
||||
# Setting appearance
|
||||
if vrange is not None:
|
||||
image.set_vrange(vmin=vrange[0], vmax=vrange[1])
|
||||
if color_map is not None:
|
||||
image.set_color_map(color_map)
|
||||
|
||||
return image
|
||||
|
||||
def add_widget(
|
||||
self,
|
||||
|
@ -40,33 +40,33 @@ def test_bec_figure_add_remove_plot(bec_figure):
|
||||
|
||||
# Adding 3 widgets - 2 WaveformBase and 1 PlotBase
|
||||
w0 = bec_figure.add_plot()
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w2 = bec_figure.add_widget(widget_id="test_plot", widget_type="PlotBase")
|
||||
w1 = bec_figure.add_plot()
|
||||
w2 = bec_figure.add_widget(widget_type="PlotBase")
|
||||
|
||||
# Check if the widgets were added
|
||||
assert len(bec_figure._widgets) == initial_count + 3
|
||||
assert "widget_1" in bec_figure._widgets
|
||||
assert "test_plot" in bec_figure._widgets
|
||||
assert "test_waveform" in bec_figure._widgets
|
||||
assert "widget_2" in bec_figure._widgets
|
||||
assert "widget_3" in bec_figure._widgets
|
||||
assert bec_figure._widgets["widget_1"].config.widget_class == "BECWaveform1D"
|
||||
assert bec_figure._widgets["test_plot"].config.widget_class == "BECPlotBase"
|
||||
assert bec_figure._widgets["test_waveform"].config.widget_class == "BECWaveform1D"
|
||||
assert bec_figure._widgets["widget_2"].config.widget_class == "BECWaveform1D"
|
||||
assert bec_figure._widgets["widget_3"].config.widget_class == "BECPlotBase"
|
||||
|
||||
# Check accessing positions by the grid in figure
|
||||
assert bec_figure[0, 0] == w0
|
||||
assert bec_figure[1, 0] == w1
|
||||
assert bec_figure[2, 0] == w2
|
||||
|
||||
# Removing 1 widget - PlotBase
|
||||
bec_figure.remove(widget_id="test_plot")
|
||||
# Removing 1 widget
|
||||
bec_figure.remove(widget_id="widget_1")
|
||||
assert len(bec_figure._widgets) == initial_count + 2
|
||||
assert "test_plot" not in bec_figure._widgets
|
||||
assert "test_waveform" in bec_figure._widgets
|
||||
assert bec_figure._widgets["test_waveform"].config.widget_class == "BECWaveform1D"
|
||||
assert "widget_1" not in bec_figure._widgets
|
||||
assert "widget_3" in bec_figure._widgets
|
||||
assert bec_figure._widgets["widget_2"].config.widget_class == "BECWaveform1D"
|
||||
|
||||
|
||||
def test_access_widgets_access_errors(bec_figure):
|
||||
bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
bec_figure.add_plot(row=0, col=0)
|
||||
|
||||
# access widget by non-existent coordinates
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@ -88,26 +88,18 @@ def test_access_widgets_access_errors(bec_figure):
|
||||
|
||||
|
||||
def test_add_plot_to_occupied_position(bec_figure):
|
||||
bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
bec_figure.add_plot(row=0, col=0)
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
bec_figure.add_plot(widget_id="test_waveform_2", row=0, col=0)
|
||||
bec_figure.add_plot(row=0, col=0)
|
||||
assert "Position at row 0 and column 0 is already occupied." in str(excinfo.value)
|
||||
|
||||
|
||||
def test_add_plot_to_occupied_id(bec_figure):
|
||||
bec_figure.add_plot(widget_id="test_waveform", row=0, col=0)
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
bec_figure.add_plot(widget_id="test_waveform", row=0, col=1)
|
||||
assert "Widget with ID 'test_waveform' already exists" in str(excinfo.value)
|
||||
|
||||
|
||||
def test_remove_plots(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
w2 = bec_figure.add_plot(widget_id="test_waveform_2", row=0, col=1)
|
||||
w3 = bec_figure.add_plot(widget_id="test_waveform_3", row=1, col=0)
|
||||
w4 = bec_figure.add_plot(widget_id="test_waveform_4", row=1, col=1)
|
||||
w1 = bec_figure.add_plot(row=0, col=0)
|
||||
w2 = bec_figure.add_plot(row=0, col=1)
|
||||
w3 = bec_figure.add_plot(row=1, col=0)
|
||||
w4 = bec_figure.add_plot(row=1, col=1)
|
||||
|
||||
assert bec_figure[0, 0] == w1
|
||||
assert bec_figure[0, 1] == w2
|
||||
@ -116,47 +108,47 @@ def test_remove_plots(bec_figure):
|
||||
|
||||
# remove by coordinates
|
||||
bec_figure[0, 0].remove()
|
||||
assert "test_waveform_1" not in bec_figure._widgets
|
||||
assert "widget_1" not in bec_figure._widgets
|
||||
|
||||
# remove by widget_id
|
||||
bec_figure.remove(widget_id="test_waveform_2")
|
||||
assert "test_waveform_2" not in bec_figure._widgets
|
||||
bec_figure.remove(widget_id="widget_2")
|
||||
assert "widget_2" not in bec_figure._widgets
|
||||
|
||||
# remove by widget object
|
||||
w3.remove()
|
||||
assert "test_waveform_3" not in bec_figure._widgets
|
||||
assert "widget_3" not in bec_figure._widgets
|
||||
|
||||
# check the remaining widget 4
|
||||
assert bec_figure[0, 0] == w4
|
||||
assert bec_figure["test_waveform_4"] == w4
|
||||
assert "test_waveform_4" in bec_figure._widgets
|
||||
assert bec_figure["widget_4"] == w4
|
||||
assert "widget_4" in bec_figure._widgets
|
||||
assert len(bec_figure._widgets) == 1
|
||||
|
||||
|
||||
def test_remove_plots_by_coordinates_ints(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
w2 = bec_figure.add_plot(widget_id="test_waveform_2", row=0, col=1)
|
||||
w1 = bec_figure.add_plot(row=0, col=0)
|
||||
w2 = bec_figure.add_plot(row=0, col=1)
|
||||
|
||||
bec_figure.remove(0, 0)
|
||||
assert "test_waveform_1" not in bec_figure._widgets
|
||||
assert "test_waveform_2" in bec_figure._widgets
|
||||
assert "widget_1" not in bec_figure._widgets
|
||||
assert "widget_2" in bec_figure._widgets
|
||||
assert bec_figure[0, 0] == w2
|
||||
assert len(bec_figure._widgets) == 1
|
||||
|
||||
|
||||
def test_remove_plots_by_coordinates_tuple(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
w2 = bec_figure.add_plot(widget_id="test_waveform_2", row=0, col=1)
|
||||
w1 = bec_figure.add_plot(row=0, col=0)
|
||||
w2 = bec_figure.add_plot(row=0, col=1)
|
||||
|
||||
bec_figure.remove(coordinates=(0, 0))
|
||||
assert "test_waveform_1" not in bec_figure._widgets
|
||||
assert "test_waveform_2" in bec_figure._widgets
|
||||
assert "widget_1" not in bec_figure._widgets
|
||||
assert "widget_2" in bec_figure._widgets
|
||||
assert bec_figure[0, 0] == w2
|
||||
assert len(bec_figure._widgets) == 1
|
||||
|
||||
|
||||
def test_remove_plot_by_id_error(bec_figure):
|
||||
bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
bec_figure.add_plot(row=0, col=0)
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
bec_figure.remove(widget_id="non_existent_widget")
|
||||
@ -164,7 +156,7 @@ def test_remove_plot_by_id_error(bec_figure):
|
||||
|
||||
|
||||
def test_remove_plot_by_coordinates_error(bec_figure):
|
||||
bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
bec_figure.add_plot(row=0, col=0)
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
bec_figure.remove(0, 1)
|
||||
@ -172,7 +164,7 @@ def test_remove_plot_by_coordinates_error(bec_figure):
|
||||
|
||||
|
||||
def test_remove_plot_by_providing_nothing(bec_figure):
|
||||
bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
bec_figure.add_plot(row=0, col=0)
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
bec_figure.remove()
|
||||
@ -192,10 +184,10 @@ def test_remove_plot_by_providing_nothing(bec_figure):
|
||||
|
||||
|
||||
def test_change_layout(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
w2 = bec_figure.add_plot(widget_id="test_waveform_2", row=0, col=1)
|
||||
w3 = bec_figure.add_plot(widget_id="test_waveform_3", row=1, col=0)
|
||||
w4 = bec_figure.add_plot(widget_id="test_waveform_4", row=1, col=1)
|
||||
w1 = bec_figure.add_plot(row=0, col=0)
|
||||
w2 = bec_figure.add_plot(row=0, col=1)
|
||||
w3 = bec_figure.add_plot(row=1, col=0)
|
||||
w4 = bec_figure.add_plot(row=1, col=1)
|
||||
|
||||
bec_figure.change_layout(max_columns=1)
|
||||
|
||||
@ -215,10 +207,10 @@ def test_change_layout(bec_figure):
|
||||
|
||||
|
||||
def test_clear_all(bec_figure):
|
||||
bec_figure.add_plot(widget_id="test_waveform_1", row=0, col=0)
|
||||
bec_figure.add_plot(widget_id="test_waveform_2", row=0, col=1)
|
||||
bec_figure.add_plot(widget_id="test_waveform_3", row=1, col=0)
|
||||
bec_figure.add_plot(widget_id="test_waveform_4", row=1, col=1)
|
||||
bec_figure.add_plot(row=0, col=0)
|
||||
bec_figure.add_plot(row=0, col=1)
|
||||
bec_figure.add_plot(row=1, col=0)
|
||||
bec_figure.add_plot(row=1, col=1)
|
||||
|
||||
bec_figure.clear_all()
|
||||
|
||||
|
@ -10,7 +10,7 @@ from .test_bec_figure import bec_figure
|
||||
|
||||
|
||||
def test_adding_curve_to_waveform(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
# adding curve which is in bec - only names
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i")
|
||||
@ -38,7 +38,7 @@ def test_adding_curve_to_waveform(bec_figure):
|
||||
|
||||
|
||||
def test_adding_curve_with_same_id(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i", gui_id="test_curve")
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@ -101,7 +101,7 @@ def test_create_waveform1D_by_config(bec_figure):
|
||||
},
|
||||
}
|
||||
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform", config=w1_config_input)
|
||||
w1 = bec_figure.add_plot(config=w1_config_input)
|
||||
|
||||
w1_config_output = w1.get_config()
|
||||
|
||||
@ -111,7 +111,7 @@ def test_create_waveform1D_by_config(bec_figure):
|
||||
|
||||
|
||||
def test_change_gui_id(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i")
|
||||
w1.change_gui_id("new_id")
|
||||
|
||||
@ -120,12 +120,12 @@ def test_change_gui_id(bec_figure):
|
||||
|
||||
|
||||
def test_getting_curve(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i", gui_id="test_curve")
|
||||
c1_expected_config = CurveConfig(
|
||||
widget_class="BECCurve",
|
||||
gui_id="test_curve",
|
||||
parent_id="test_waveform",
|
||||
parent_id="widget_1",
|
||||
label="bpm4i-bpm4i",
|
||||
color="#cc4778",
|
||||
symbol="o",
|
||||
@ -142,7 +142,7 @@ def test_getting_curve(bec_figure):
|
||||
)
|
||||
|
||||
assert w1.curves[0].config == c1_expected_config
|
||||
assert w1.curves_data["scan_segment"]["bpm4i-bpm4i"].config == c1_expected_config
|
||||
assert w1._curves_data["scan_segment"]["bpm4i-bpm4i"].config == c1_expected_config
|
||||
assert w1.get_curve(0).config == c1_expected_config
|
||||
assert w1.get_curve("bpm4i-bpm4i").config == c1_expected_config
|
||||
assert c1.get_config(False) == c1_expected_config
|
||||
@ -150,7 +150,7 @@ def test_getting_curve(bec_figure):
|
||||
|
||||
|
||||
def test_getting_curve_errors(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i", gui_id="test_curve")
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@ -167,18 +167,18 @@ def test_getting_curve_errors(bec_figure):
|
||||
|
||||
|
||||
def test_add_curve(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i")
|
||||
|
||||
assert len(w1.curves) == 1
|
||||
assert w1.curves_data["scan_segment"] == {"bpm4i-bpm4i": c1}
|
||||
assert w1._curves_data["scan_segment"] == {"bpm4i-bpm4i": c1}
|
||||
assert c1.config.label == "bpm4i-bpm4i"
|
||||
assert c1.config.source == "scan_segment"
|
||||
|
||||
|
||||
def test_remove_curve(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
w1.add_curve_scan(x_name="samx", y_name="bpm4i")
|
||||
w1.add_curve_scan(x_name="samx", y_name="bpm3a")
|
||||
@ -186,7 +186,7 @@ def test_remove_curve(bec_figure):
|
||||
w1.remove_curve("bpm3a-bpm3a")
|
||||
|
||||
assert len(w1.plot_item.curves) == 0
|
||||
assert w1.curves_data["scan_segment"] == {}
|
||||
assert w1._curves_data["scan_segment"] == {}
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
w1.remove_curve(1.2)
|
||||
@ -196,7 +196,7 @@ def test_remove_curve(bec_figure):
|
||||
|
||||
|
||||
def test_change_curve_appearance_methods(bec_figure, qtbot):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i")
|
||||
|
||||
@ -223,7 +223,7 @@ def test_change_curve_appearance_methods(bec_figure, qtbot):
|
||||
|
||||
|
||||
def test_change_curve_appearance_args(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i")
|
||||
|
||||
@ -251,7 +251,7 @@ def test_change_curve_appearance_args(bec_figure):
|
||||
|
||||
|
||||
def test_set_custom_curve_data(bec_figure, qtbot):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
c1 = w1.add_curve_custom(
|
||||
x=[1, 2, 3],
|
||||
@ -287,7 +287,7 @@ def test_set_custom_curve_data(bec_figure, qtbot):
|
||||
|
||||
|
||||
def test_get_all_data(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
c1 = w1.add_curve_custom(
|
||||
x=[1, 2, 3],
|
||||
@ -322,7 +322,7 @@ def test_get_all_data(bec_figure):
|
||||
|
||||
|
||||
def test_curve_add_by_config(bec_figure):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
c1_config_input = {
|
||||
"widget_class": "BECCurve",
|
||||
@ -353,7 +353,7 @@ def test_curve_add_by_config(bec_figure):
|
||||
|
||||
|
||||
def test_scan_update(bec_figure, qtbot):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i")
|
||||
|
||||
@ -387,7 +387,7 @@ def test_scan_update(bec_figure, qtbot):
|
||||
|
||||
|
||||
def test_scan_history_with_val_access(bec_figure, qtbot):
|
||||
w1 = bec_figure.add_plot(widget_id="test_waveform_history_val")
|
||||
w1 = bec_figure.add_plot()
|
||||
|
||||
c1 = w1.add_curve_scan(x_name="samx", y_name="bpm4i")
|
||||
|
||||
|
Reference in New Issue
Block a user