From 948994a96df947cf0a1657ff62787e3406be6654 Mon Sep 17 00:00:00 2001 From: Matt Whitworth Date: Sat, 24 Feb 2024 12:18:35 +0000 Subject: [PATCH] no need for an array intermediate to return this statistic --- rrcf/rrcf.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rrcf/rrcf.py b/rrcf/rrcf.py index 3476739..a1d4799 100644 --- a/rrcf/rrcf.py +++ b/rrcf/rrcf.py @@ -616,7 +616,7 @@ def codisp(self, leaf): if leaf is self.root: return 0 node = leaf - results = [] + co_displacement = 0 for _ in range(node.d): parent = node.u if parent is None: @@ -627,10 +627,8 @@ def codisp(self, leaf): sibling = parent.l num_deleted = node.n displacement = sibling.n - result = (displacement / num_deleted) - results.append(result) + co_displacement = max(co_displacement, displacement / num_deleted) node = parent - co_displacement = max(results) return co_displacement