Skip to content

Commit

Permalink
Merge pull request #707 from markotoplak/fix-context-crash
Browse files Browse the repository at this point in the history
Avoid some context crashes: exclude_attributes=True
  • Loading branch information
markotoplak authored Feb 6, 2024
2 parents 0225031 + 407ac90 commit c51ecb0
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
8 changes: 5 additions & 3 deletions orangecontrib/spectroscopy/tests/test_owhyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,14 @@ def test_unknown_values_axes(self):
self.assertTrue(self.widget.Information.not_shown.is_shown())

def test_migrate_context_feature_color(self):
c = self.widget.settingsHandler.new_context(self.iris.domain,
None, self.iris.domain.class_vars)
# avoid class_vars in tests, because the setting does not allow them
iris = self.iris.transform(
Domain(self.iris.domain.attributes, None, self.iris.domain.class_vars))
c = self.widget.settingsHandler.new_context(iris.domain, None, iris.domain.metas)
c.values["curveplot"] = {"feature_color": ("iris", 1)}
self.widget = self.create_widget(OWHyper,
stored_settings={"context_settings": [c]})
self.send_signal("Data", self.iris)
self.send_signal("Data", iris)
self.assertIsInstance(self.widget.curveplot.feature_color, DiscreteVariable)

def test_image_computation(self):
Expand Down
8 changes: 5 additions & 3 deletions orangecontrib/spectroscopy/tests/test_owspectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,14 @@ def test_waterfall(self):
self.assertTrue(vb.targetRect().bottom() > 800)

def test_migrate_context_feature_color(self):
c = self.widget.settingsHandler.new_context(self.iris.domain,
None, self.iris.domain.class_vars)
# avoid class_vars in tests, because the setting does not allow them
iris = self.iris.transform(
Domain(self.iris.domain.attributes, None, self.iris.domain.class_vars))
c = self.widget.settingsHandler.new_context(iris.domain, None, iris.domain.metas)
c.values["curveplot"] = {"feature_color": ("iris", 1)}
self.widget = self.create_widget(OWSpectra,
stored_settings={"context_settings": [c]})
self.send_signal("Data", self.iris)
self.send_signal("Data", iris)
self.assertIsInstance(self.widget.curveplot.feature_color, DiscreteVariable)

def test_compat_no_group(self):
Expand Down
2 changes: 1 addition & 1 deletion orangecontrib/spectroscopy/widgets/owbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Warning(OWWidget.Warning):

settingsHandler = DomainContextHandler()

attrs = ContextSetting([None, None])
attrs = ContextSetting([None, None], exclude_attributes=True)
bin_shape = settings.Setting((1, 1))
square_bin = settings.Setting(True)

Expand Down
4 changes: 2 additions & 2 deletions orangecontrib/spectroscopy/widgets/owhyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ class ImagePlot(QWidget, OWComponent, SelectionGroupMixin,
ImageColorSettingMixin, ImageRGBSettingMixin,
ImageZoomMixin, ConcurrentMixin):

attr_x = ContextSetting(None)
attr_y = ContextSetting(None)
attr_x = ContextSetting(None, exclude_attributes=True)
attr_y = ContextSetting(None, exclude_attributes=True)
gamma = Setting(0)

selection_changed = Signal()
Expand Down
6 changes: 4 additions & 2 deletions orangecontrib/spectroscopy/widgets/owsnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class Outputs:
'Standard Deviation': 2} # std

settingsHandler = settings.DomainContextHandler()
group_x = settings.ContextSetting(None)
group_y = settings.ContextSetting(None)
group_x = settings.ContextSetting(None, exclude_attributes=True,
exclude_class_vars=True)
group_y = settings.ContextSetting(None, exclude_attributes=True,
exclude_class_vars=True)
out_choiced = settings.Setting(0)

autocommit = settings.Setting(True)
Expand Down
2 changes: 1 addition & 1 deletion orangecontrib/spectroscopy/widgets/owspectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ class CurvePlot(QWidget, OWComponent, SelectionGroupMixin):

sample_seed = Setting(0, schema_only=True)
peak_labels_saved = Setting([], schema_only=True)
feature_color = ContextSetting(None)
feature_color = ContextSetting(None, exclude_attributes=True)
color_individual = Setting(False) # color individual curves (in a cycle) if no feature_color
invertX = Setting(False)
viewtype = Setting(INDIVIDUAL)
Expand Down
2 changes: 1 addition & 1 deletion orangecontrib/spectroscopy/widgets/owspectralseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class LineScanPlot(QWidget, OWComponent, SelectionGroupMixin,
ImageColorSettingMixin, ImageZoomMixin):

attr_x = ContextSetting(None)
attr_x = ContextSetting(None, exclude_attributes=True)
gamma = Setting(0)

selection_changed = Signal()
Expand Down
4 changes: 2 additions & 2 deletions orangecontrib/spectroscopy/widgets/owstackalign.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ class Error(OWWidget.Error):
settingsHandler = DomainContextHandler()

sobel_filter = settings.Setting(False)
attr_x = ContextSetting(None)
attr_y = ContextSetting(None)
attr_x = ContextSetting(None, exclude_attributes=True)
attr_y = ContextSetting(None, exclude_attributes=True)
ref_frame_num = settings.Setting(0)

def __init__(self):
Expand Down

0 comments on commit c51ecb0

Please sign in to comment.