Changeset 11661:b05f82fd1660 in orange


Ignore:
Timestamp:
08/16/13 14:33:59 (8 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Fixed comparison of Orange.data.Instance when the domain is empty.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Orange/testing/unit/tests/test_instance.py

    r10750 r11661  
    5050        self.assertRaises(TypeError, Orange.data.Instance, (domain, ["?", "?"])) 
    5151 
     52    def test_compare(self): 
     53        # Empty domain/instance (compare equal) 
     54        domain = Orange.data.Domain([]) 
     55        self.assertEqual(Orange.data.Instance(domain, []), 
     56                         Orange.data.Instance(domain, [])) 
     57 
     58        lenses = Orange.data.Table("lenses") 
     59 
     60        inst1 = lenses[0] 
     61        inst2 = Orange.data.Instance(inst1) 
     62 
     63        self.assertEqual(inst1, inst2) 
     64 
     65        inst1[0] = "?" 
     66        self.assertNotEqual(inst1, inst2) 
     67 
     68        inst2[0] = "?" 
     69        self.assertEqual(inst1, inst2) 
     70 
     71        for f in lenses.domain: 
     72            inst1[f] = inst2[f] = "?" 
     73 
     74        self.assertEqual(inst1, inst2) 
     75 
    5276 
    5377if __name__ == "__main__": 
  • source/orange/examples.cpp

    r10596 r11661  
    341341{ if (domain != other.domain) 
    342342    raiseError("examples are from different domains"); 
    343  
    344343  int Na = domain->variables->size(); 
    345344  if (ignoreClass) { 
     
    352351  } 
    353352  if (!Na) 
    354     return true; 
     353    return 0; 
    355354 
    356355  const_iterator i1(begin()), i2(other.begin()); 
Note: See TracChangeset for help on using the changeset viewer.