Ignore:
Timestamp:
03/20/12 22:50:26 (2 years ago)
Author:
Janez Demšar <janez.demsar@…>
Branch:
default
Message:

Fixed conversion of Examples from lists and of ExampleTables from numpy arrays to work for domains with multiple classes (fixes #1145)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/cls_example.cpp

    r9415 r10588  
    6060  } 
    6161 
    62   if (Py_ssize_t(dom->variables->size()) != PyList_Size(lst)) { 
    63     PyErr_Format(PyExc_IndexError, "invalid list size (%i items expected)", dom->variables->size()); 
     62  int const nvars = dom->variables->size() + dom->classVars->size(); 
     63  if (Py_ssize_t(nvars) != PyList_Size(lst)) { 
     64    PyErr_Format(PyExc_IndexError, "invalid list size (got %i, expected %i items)", 
     65        PyList_Size(lst), nvars); 
    6466    return false; 
    6567  } 
     
    6769  Py_ssize_t pos = 0; 
    6870  TExample::iterator ei(example.begin()); 
    69   PITERATE(TVarList, vi, dom->variables) { 
     71  TVarList::iterator vi(dom->variables->begin()); 
     72  TVarList::const_iterator const ve(dom->variables->end()); 
     73  TVarList::const_iterator const ce(dom->classVars->end()); 
     74  while(vi != ce) { 
    7075    PyObject *li=PyList_GetItem(lst, pos++); 
    7176    if (!li) 
     
    107112      else 
    108113        ei++; 
     114    } 
     115    if (++vi == ve) { 
     116        vi = dom->classVars->begin(); 
    109117    } 
    110118  } 
Note: See TracChangeset for help on using the changeset viewer.