def test_plane_two_points(self): data = [(-1, 0), (-1, 0)] hyps = list(origin_plane_hypotheses(data)) for pp in [[False, False], [True, True]]: self.assertTrue(assign_exists(data, hyps, pp)) self.assertEqual(2, len(hyps)) print data = [(1, 1), (-2, -2)] hyps = list(origin_plane_hypotheses(data)) for pp in [[False, True], [True, False], [True, True]]: self.assertTrue(assign_exists(data, hyps, pp)) self.assertEqual(3, len(hyps)) print data = [(-1, 0), (-3, -2)] hyps = list(origin_plane_hypotheses(data)) for pp in [[False, True], [True, False], [False, False], [True, True]]: self.assertTrue(assign_exists(data, hyps, pp)) self.assertEqual(4, len(hyps)) print data = [(-1, 0), (1, 0)] hyps = list(origin_plane_hypotheses(data)) for pp in [[False, True], [True, False], [True, True]]: self.assertTrue(assign_exists(data, hyps, pp)) self.assertEqual(3, len(hyps))
def test_plane_single_point(self): data = [[(1, 1)], [(1, 0)], [(0, -5)], [(-1, 0)], [(-2.3, -5.34)]] for d in data: hyps = list(origin_plane_hypotheses(d)) for pp in [[False], [True]]: self.assertTrue(assign_exists(d, hyps, pp)) self.assertEqual(2, len(hyps)) d = [(0, 0)] hyps = list(origin_plane_hypotheses(d)) for pp in [[True]]: self.assertTrue(assign_exists(d, hyps, pp)) self.assertEqual(1, len(hyps))
def test_plane_three_points(self): data = [(-1, 0), (-1, 0), (-1, 0)] hyps = list(origin_plane_hypotheses(data)) for pp in [[False, False, False], [True, True, True]]: self.assertTrue(assign_exists(data, hyps, pp)) self.assertEqual(2, len(hyps)) print data = [(-1, 0), (-1, 0), (1, 0)] hyps = list(origin_plane_hypotheses(data)) for pp in [[False, False, True], [True, True, False], [True, True, True]]: self.assertTrue(assign_exists(data, hyps, pp)) # self.assertEqual(3, len(hyps)) print data = [(1, 0), (-1, 0), (-4, -5)] hyps = list(origin_plane_hypotheses(data)) for pp in [[True, True, True], [True, True, False], [True, False, False], [False, True, True], [True, False, True], [False, True, False]]: self.assertTrue(assign_exists(data, hyps, pp)) self.assertEqual(6, len(hyps)) print data = [(1, 0), (1, 0), (-4, -5)] hyps = list(origin_plane_hypotheses(data)) for pp in [[True, True, True], [True, True, False], [False, False, True], [False, False, False]]: self.assertTrue(assign_exists(data, hyps, pp)) self.assertEqual(4, len(hyps)) print data = [(10, 1), (3, 3), (-1, -15)] hyps = list(origin_plane_hypotheses(data)) for pp in [[True, True, True], [False, False, False], [False, False, True], [True, True, False], [True, False, True], [False, True, False]]: self.assertTrue(assign_exists(data, hyps, pp)) self.assertEqual(6, len(hyps))
def test_plane_four_points(self): hyps = list(origin_plane_hypotheses(self._2d[4])) for pp in [[True, True, True, True], [False, False, True, True], [False, False, True, False], [True, True, False, True], [True, True, False, False], [False, False, False, False]]: self.assertTrue(assign_exists(self._2d[4], hyps, pp)) self.assertEqual(6, len(hyps))
def test_plane_random(self): hyps = list(origin_plane_hypo(rand_data1)) self.assertEqual(134, len(hyps)) data = [(randint(-40, 40), randint(-40, 40)) for i in range(100)] count1 = count2 = 0 t1 = time.time() for i in origin_plane_hypotheses(data): count1 += 1 print(time.time() - t1) print(count1) t2 = time.time() for i in origin_plane_hypotheses2(data): count2 += 1 print(time.time() - t2) print(count2) self.assertEqual(count2, count1)
def test_plane_random(self): hyps = list(origin_plane_hypotheses(rand_data1)) self.assertEqual(134, len(hyps))