@@ -50,6 +50,45 @@ def __setstate__(self, state):
5050 def adopt_pipeline (self , pipeline_state ):
5151 self .__setstate__ (pipeline_state )
5252
53+ def get_widget (self , slot_id = None , filt_plot_id = None ):
54+ """Convenience function for testing"""
55+ if slot_id is None and filt_plot_id is not None :
56+ # get a filter or a plot
57+ w = self .data_matrix .filter_widgets + self .plot_matrix .plot_widgets
58+ for wi in w :
59+ if wi .identifier == filt_plot_id :
60+ break
61+ else :
62+ raise KeyError (
63+ "Widget identifier '{}' not found!" .format (filt_plot_id ))
64+ return wi
65+ elif slot_id is not None and filt_plot_id is None :
66+ # get a slot
67+ for wi in self .data_matrix .dataset_widgets :
68+ if wi .identifier == slot_id :
69+ break
70+ else :
71+ raise KeyError (
72+ "Widget identifier '{}' not found!" .format (filt_plot_id ))
73+ return wi
74+ elif slot_id is not None and filt_plot_id is not None :
75+ # get a matrix element
76+ wd = self .data_matrix .element_widget_dict
77+ wp = self .plot_matrix .element_widget_dict
78+ fpd = wd [slot_id ]
79+ fpp = wp [slot_id ]
80+ if filt_plot_id in fpp :
81+ wi = fpp [filt_plot_id ]
82+ elif filt_plot_id in fpd :
83+ wi = fpd [filt_plot_id ]
84+ else :
85+ raise KeyError (
86+ "Widget identifier '{}' not found!" .format (filt_plot_id ))
87+ return wi
88+ else :
89+ raise ValueError (
90+ "One of `slot_id` or `filt_plot_id` must be specified!" )
91+
5392 def invalidate_elements (self , invalid_dm , invalid_pm ):
5493 for slot_id , filt_id in invalid_dm :
5594 em = self .data_matrix .get_matrix_element (slot_id , filt_id )
0 commit comments