@@ -149,6 +149,10 @@ def __init__(self, data=None, parent=None):
149149 self .n_attributes = self .n_instances = 0
150150
151151 self .__attributes = self .__class_vars = self .__metas = None
152+ # sets of variables for fast membership tests
153+ self .__attributes_set = set ()
154+ self .__class_vars_set = set ()
155+ self .__metas_set = set ()
152156 self .__distributions_cache = {}
153157
154158 no_data = np .array ([])
@@ -176,7 +180,9 @@ def set_data(self, data):
176180 # while we need a 2d array, which `_Y` provides
177181 self .__class_vars = self .__filter_attributes (domain .class_vars , self .table ._Y ) # pylint: disable=protected-access
178182 self .__metas = self .__filter_attributes (domain .metas , self .table .metas )
179-
183+ self .__attributes_set = set (self .__metas [0 ])
184+ self .__class_vars_set = set (self .__class_vars [0 ])
185+ self .__metas_set = set (self .__metas [0 ])
180186 self .n_attributes = len (self .variables )
181187 self .n_instances = len (data )
182188
@@ -191,6 +197,9 @@ def clear(self):
191197 self .__attributes = (np .array ([]), np .array ([]))
192198 self .__class_vars = (np .array ([]), np .array ([]))
193199 self .__metas = (np .array ([]), np .array ([]))
200+ self .__attributes_set = set ()
201+ self .__class_vars_set = set ()
202+ self .__metas_set = set ()
194203 self .__distributions_cache .clear ()
195204 self .endResetModel ()
196205
@@ -471,11 +480,11 @@ def headerData(self, section, orientation, role):
471480 def data (self , index , role ):
472481 # type: (QModelIndex, Qt.ItemDataRole) -> Any
473482 def background ():
474- if attribute in self .domain . attributes :
483+ if attribute in self .__attributes_set :
475484 return self .COLOR_FOR_ROLE [self .ATTRIBUTE ]
476- if attribute in self .domain . metas :
485+ if attribute in self .__metas_set :
477486 return self .COLOR_FOR_ROLE [self .META ]
478- if attribute in self .domain . class_vars :
487+ if attribute in self .__class_vars_set :
479488 return self .COLOR_FOR_ROLE [self .CLASS_VAR ]
480489 return None
481490
@@ -505,7 +514,7 @@ def render_value(value):
505514 return "∞"
506515
507516 str_val = attribute .str_val (value )
508- if attribute .is_continuous :
517+ if attribute .is_continuous and not attribute . is_time :
509518 str_val = format_zeros (str_val )
510519
511520 return str_val
0 commit comments