Hi mat, I appreciate your code! However in the following code, when I inspect the variable index, I found that the it is initialized once and then incremented in the loop, however it is never used to assign to anything. And this variable isn't passed to any other function, too. So I wonder is this a redundant variable? If so I think deleting it would make the logic clearer.
def group_points(self, points):
group_assignment = []
groups = []
group_index = 0
index = 0 # initialization
for point in points:
nearest_group_index = self._determine_nearest_group(point, groups)
if nearest_group_index == None:
# create new group
groups.append([point])
group_assignment.append(group_index)
group_index += 1
else:
group_assignment.append(nearest_group_index)
groups[nearest_group_index].append(point)
index += 1 #increment
return np.array(group_assignment)
Hi mat, I appreciate your code! However in the following code, when I inspect the variable
index
, I found that the it is initialized once and then incremented in the loop, however it is never used to assign to anything. And this variable isn't passed to any other function, too. So I wonder is this a redundant variable? If so I think deleting it would make the logic clearer.