Make arrays of the same size in a better way trunk
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 13 Sep 2024 12:59:34 +0000 (14:59 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 13 Sep 2024 12:59:34 +0000 (14:59 +0200)
This way conversion of NaNs to integer types won't throw an exception.

povodi.py

index 08cb2afac0153f91aae08eac9b2cc6a235db57af..19c02dea6366e6476719c3f7e0ba4810aefa0bf2 100644 (file)
--- 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: