Skip to content

Commit db5b1fa

Browse files
author
Simon Lammer
committed
Fix build errors
1 parent 3a0316f commit db5b1fa

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Diff for: divide_and_conquer/convex_hull.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from typing import Iterable, List, Set, Union
1717

18+
1819
class Point:
1920
"""
2021
Defines a 2-d point for use by all convex-hull algorithms.
@@ -82,7 +83,9 @@ def __hash__(self):
8283
return hash(self.x)
8384

8485

85-
def _construct_points(list_of_tuples: Union[List[Point], List[List[float]], Iterable[List[float]]]) -> List[Point]:
86+
def _construct_points(
87+
list_of_tuples: Union[List[Point], List[List[float]], Iterable[List[float]]]
88+
) -> List[Point]:
8689
"""
8790
constructs a list of points from an array-like object of numbers
8891
@@ -111,7 +114,7 @@ def _construct_points(list_of_tuples: Union[List[Point], List[List[float]], Iter
111114
[]
112115
"""
113116

114-
points = []
117+
points: List[Point] = []
115118
if list_of_tuples:
116119
for p in list_of_tuples:
117120
if isinstance(p, Point):
@@ -169,10 +172,15 @@ def _validate_input(points: Union[List[Point], List[List[float]]]) -> List[Point
169172
ValueError: Expecting an iterable object but got an non-iterable type 1
170173
"""
171174

175+
if not hasattr(points, "__iter__"):
176+
raise ValueError(
177+
f"Expecting an iterable object but got an non-iterable type {points}"
178+
)
179+
172180
if not points:
173181
raise ValueError(f"Expecting a list of points but got {points}")
174182

175-
return _construct_points(points)
183+
return _construct_points(points)
176184

177185

178186
def _det(a: Point, b: Point, c: Point) -> float:
@@ -353,7 +361,9 @@ def convex_hull_recursive(points: List[Point]) -> List[Point]:
353361
return sorted(convex_set)
354362

355363

356-
def _construct_hull(points: List[Point], left: Point, right: Point, convex_set: Set[Point]) -> None:
364+
def _construct_hull(
365+
points: List[Point], left: Point, right: Point, convex_set: Set[Point]
366+
) -> None:
357367
"""
358368
359369
Parameters

0 commit comments

Comments
 (0)