From 74cc4114d7f897b374af72f0a91d9ad3152405db Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Thu, 14 Oct 2021 22:45:59 +0100
Subject: [PATCH] fixed resolution to be set on the fly if it's zero

---
 binarycpython/utils/grid.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 2da217446..12cd6f0bb 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -2312,8 +2312,11 @@ class Population:
             else:
                 # use resolution passed in
                 self._add_code(
-                    "for {}_sample_number in range({}):".format(
-                        grid_variable["name"], grid_variable["resolution"]
+                    "for {}_sample_number in range({} if {} != 0 else max(0,len(sampled_values_{})-1)):".format(
+                        grid_variable["name"],
+                        grid_variable["resolution"],
+                        grid_variable["resolution"],
+                        grid_variable["name"],
                     )
                     + "\n"
                 )
-- 
GitLab