Changeset 10589:e583c98f2220 in orange


Ignore:
Timestamp:
03/20/12 23:52:32 (2 years ago)
Author:
Janez Demšar <janez.demsar@…>
Branch:
default
Children:
10590:39cb3e632aed, 10591:1a543c7924ef
Message:

Examples from different domains can now be compared for (in)equality; other comparison operators still raise exceptions as they used to

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/cls_example.cpp

    r10588 r10589  
    10761076} 
    10771077 
    1078 int Example_cmp(TPyExample *one, TPyExample *another) 
    1079 { PyTRY 
    1080     return PyExample_AS_Example(one)->compare(PyExample_AS_ExampleReference(another)); 
    1081   PyCATCH_1 
     1078PyObject *richcmp_from_sign(const int &i, const int &op); 
     1079 
     1080PyObject *Example_richcmp(TPyExample *one, TPyExample *another, int op) 
     1081{ PyTRY 
     1082    PExample rone = PyExample_AS_Example(one); 
     1083    TExample &ranother = PyExample_AS_ExampleReference(another); 
     1084    if (rone->domain != ranother.domain) { 
     1085        if ((op == Py_EQ) || (op == Py_NE)) { 
     1086            PyObject *res = op == Py_NE ? Py_True : Py_False; 
     1087            Py_INCREF(res); 
     1088            return res; 
     1089        } 
     1090        else { 
     1091            PYERROR(PyExc_ValueError, "examples are from different domains", NULL); 
     1092        } 
     1093    } 
     1094    return richcmp_from_sign(rone->compare(ranother), op); 
     1095  PyCATCH 
    10821096} 
    10831097 
Note: See TracChangeset for help on using the changeset viewer.