Changeset 3617:67aeddc39259 in orange


Ignore:
Timestamp:
04/30/07 17:45:56 (7 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
d751b0abac0c68308675dc1d2a9c3196df5d69ad
Message:
  • fixed a problem with out-of-bound indices
  • catch exceptions in imputer construction
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Data/OWImpute.py

    r3481 r3617  
    2525            elif meth: 
    2626                attr = self.master.data.domain[btext] 
    27                 ntext = attr.varType == orange.VarTypes.Discrete and attr.values[val] or val 
     27                if attr.varType == orange.VarTypes.Discrete: 
     28                    if val < len(attr.values): 
     29                        ntext = attr.values[val] 
     30                    else: 
     31                        ntext = "?" 
     32                else: 
     33                    ntext = str(val) 
    2834            self.setText(btext + " -> " + ntext) 
    2935        painter.font().setBold(meth) 
     
    6167        self.loadSettings() 
    6268 
    63         bgTreat = OWGUI.radioButtonsInBox(self.controlArea, self, "defaultMethod", ["Don't Impute", "Average/Most frequent", "Model-based imputer", "Random values"], "Default imputation method", callback=self.sendIf) 
     69        bgTreat = OWGUI.radioButtonsInBox(self.controlArea, self, "defaultMethod", ["Don't Impute", "Average/Most frequent", "Model-based imputer (can be slow!)", "Random values"], "Default imputation method", callback=self.sendIf) 
    6470 
    6571        OWGUI.separator(self.controlArea) 
     
    335341        if self.data: 
    336342            if self.imputer: 
    337                 constructed = self.imputer(self.data) 
    338343                try: 
     344                    constructed = self.imputer(self.data) 
    339345                    data = constructed(self.data) 
    340346                    ## meta-comment: is there a missing 'not' in the below comment? 
     
    342348                    self.dataChanged = False 
    343349                except: 
    344                     self.error(0, "Imputation failed; this is typically due to unsuitable model.") 
     350                    self.error(0, "Imputation failed; this is typically due to unsuitable model.\nIt can also happen with some imputation techniques if no values are defined.") 
    345351                    data = None 
    346352            else: 
Note: See TracChangeset for help on using the changeset viewer.