@@ -82,7 +82,9 @@ def __hash__(self):
82
82
return hash (self .x )
83
83
84
84
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 ]:
86
88
"""
87
89
constructs a list of points from an array-like object of numbers
88
90
@@ -111,19 +113,18 @@ def _construct_points(list_of_tuples: Union[List[Point], List[List[float]], Iter
111
113
[]
112
114
"""
113
115
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
+ )
127
128
return points
128
129
129
130
@@ -169,10 +170,15 @@ def _validate_input(points: Union[List[Point], List[List[float]]]) -> List[Point
169
170
ValueError: Expecting an iterable object but got an non-iterable type 1
170
171
"""
171
172
173
+ if not hasattr (points , "__iter__" ):
174
+ raise ValueError (
175
+ f"Expecting an iterable object but got an non-iterable type { points } "
176
+ )
177
+
172
178
if not points :
173
179
raise ValueError (f"Expecting a list of points but got { points } " )
174
180
175
- return _construct_points (points )
181
+ return _construct_points (points )
176
182
177
183
178
184
def _det (a : Point , b : Point , c : Point ) -> float :
0 commit comments