How to use _display_extra method in avocado

Best Python code snippet using avocado_python

scan_info_helper.py

Source:scan_info_helper.py Github

copy

Full Screen

...504 plotselect: Optional[List[str]]505 """List of name selected by plot select"""506 plotselect_time: Optional[int]507 """Time from `time.time()` of the last plotselect"""508def parse_display_extra(scan_info: Dict) -> DisplayExtra:509 """Return the list of the displayed channels stored in the scan"""510 def parse_optional_list_of_string(data, name):511 """Sanitize data from scan_info protocol"""512 if data is None:513 return None514 if not isinstance(data, list):515 _logger.warning("%s is not a list: Key ignored", name)516 return None517 if not all([isinstance(i, str) for i in data]):518 _logger.warning("%s must only contains strings: Key ignored", name)519 return None520 return data521 display_extra = scan_info.get("_display_extra", None)522 if display_extra is not None:523 raw = display_extra.get("displayed_channels", None)524 displayed_channels = parse_optional_list_of_string(525 raw, "_display_extra.displayed_channels"526 )527 raw = display_extra.get("plotselect", None)528 plotselect = parse_optional_list_of_string(raw, "_display_extra.plotselect")529 plotselect_time = display_extra.get("plotselect_time", None)530 else:531 displayed_channels = None532 plotselect = None533 plotselect_time = None534 return DisplayExtra(displayed_channels, plotselect, plotselect_time)535def removed_same_plots(plots, remove_plots) -> List[plot_model.Plot]:536 """Returns plots from an initial list of `plots` in which same plots was537 removed."""538 if remove_plots == []:539 return list(plots)540 result = []541 for p in plots:542 for p2 in remove_plots:543 if p.hasSameTarget(p2):544 break545 else:546 result.append(p)547 continue548 return result549def create_plot_model(550 scan_info: Dict, scan: Optional[scan_model.Scan] = None551) -> List[plot_model.Plot]:552 """Create plot models from a scan_info.553 If a `plots` key exists from the `scan_info`, scatter and curve plots will554 created following this description. Else, plots will be inferred from the555 acquisition chain.556 Finally the selection is updated using `_display_extra` field. This should557 be removed a one point.558 Special kind of plots depending on devices and data kind, like Lima, MCAs559 and 1D data will always be inferred.560 """561 if scan is None:562 scan = create_scan_model(scan_info)563 if "plots" in scan_info:564 plots = read_plot_models(scan_info)565 for plot in plots:566 _select_default_counter(scan, plot)567 def contains_default_plot_kind(plots, plot):568 """Returns true if the list contain a default plot for this kind."""569 for p in plots:570 if p.hasSameTarget(plot):571 return True572 return False573 aq_plots = infer_plot_models(scan)574 for plot in aq_plots:575 if isinstance(576 plot, (plot_item_model.CurvePlot, plot_item_model.ScatterPlot)577 ):578 # This kind of plots are already constrained by the `plots` key579 continue580 if not contains_default_plot_kind(plots, plot):581 plots.append(plot)582 else:583 plots = infer_plot_models(scan)584 def filter_with_scan_content(channel_names, scan):585 if scan is None:586 return channel_names587 if channel_names is None:588 return channel_names589 # Filter selection by available channels590 intersection = set(channel_names) & set(scan.getChannelNames())591 if len(channel_names) != len(intersection):592 # Remove missing without breaking the order593 for name in list(channel_names):594 if name not in intersection:595 channel_names.remove(name)596 _logger.warning(597 "Skip display of channel '%s' from scan_info. Not part of the scan",598 name,599 )600 if len(channel_names) == 0:601 channel_names = None602 return channel_names603 display_extra = parse_display_extra(scan_info)604 displayed_channels = filter_with_scan_content(605 display_extra.displayed_channels, scan606 )607 for plot in plots:608 channel_names = None609 if isinstance(plot, plot_item_model.CurvePlot):610 if displayed_channels is None:611 channel_names = filter_with_scan_content(display_extra.plotselect, scan)612 else:613 channel_names = displayed_channels614 elif isinstance(plot, plot_item_model.ScatterPlot):615 if displayed_channels:616 channel_names = displayed_channels617 if channel_names:...

Full Screen

Full Screen

test_manager.py

Source:test_manager.py Github

copy

Full Screen

1"""Testing manager module."""2import copy3from bliss.flint.manager.manager import ManageMainBehaviours4from bliss.flint.model import flint_model5from bliss.flint.model import plot_item_model6from bliss.flint.widgets.curve_plot import CurvePlotWidget7from bliss.flint.helper import scan_info_helper8from bliss.flint.helper import model_helper9from tests.qt.flint.factory import ScanInfoFactory10def _create_loopscan_scan_info():11 factory = ScanInfoFactory()12 factory.add_device(root_id="timer", device_id="timer")13 factory.add_channel(channel_id="timer:elapsed_time", dim=0, unit="s")14 factory.add_channel(channel_id="timer:epoch", dim=0, unit="s")15 factory.add_device(root_id="timer", device_id="diode", triggered_by="timer")16 factory.add_channel(channel_id="diode:diode1", dim=0)17 factory.add_channel(channel_id="diode:diode2", dim=0)18 factory["type"] = "loopscan"19 return factory.scan_info()20def _create_ascan_scan_info(master_name, extra_name=None):21 factory = ScanInfoFactory()22 factory.add_device(root_id="ascan", device_id="master")23 factory.add_channel(channel_id=master_name, device_id="master", dim=0)24 factory.add_device(root_id="ascan", device_id="slave", triggered_by="master")25 factory.add_channel(26 channel_id="timer:elapsed_time", device_id="slave", dim=0, unit="s"27 )28 factory.add_channel(channel_id="timer:epoch", device_id="slave", dim=0, unit="s")29 factory.add_channel(channel_id="diode:diode1", device_id="slave", dim=0)30 factory.add_channel(channel_id="diode:diode2", device_id="slave", dim=0)31 if extra_name is not None:32 factory.add_channel(channel_id=extra_name, device_id="master", dim=0)33 factory["type"] = "ascan"34 return factory.scan_info()35def _create_lima_scan_info(include_roi2):36 """37 Simulate a scan containing a lima detector with ROIs.38 """39 factory = ScanInfoFactory()40 factory.add_device(root_id="timer", device_id="timer")41 factory.add_channel(channel_id="timer:elapsed_time", dim=0)42 factory.add_channel(channel_id="timer:epoch", dim=0)43 rois = {"roi1": {"kind": "rect", "x": 190, "y": 110, "width": 600, "height": 230}}44 if include_roi2:45 rois["roi2"] = {46 "kind": "arc",47 "cx": 487.0,48 "cy": 513.0,49 "r1": 137.0,50 "r2": 198.0,51 "a1": -172.0,52 "a2": -300.0,53 }54 factory.add_lima_device(55 device_id="beamviewer",56 root_id="timer",57 triggered_by="timer",58 image=True,59 rois=rois,60 )61 factory.add_channel(channel_id="beamviewer:roi_counters:roi1_sum", dim=0)62 if include_roi2:63 factory.add_channel(channel_id="beamviewer:roi_counters:roi2_sum", dim=0)64 scan_info = factory.scan_info()65 return scan_info66def test_curve_plot__from_loopscan_to_ascan(local_flint):67 """68 Test plot state with consecutive scans69 - Create a loopscan -> elapsed_time should be the axis70 - Then create a ascan -> the motor should be the axis71 """72 flint = flint_model.FlintState()73 workspace = flint_model.Workspace()74 flint.setWorkspace(workspace)75 widget = CurvePlotWidget()76 workspace.addWidget(widget)77 manager = ManageMainBehaviours()78 manager.setFlintModel(flint)79 loopscan_info = _create_loopscan_scan_info()80 scan = scan_info_helper.create_scan_model(loopscan_info)81 plots = scan_info_helper.create_plot_model(loopscan_info, scan)82 manager.updateScanAndPlots(scan, plots)83 ascan_info = _create_ascan_scan_info("axis:sx")84 scan = scan_info_helper.create_scan_model(ascan_info)85 plots = scan_info_helper.create_plot_model(ascan_info, scan)86 manager.updateScanAndPlots(scan, plots)87 model = widget.plotModel()88 item = model.items()[0]89 assert item.xChannel().name() == "axis:sx"90def test_curve_plot__user_selection(local_flint):91 """92 Test plot state with consecutive scans and a user selection in between93 We expect the user selection to be restored94 """95 flint = flint_model.FlintState()96 workspace = flint_model.Workspace()97 flint.setWorkspace(workspace)98 widget = CurvePlotWidget()99 workspace.addWidget(widget)100 manager = ManageMainBehaviours()101 manager.setFlintModel(flint)102 loopscan_info = _create_loopscan_scan_info()103 scan = scan_info_helper.create_scan_model(loopscan_info)104 plots = scan_info_helper.create_plot_model(loopscan_info, scan)105 plot = [p for p in plots if isinstance(p, plot_item_model.CurvePlot)][0]106 manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=False)107 model = widget.plotModel()108 assert len(model.items()) == 1109 # user selection110 model_helper.updateDisplayedChannelNames(111 plot, scan, ["diode:diode1", "diode:diode2"]112 )113 plot.tagUserEditTime()114 ascan_info = _create_ascan_scan_info("axis:sx")115 scan = scan_info_helper.create_scan_model(ascan_info)116 plots = scan_info_helper.create_plot_model(ascan_info, scan)117 plot = [p for p in plots if isinstance(p, plot_item_model.CurvePlot)][0]118 manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=False)119 model = widget.plotModel()120 assert len(model.items()) == 2121def test_curve_plot__ascan_axis_updated(local_flint):122 """123 Test plot state with consecutive scans124 - Create a ascan -> sx should be the axis125 - Then create a ascan -> sy should be the axis126 """127 flint = flint_model.FlintState()128 workspace = flint_model.Workspace()129 flint.setWorkspace(workspace)130 widget = CurvePlotWidget()131 workspace.addWidget(widget)132 manager = ManageMainBehaviours()133 manager.setFlintModel(flint)134 ascan_info = _create_ascan_scan_info("axis:sx", "axis:sy")135 scan = scan_info_helper.create_scan_model(ascan_info)136 plots = scan_info_helper.create_plot_model(ascan_info, scan)137 manager.updateScanAndPlots(scan, plots)138 model = widget.plotModel()139 item = model.items()[0]140 assert item.xChannel().name() == "axis:sx"141 ascan_info = _create_ascan_scan_info("axis:sy", "axis:sx")142 scan = scan_info_helper.create_scan_model(ascan_info)143 plots = scan_info_helper.create_plot_model(ascan_info, scan)144 manager.updateScanAndPlots(scan, plots)145 model = widget.plotModel()146 item = model.items()[0]147 assert item.xChannel().name() == "axis:sy"148def test_curve_plot__enforced_channel_from_scan_info(local_flint):149 """150 Test a new plot with enforced channel (plotinit)151 We expect the channel from the scan_info to be used,152 anyway the user selection was done on the previous plot153 """154 flint = flint_model.FlintState()155 workspace = flint_model.Workspace()156 flint.setWorkspace(workspace)157 widget = CurvePlotWidget()158 workspace.addWidget(widget)159 manager = ManageMainBehaviours()160 manager.setFlintModel(flint)161 ascan_info = _create_ascan_scan_info("axis:sx", "axis:sy")162 scan = scan_info_helper.create_scan_model(ascan_info)163 plots = scan_info_helper.create_plot_model(ascan_info, scan)164 manager.updateScanAndPlots(scan, plots)165 enforced_channel = "axis:sy"166 # Enforce a user selection167 plotModel = widget.plotModel()168 plotModel.tagUserEditTime()169 item = plotModel.items()[0]170 # Make sure the following test have meaning171 assert item.yChannel().name() != enforced_channel172 ascan_info = _create_ascan_scan_info("axis:sy", "axis:sx")173 ascan_info["_display_extra"] = {"displayed_channels": [enforced_channel]}174 scan = scan_info_helper.create_scan_model(ascan_info)175 plots = scan_info_helper.create_plot_model(ascan_info, scan)176 manager.updateScanAndPlots(scan, plots)177 plotModel = widget.plotModel()178 item = plotModel.items()[0]179 assert item.yChannel().name() == enforced_channel180def test_image_plot_with_new_roi(local_flint):181 """Test the resulted image plot when a new ROI is part of the scan.182 We expect:183 - The previous ROI to still use the same config184 - The new ROI to be displayed.185 """186 flint = flint_model.FlintState()187 workspace = flint_model.Workspace()188 flint.setWorkspace(workspace)189 widget = CurvePlotWidget()190 workspace.addWidget(widget)191 manager = ManageMainBehaviours()192 manager.setFlintModel(flint)193 scan_info1 = _create_lima_scan_info(include_roi2=False)194 scan = scan_info_helper.create_scan_model(scan_info1)195 plots = scan_info_helper.create_plot_model(scan_info1, scan)196 plot = [p for p in plots if isinstance(p, plot_item_model.ImagePlot)][0]197 manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=True)198 plotModel = widget.plotModel()199 assert len(plotModel.items()) == 2 # image + ROI200 roiItem = [i for i in plotModel.items() if isinstance(i, plot_item_model.RoiItem)][201 0202 ]203 roiItem.setVisible(False)204 scan_info2 = _create_lima_scan_info(include_roi2=True)205 scan = scan_info_helper.create_scan_model(scan_info2)206 plots = scan_info_helper.create_plot_model(scan_info2, scan)207 plot = [p for p in plots if isinstance(p, plot_item_model.ImagePlot)][0]208 manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=True)209 plotModel = widget.plotModel()210 assert len(plotModel.items()) == 3 # image + ROI * 2211 roiItems = [i for i in plotModel.items() if isinstance(i, plot_item_model.RoiItem)]212 rois = {r.name(): r.isVisible() for r in roiItems}...

Full Screen

Full Screen

list.py

Source:list.py Github

copy

Full Screen

...63 # for this:64 matrix = self._prepare_matrix_for_display(matrix, verbose)65 for line in iter_tabular_output(matrix, header=header, strip=True):66 LOG_UI.debug(line)67 self._display_extra(suite, verbose)68 @staticmethod69 def _display_extra(suite, verbose=True):70 """Display extra data when in verbose mode."""71 if not verbose:72 return73 if suite.resolutions:74 resolution_header = (75 TERM_SUPPORT.header_str("Resolver"),76 TERM_SUPPORT.header_str("Reference"),77 TERM_SUPPORT.header_str("Info"),78 )79 LOG_UI.info("")80 mapping = {81 ReferenceResolutionResult.SUCCESS: TERM_SUPPORT.healthy_str,82 ReferenceResolutionResult.NOTFOUND: TERM_SUPPORT.fail_header_str,83 ReferenceResolutionResult.ERROR: TERM_SUPPORT.fail_header_str,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful