Skip to content

Commit

Permalink
ContextHandlers: Add is_allowed_type
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed May 1, 2020
1 parent cf0f69f commit efde6d7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Orange/widgets/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import itertools
import logging
import warnings
from typing import List

from orangewidget.settings import (
Setting, SettingProvider, SettingsHandler, ContextSetting,
Expand Down Expand Up @@ -77,6 +78,11 @@ def __init__(self, *, match_values=0, first_match=True, **kwargs):
.format(name), OrangeDeprecationWarning
)

@classmethod
def is_allowed_type(cls, setting):
return ContextHandler.is_allowed_type(setting) \
or setting.type in (Variable, List[Variable])

def encode_domain(self, domain):
"""
domain: Orange.data.domain to encode
Expand Down Expand Up @@ -273,15 +279,15 @@ class ClassValuesContextHandler(ContextHandler):
def open_context(self, widget, classes):
if isinstance(classes, Variable):
if classes.is_discrete:
classes = classes.values
classes = tuple(classes.values)
else:
classes = None

super().open_context(widget, classes)

def new_context(self, classes):
context = super().new_context()
context.classes = classes
context.classes = tuple(classes)
return context

def match(self, context, classes):
Expand Down

0 comments on commit efde6d7

Please sign in to comment.