From: Lukas Jiriste Date: Fri, 13 Sep 2024 12:59:34 +0000 (+0200) Subject: Make arrays of the same size in a better way X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=b2809e145b5d1509f2b9787c56695cfb84e68b5d;p=folflow.git Make arrays of the same size in a better way This way conversion of NaNs to integer types won't throw an exception. --- 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: