@@ -172,7 +172,7 @@ def _setdata(self, x, y, res):
172
172
self .lastcluster_idx = None
173
173
return
174
174
175
- def next (self ):
175
+ def __next__ (self ):
176
176
"""Cluster point with largest y-coordinate left, returning self.
177
177
178
178
next() always adds at least one additional point to the existing
@@ -217,7 +217,7 @@ def next(self):
217
217
else :
218
218
# insert right of nearest cluster
219
219
self .lastcluster_idx = nearest_cluster [0 ] + 1
220
- self .clusters = np .insert (self .clusters , self .lastcluster_idx , [test_idx , test_idx ], 0 )
220
+ self .clusters = np .insert (self .clusters , int ( self .lastcluster_idx ) , [test_idx , test_idx ], 0 )
221
221
return self
222
222
223
223
def makeclusters (self ):
@@ -286,8 +286,8 @@ def find_nearest_cluster(self, idx):
286
286
# Calculate which of the two nearest clusters is closer
287
287
distances = np .array (
288
288
[
289
- self .x [idx ] - self .x [self .clusters [near_idx - 1 , 1 ]],
290
- self .x [idx ] - self .x [self .clusters [near_idx , 0 ]],
289
+ self .x [idx ] - self .x [self .clusters [int ( near_idx ) - 1 , 1 ]],
290
+ self .x [idx ] - self .x [self .clusters [int ( near_idx ) , 0 ]],
291
291
]
292
292
)
293
293
if distances [0 ] < np .abs (distances [1 ]):
0 commit comments