Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,16 @@ def findvar(name, iterable):
self.attr_y = findvar(self.attr_y, self.xy_model)
if isinstance(self.graph.attr_label, str):
self.graph.attr_label = findvar(
self.graph.attr_label, self.label_model)
self.graph.attr_label, self.graph.gui.label_model)
if isinstance(self.graph.attr_color, str):
self.graph.attr_color = findvar(
self.graph.attr_color, self.color_model)
self.graph.attr_color, self.graph.gui.color_model)
if isinstance(self.graph.attr_shape, str):
self.graph.attr_shape = findvar(
self.graph.attr_shape, self.shape_model)
self.graph.attr_shape, self.graph.gui.shape_model)
if isinstance(self.graph.attr_size, str):
self.graph.attr_size = findvar(
self.graph.attr_size, self.size_model)
self.graph.attr_size, self.graph.gui.size_model)

def add_data(self, time=0.4):
if self.data and len(self.data) > 2000:
Expand Down
20 changes: 20 additions & 0 deletions Orange/widgets/visualize/tests/test_owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,26 @@ def test_invalid_points_selection(self):
selected_data = self.get_output("Selected Data")
self.assertEqual(len(selected_data), 10)

def test_set_strings_settings(self):
"""
Test if settings can be loaded as strings and successfully put
in new owplotgui combos.
GH-2240
"""
self.send_signal("Data", self.data)
settings = self.widget.settingsHandler.pack_data(self.widget)
graph_settings = settings["context_settings"][0].values["graph"]
graph_settings["attr_label"] = ("sepal length", -2)
graph_settings["attr_color"] = ("sepal width", -2)
graph_settings["attr_shape"] = ("iris", -2)
graph_settings["attr_size"] = ("petal width", -2)
w = self.create_widget(OWScatterPlot, stored_settings=settings)
self.send_signal("Data", self.data, widget=w)
self.assertEqual(w.graph.attr_label.name, "sepal length")
self.assertEqual(w.graph.attr_color.name, "sepal width")
self.assertEqual(w.graph.attr_shape.name, "iris")
self.assertEqual(w.graph.attr_size.name, "petal width")


if __name__ == "__main__":
import unittest
Expand Down