From b2809e145b5d1509f2b9787c56695cfb84e68b5d Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Fri, 13 Sep 2024 14:59:34 +0200 Subject: [PATCH] Make arrays of the same size in a better way This way conversion of NaNs to integer types won't throw an exception. --- povodi.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/povodi.py b/povodi.py index 08cb2af..19c02de 100644 --- a/povodi.py +++ b/povodi.py @@ -38,10 +38,8 @@ def append_eligible_neighbours(to_calc, height_map, calced, multi_ind): def povodi(height_map): height_map = np.array(height_map) - calced = height_map.astype('bool') - calced.fill(0) - result = height_map.astype("uint32") - result.fill(1) + calced = np.zeros(height_map.shape, dtype='bool') + result = np.ones(height_map.shape, dtype="uint32") to_calc = [] it = np.nditer(height_map, flags=['multi_index']) for el in it: -- 2.30.2