Changeset 8132:478c741eb878 in orange


Ignore:
Timestamp:
08/01/11 17:28:36 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
73fe9488b25332fb60b1ffebce5475a4cd6dcea7
Message:

When testing equality of unpickled classifier (for continuous class) use assertAlmostEqual.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/misc/testing.py

    r8042 r8132  
    407407         
    408408        for ex in test: 
    409             if classifier(ex, orange.GetValue) != classifier_clone(ex, orange.GetValue): 
    410                 print classifier(ex, orange.GetBoth) , classifier_clone(ex, orange.GetBoth) 
    411                 print classifier(ex, orange.GetValue) , classifier_clone(ex, orange.GetValue) 
    412             self.assertEqual(classifier(ex, orange.GetValue), classifier_clone(ex, orange.GetValue), "Pickled and original classifier return a different value!") 
    413         self.assertTrue(all(classifier(ex, orange.GetValue) == classifier_clone(ex, orange.GetValue) for ex in test)) 
    414  
     409            if isinstance(dataset.domain.class_var, Orange.data.variable.Continuous): 
     410                self.assertAlmostEqual(classifier(ex, orange.GetValue).native(), 
     411                                       classifier_clone(ex, orange.GetValue).native(), 
     412                                       dataset.domain.class_var.number_of_decimals + 3, 
     413                                       "Pickled and original classifier return a different value!") 
     414            else: 
     415                self.assertEqual(classifier(ex, orange.GetValue), classifier_clone(ex, orange.GetValue), "Pickled and original classifier return a different value!") 
    415416 
    416417class MeasureAttributeTestCase(DataTestCase): 
Note: See TracChangeset for help on using the changeset viewer.