def test_polygon_length_four_edges_returns_4(self): e1 = Edge(Vertex(0, 0), Vertex(1, 0)) e2 = Edge(Vertex(1, 0), Vertex(1, 1)) e3 = Edge(Vertex(0, 1), Vertex(1, 1)) e4 = Edge(Vertex(0, 0), Vertex(0, 1)) polygon = [e1, e2, e3, e4] self.assertEqual(polygon_length(polygon), 4)
def test_polygon_length_four_edges_returns_4(self): e1 = Edge(Vertex(0, 0), Vertex(1, 0)) e2 = Edge(Vertex(1, 0), Vertex(1, 1)) e3 = Edge(Vertex(0, 1), Vertex(1, 1)) e4 = Edge(Vertex(0, 0), Vertex(0, 1)) polygon = [e1, e2, e3, e4] self.assertEqual(polygon_length(polygon), 4)
def _score(self, polygon, data): edges = polygon_to_array(polygon) if self.config.gpu: cost = cost_function_gpu(data, edges) else: cost = cost_function(data, edges) # try: length_factor = 1 / polygon_length(polygon) return (cost**self.config.alpha) * (length_factor**self.config.beta)
def _score(self, polygon, data): edges = polygon_to_array(polygon) if self.config.gpu: cost = cost_function_gpu(data, edges) else: cost = cost_function(data, edges) # try: length_factor = 1 / polygon_length(polygon) return (cost ** self.config.alpha) * (length_factor ** self.config.beta)