From 2451ded37276d4829c53071c6843f6ee7161344d Mon Sep 17 00:00:00 2001
From: pswain <peter.swain@ed.ac.uk>
Date: Tue, 21 May 2024 12:51:57 +0100
Subject: [PATCH] fix(growth_rate): for running in parallel

Error was in asking for non-existing cells.
---
 src/wela/growth_rate.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/wela/growth_rate.py b/src/wela/growth_rate.py
index e95fbf8..b9bef1e 100644
--- a/src/wela/growth_rate.py
+++ b/src/wela/growth_rate.py
@@ -238,7 +238,11 @@ def run_parallel(t, volume, buddings_df, buddings, no_cells, config):
         t_batch = [t for i in range(batch_size)]
         for idx in range(0, no_cells, batch_size):
             print(f" mother {idx:d}/{no_cells-1:d}")
-            v_batch = [volume[idx + i, :] for i in range(batch_size)]
+            if idx + batch_size < no_cells:
+                v_batch = [volume[idx + i, :] for i in range(batch_size)]
+            else:
+                v_batch = [volume[i, :] for i in range(idx, no_cells)]
+                t_batch = [t for i in range(len(v_batch))]
             res_batch = pool.map(batch_GP, t_batch, v_batch)
             for ires in res_batch:
                 if ires:
-- 
GitLab