Fixed a bug when there are no squares.
authorFrancois Fleuret <francois@fleuret.org>
Sat, 30 Jul 2022 06:06:11 +0000 (08:06 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Sat, 30 Jul 2022 06:06:11 +0000 (08:06 +0200)
picoclvr.py

index 8201f5d..3ecbf3a 100755 (executable)
@@ -173,9 +173,14 @@ def descr2properties(descr, height, width):
             seen[x] = (color_id[x], k // width, k % width)
 
     square_infos = tuple(zip(*seen.values()))
-    square_c = torch.tensor(square_infos[0])
-    square_i = torch.tensor(square_infos[1])
-    square_j = torch.tensor(square_infos[2])
+    if square_infos:
+        square_c = torch.tensor(square_infos[0])
+        square_i = torch.tensor(square_infos[1])
+        square_j = torch.tensor(square_infos[2])
+    else:
+        square_c = torch.tensor([])
+        square_i = torch.tensor([])
+        square_j = torch.tensor([])
 
     s = all_properties(height, width, len(seen), square_i, square_j, square_c)