I am trying to remove points from a point cloud that are too close to each other. My input is an mx3 matrix where the columns represent xyz coordinates. Code is as follows:

```
def remove_duplicates(points, threshold):
    # Convert to numpy
    points = np.array(points)

    # Round to within the threshold
    rounded_points = points
    if threshold > 0.0:
        rounded_points = np.round(points/threshold)*threshold

    # Remove duplicate points
    point_tuples = [tuple(point) for point in rounded_points]
    unique_rounded_points, unique_indices = np.unique(point_tuples, return_index = True)

    points = points[unique_indices]

    return points

```

The issue I am running into is that unique\_indices contains values larger than the length of points (2265 and 1000 for my test data). Am I doing something wrong, or is this a bug in NumPy?

Edit: I should note that for very small inputs (tried 27 points), unique() appears to work correctly.