From d7f80b810be20afa7bbe3cf247f6d047a6b16a90 Mon Sep 17 00:00:00 2001 From: espg Date: Tue, 17 Jun 2025 16:18:44 -0600 Subject: [PATCH] basic check to prevent 'orphan' clusters during prune --- pgamit/cluster.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pgamit/cluster.py b/pgamit/cluster.py index 615fa669..29c0deae 100644 --- a/pgamit/cluster.py +++ b/pgamit/cluster.py @@ -50,8 +50,12 @@ def prune(OC, central_points, method='minsize'): counts = mod.sum(axis=0) problems = np.sum(counts == 0) if problems == 0: - subset.append(i) - OC[i, :] = np.zeros(rowlength) + for row in mod: + if np.sum(row) > 0: + problems += ~(np.max(mod[:,row].sum(axis=0)) >= 2) + if problems == 0: + subset.append(i) + OC[i, :] = np.zeros(rowlength) # Cast subset list to pandas index dfIndex = pd.Index(subset) # Cast OC to pandas dataframe