def internal_compare(self, lst, line): circle, points = find_constrained_centre_directly(lst, line) while len(lst) > 3: rejected = find_constrained_redundant_points(lst, line) if not rejected: chk1 = len(lst) last = lst[-1] lst.remove(last) lst.insert(0, last) chk2 = len(lst) assert chk1 == chk2 rejected = find_constrained_redundant_points(lst, line) if not rejected: print "bad bad bad" for p in lst: if p in rejected: lst.remove(p) for p in points: self.assertTrue(p in lst)
def easy_test_with_line(self, line): ppp = [Vector2D(1.0, 0.0), Vector2D(2.5, 1.0), Vector2D(2.0, -1.5), Vector2D(0.0, -1.9), Vector2D(-0.5, 0.5), Vector2D(-1.0, 0.0), Vector2D(0.5, -1.0), Vector2D(0.5, 1.5)] rejected = find_constrained_redundant_points(ppp, line) self.assertEqual(len(rejected), 2) self.assertTrue(Vector2D(0.5, -1.0) in rejected) self.assertTrue(Vector2D(-0.5, 0.5) in rejected) for p in ppp: if p in rejected: ppp.remove(p) rejected = find_constrained_redundant_points(ppp, line) self.assertEqual(len(rejected), 1) self.assertTrue(Vector2D(0.5, 1.5) in rejected) for p in ppp: if p in rejected: ppp.remove(p) rejected = find_constrained_redundant_points(ppp, line) self.assertEqual(len(rejected), 1) self.assertTrue(Vector2D(1.0, 0.) in rejected)