source: orange/Orange/testing/unit/tests/test_mds.py @ 9724:318e91106d47

Revision 9724:318e91106d47, 1.1 KB checked in by markotoplak, 2 years ago (diff)

Renames in Orange.distance.

Line 
1from Orange.misc import testing
2from Orange.misc.testing import test_on_data, datasets_driven
3
4import unittest
5from Orange.projection import mds
6from Orange.distance import distance_matrix, Euclidean
7   
8@datasets_driven
9class TestMDS(unittest.TestCase):
10   
11    @test_on_data
12    def test_mds_on(self, data):
13        matrix = distance_matrix(data, EuclideanConstructor)
14        self.__mds_test_helper(matrix, proj_dim=1)
15        self.__mds_test_helper(matrix, proj_dim=2)
16        self.__mds_test_helper(matrix, proj_dim=3)
17       
18    def __mds_test_helper(self, matrix, proj_dim):
19        proj = mds.MDS(matrix, dim=proj_dim)
20        proj.torgerson()
21        proj.smacof_step()
22        proj.run(100)
23        proj.smacof_step()
24        self.assertEquals(len(proj.points), matrix.dim)
25        self.assertTrue(all(len(p) == proj_dim for p in proj.points))
26        self.assertEquals(matrix, proj.distances,
27                        "The input distance matrix was changed in place")
28        self.assertEquals(matrix.dim, proj.projected_distances.dim)
29       
30       
31       
32if __name__ == "__main__":
33    unittest.main()
Note: See TracBrowser for help on using the repository browser.