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.

File:
1 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__": 
Note: See TracChangeset for help on using the changeset viewer.