Skip to content

Commit c9371a0

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

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

Diff for: divide_and_conquer/convex_hull.py

+21-15
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def __hash__(self):
8282
return hash(self.x)
8383

8484

85-
def _construct_points(list_of_tuples: Union[List[Point], List[List[float]], Iterable[List[float]]]) -> List[Point]:
85+
def _construct_points(
86+
list_of_tuples: Union[List[Point], List[List[float]], Iterable[List[float]]]
87+
) -> List[Point]:
8688
"""
8789
constructs a list of points from an array-like object of numbers
8890
@@ -111,19 +113,18 @@ def _construct_points(list_of_tuples: Union[List[Point], List[List[float]], Iter
111113
[]
112114
"""
113115

114-
points = []
115-
if list_of_tuples:
116-
for p in list_of_tuples:
117-
if isinstance(p, Point):
118-
points.append(p)
119-
else:
120-
try:
121-
points.append(Point(p[0], p[1]))
122-
except (IndexError, TypeError):
123-
print(
124-
f"Ignoring deformed point {p}. All points"
125-
" must have at least 2 coordinates."
126-
)
116+
points: List[Point] = []
117+
for p in list_of_tuples:
118+
if isinstance(p, Point):
119+
points.append(p)
120+
else:
121+
try:
122+
points.append(Point(p[0], p[1]))
123+
except (IndexError, TypeError):
124+
print(
125+
f"Ignoring deformed point {p}. All points"
126+
" must have at least 2 coordinates."
127+
)
127128
return points
128129

129130

@@ -169,10 +170,15 @@ def _validate_input(points: Union[List[Point], List[List[float]]]) -> List[Point
169170
ValueError: Expecting an iterable object but got an non-iterable type 1
170171
"""
171172

173+
if not hasattr(points, "__iter__"):
174+
raise ValueError(
175+
f"Expecting an iterable object but got an non-iterable type {points}"
176+
)
177+
172178
if not points:
173179
raise ValueError(f"Expecting a list of points but got {points}")
174180

175-
return _construct_points(points)
181+
return _construct_points(points)
176182

177183

178184
def _det(a: Point, b: Point, c: Point) -> float:

0 commit comments

Comments
 (0)