def test_nan_plot(self): data = datasets.missing_data_1() espy = EventSpy(self.widget, OWLinearProjection.ReplotRequest) with excepthook_catch(): self.send_signal(self.widget.Inputs.data, data) # ensure delayed replot request is processed if not espy.events(): assert espy.wait(1000) cb = self.widget.graph.controls simulate.combobox_run_through_all(cb.attr_color) simulate.combobox_run_through_all(cb.attr_size) data = data.copy() data.X[:, 0] = np.nan data.Y[:] = np.nan spy = EventSpy(self.widget, OWLinearProjection.ReplotRequest) self.send_signal(self.widget.Inputs.data, data) self.send_signal(self.widget.Inputs.data_subset, data[2:3]) if not spy.events(): assert spy.wait() with excepthook_catch(): simulate.combobox_activate_item(cb.attr_color, "X1") with excepthook_catch(): simulate.combobox_activate_item(cb.attr_size, "X1")
def test_nan_plot(self): data = datasets.missing_data_1() espy = EventSpy(self.widget, OWLinearProjection.ReplotRequest) with excepthook_catch(): self.send_signal(self.widget.Inputs.data, data) # ensure delayed replot request is processed if not espy.events(): assert espy.wait(1000) cb = self.widget.graph.controls simulate.combobox_run_through_all(cb.attr_color) simulate.combobox_run_through_all(cb.attr_size) data = data.copy() data.X[:, 0] = np.nan data.Y[:] = np.nan spy = EventSpy(self.widget, OWLinearProjection.ReplotRequest) self.send_signal(self.widget.Inputs.data, data) self.send_signal(self.widget.Inputs.data_subset, data[2:3]) if not spy.events(): assert spy.wait() with excepthook_catch(): simulate.combobox_activate_item(cb.attr_color, "X1") with excepthook_catch(): simulate.combobox_activate_item(cb.attr_size, "X1")
def test_changed_class_var(self): def set_input(data, model): self.send_signals([ (self.widget.Inputs.data, data), (self.widget.Inputs.predictors, model) ]) iris = self.iris learner = ConstantLearner() heart_disease = Table("heart_disease") # catch exceptions in item delegates etc. during switching inputs with excepthook_catch(): set_input(iris[:5], learner(iris)) set_input(Table("housing"), None) set_input(heart_disease[:5], learner(heart_disease))
def test_bad_data(self): """ Firstly it creates predictions with TreeLearner. Then sends predictions and different data with different domain to Predictions widget. Those different data and domain are similar to original data and domain but they have three different target values instead of two. GH-2129 """ Variable._clear_all_caches() filestr1 = """\ age\tsex\tsurvived d\td\td \t\tclass adult\tmale\tyes adult\tfemale\tno child\tmale\tyes child\tfemale\tyes """ file1 = io.StringIO(filestr1) table = TabReader(file1).read() learner = TreeLearner() tree = learner(table) filestr2 = """\ age\tsex\tsurvived d\td\td \t\tclass adult\tmale\tyes adult\tfemale\tno child\tmale\tyes child\tfemale\tunknown """ file2 = io.StringIO(filestr2) bad_table = TabReader(file2).read() self.send_signal(self.widget.Inputs.predictors, tree, 1) with excepthook_catch(): self.send_signal(self.widget.Inputs.data, bad_table) Variable._clear_all_caches( ) # so that test excepting standard titanic work
def test_bad_data(self): """ Firstly it creates predictions with TreeLearner. Then sends predictions and different data with different domain to Predictions widget. Those different data and domain are similar to original data and domain but they have three different target values instead of two. GH-2129 """ Variable._clear_all_caches() filestr1 = """\ age\tsex\tsurvived d\td\td \t\tclass adult\tmale\tyes adult\tfemale\tno child\tmale\tyes child\tfemale\tyes """ file1 = io.StringIO(filestr1) table = TabReader(file1).read() learner = TreeLearner() tree = learner(table) filestr2 = """\ age\tsex\tsurvived d\td\td \t\tclass adult\tmale\tyes adult\tfemale\tno child\tmale\tyes child\tfemale\tunknown """ file2 = io.StringIO(filestr2) bad_table = TabReader(file2).read() self.send_signal(self.widget.Inputs.predictors, tree, 1) with excepthook_catch(): self.send_signal(self.widget.Inputs.data, bad_table) Variable._clear_all_caches() # so that test excepting standard titanic work
def test_scheme_examples(self): """ Test if Orange workflow examples can be opened. Examples in canvas and also those placed "workflows" subfolder. GH-2240 """ reg = registry() test_workflows = chain( discover_workflows(dirname(workflows.__file__)), discover_workflows(join(dirname(__file__), "workflows"))) for ows_file in test_workflows: new_scheme = widgetsscheme.WidgetsScheme() new_scheme.widget_manager.set_creation_policy( new_scheme.widget_manager.Immediate) with open(ows_file, "rb") as f: try: with excepthook_catch(raise_on_exit=True): new_scheme.load_from(f, registry=reg) except Exception as e: self.fail( "Old workflow '{}' could not be loaded\n'{}'".format( ows_file, str(e))) finally: new_scheme.clear()
def test_nan_plot(self): data = datasets.missing_data_1() espy = EventSpy(self.widget, OWLinearProjection.ReplotRequest) with excepthook_catch(): self.send_signal("Data", data) # ensure delayed replot request is processed if not espy.events(): assert espy.wait(1000) cb_color = self.widget.controls.color_index cb_size = self.widget.controls.size_index cb_shape = self.widget.controls.shape_index cb_jitter = self.widget.controls.jitter_value simulate.combobox_run_through_all(cb_color) simulate.combobox_run_through_all(cb_size) simulate.combobox_run_through_all(cb_shape) with excepthook_catch(): simulate.combobox_activate_index(cb_jitter, 1, delay=1) data = data.copy() data.X[:, 0] = np.nan data.Y[:] = np.nan spy = EventSpy(self.widget, OWLinearProjection.ReplotRequest) self.send_signal("Data", data) self.send_signal("Data Subset", data[2:3]) if not spy.events(): assert spy.wait() with excepthook_catch(): simulate.combobox_activate_item(cb_color, "X1") with excepthook_catch(): simulate.combobox_activate_item(cb_size, "X1") with excepthook_catch(): simulate.combobox_activate_item(cb_shape, "D") with excepthook_catch(): simulate.combobox_activate_index(cb_jitter, 2, delay=1)