Ignore:
Timestamp:
04/18/12 12:21:57 (2 years ago)
Author:
anze <anze.staric@…>
Branch:
default
Message:

BUG Fixed pickling of pca projector.

File:
1 edited

Legend:

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

    r10710 r10803  
    55 
    66import numpy as np 
    7 import random 
     7import pickle, random 
    88 
    99from Orange import data, feature 
    1010from Orange.projection import linear 
    1111 
     12np.random.seed(0) 
    1213random.seed(0) 
    1314 
     
    211212        projector(new_examples) 
    212213 
     214    def test_can_pickle_and_unpickle(self): 
     215        self.create_normal_dataset() 
     216        projector = linear.PCA(variance_covered=.99)(self.dataset) 
     217 
     218        pickled = pickle.dumps(projector) 
     219        restored = pickle.loads(pickled) 
     220 
     221        self.assertFalse((projector.projection - restored.projection).any()) 
     222        self.assertFalse((projector.center - restored.center).any()) 
     223        self.assertFalse((projector.scale - restored.scale).any()) 
     224 
     225        transformed, new_transformed = projector(self.dataset), restored(self.dataset) 
     226        print transformed[0][0] 
     227        for ex1, ex2 in zip(transformed, new_transformed): 
     228            for v1, v2 in zip(ex1, ex2): 
     229                self.assertEqual(v1, v2) 
     230 
    213231 
    214232class TestFda(unittest.TestCase): 
Note: See TracChangeset for help on using the changeset viewer.