@@ -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
178184def _det (a : Point , b : Point , c : Point ) -> float :
@@ -353,7 +359,9 @@ def convex_hull_recursive(points: List[Point]) -> List[Point]:
353359 return sorted (convex_set )
354360
355361
356- def _construct_hull (points : List [Point ], left : Point , right : Point , convex_set : Set [Point ]) -> None :
362+ def _construct_hull (
363+ points : List [Point ], left : Point , right : Point , convex_set : Set [Point ]
364+ ) -> None :
357365 """
358366
359367 Parameters
0 commit comments