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
19 changes: 14 additions & 5 deletions Orange/widgets/data/owfeaturestatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ def __init__(self, data=None, parent=None):
self.n_attributes = self.n_instances = 0

self.__attributes = self.__class_vars = self.__metas = None
# sets of variables for fast membership tests
self.__attributes_set = set()
self.__class_vars_set = set()
self.__metas_set = set()
self.__distributions_cache = {}

no_data = np.array([])
Expand Down Expand Up @@ -176,7 +180,9 @@ def set_data(self, data):
# while we need a 2d array, which `_Y` provides
self.__class_vars = self.__filter_attributes(domain.class_vars, self.table._Y) # pylint: disable=protected-access
self.__metas = self.__filter_attributes(domain.metas, self.table.metas)

self.__attributes_set = set(self.__metas[0])
self.__class_vars_set = set(self.__class_vars[0])
self.__metas_set = set(self.__metas[0])
self.n_attributes = len(self.variables)
self.n_instances = len(data)

Expand All @@ -191,6 +197,9 @@ def clear(self):
self.__attributes = (np.array([]), np.array([]))
self.__class_vars = (np.array([]), np.array([]))
self.__metas = (np.array([]), np.array([]))
self.__attributes_set = set()
self.__class_vars_set = set()
self.__metas_set = set()
self.__distributions_cache.clear()
self.endResetModel()

Expand Down Expand Up @@ -471,11 +480,11 @@ def headerData(self, section, orientation, role):
def data(self, index, role):
# type: (QModelIndex, Qt.ItemDataRole) -> Any
def background():
if attribute in self.domain.attributes:
if attribute in self.__attributes_set:
return self.COLOR_FOR_ROLE[self.ATTRIBUTE]
if attribute in self.domain.metas:
if attribute in self.__metas_set:
return self.COLOR_FOR_ROLE[self.META]
if attribute in self.domain.class_vars:
if attribute in self.__class_vars_set:
return self.COLOR_FOR_ROLE[self.CLASS_VAR]
return None

Expand Down Expand Up @@ -505,7 +514,7 @@ def render_value(value):
return "∞"

str_val = attribute.str_val(value)
if attribute.is_continuous:
if attribute.is_continuous and not attribute.is_time:
str_val = format_zeros(str_val)

return str_val
Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/data/tests/test_owfeaturestatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _to_timestamps(years):
# Time variable variations, windows timestamps need to be valid timestamps so
# we'll just fill it in with arbitrary years
time_full = VarDataPair(
TimeVariable('time_full'),
TimeVariable('time_full', have_date=True, have_time=True),
np.array(_to_timestamps([2000, 2001, 2002, 2003, 2004]), dtype=float),
)
time_missing = VarDataPair(
Expand All @@ -117,7 +117,7 @@ def _to_timestamps(years):
np.array(_to_timestamps([np.nan] * 5), dtype=float),
)
time_same = VarDataPair(
TimeVariable('time_same'),
TimeVariable('time_same', have_date=True, have_time=True),
np.array(_to_timestamps([2004] * 5), dtype=float),
)
time = [
Expand Down