Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/diffpy/srmise/dataclusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _setdata(self, x, y, res):
self.lastcluster_idx = None
return

def next(self):
def __next__(self):
"""Cluster point with largest y-coordinate left, returning self.

next() always adds at least one additional point to the existing
Expand Down Expand Up @@ -217,7 +217,7 @@ def next(self):
else:
# insert right of nearest cluster
self.lastcluster_idx = nearest_cluster[0] + 1
self.clusters = np.insert(self.clusters, self.lastcluster_idx, [test_idx, test_idx], 0)
self.clusters = np.insert(self.clusters, int(self.lastcluster_idx), [test_idx, test_idx], 0)
return self

def makeclusters(self):
Expand Down Expand Up @@ -286,8 +286,8 @@ def find_nearest_cluster(self, idx):
# Calculate which of the two nearest clusters is closer
distances = np.array(
[
self.x[idx] - self.x[self.clusters[near_idx - 1, 1]],
self.x[idx] - self.x[self.clusters[near_idx, 0]],
self.x[idx] - self.x[self.clusters[int(near_idx) - 1, 1]],
self.x[idx] - self.x[self.clusters[int(near_idx), 0]],
]
)
if distances[0] < np.abs(distances[1]):
Expand Down
Loading