Update.
authorFrançois Fleuret <francois@fleuret.org>
Fri, 19 Jul 2024 04:45:23 +0000 (06:45 +0200)
committerFrançois Fleuret <francois@fleuret.org>
Fri, 19 Jul 2024 04:45:23 +0000 (06:45 +0200)
grids.py

index 400bf91..4f07d70 100755 (executable)
--- a/grids.py
+++ b/grids.py
@@ -137,11 +137,11 @@ class Grids(problem.Problem):
             self.task_half_fill,
             self.task_frame,
             self.task_detect,
-            self.task_count,
+            self.task_count,
             self.task_trajectory,
             self.task_bounce,
             self.task_scale,
-            self.task_symbols,
+            self.task_symbols,
             self.task_isometry,
             self.task_islands,
         ]
@@ -574,6 +574,7 @@ class Grids(problem.Problem):
             for n in range(nb_rec):
                 i1, j1, i2, j2 = r[n]
                 X[i1:i2, j1:j2] = c[n]
+                f_X[i1:i2, j1:j2] = c[n]
                 if n < nb_rec - 1:
                     f_X[i1, j1] = c[-1]
 
@@ -752,6 +753,7 @@ class Grids(problem.Problem):
                     f_X[i, j] = c[2]
                     if l <= 1:
                         X[i, j] = c[2]
+                        f_X[i, j] = c[1]
 
                     if l >= self.width:
                         break
@@ -788,7 +790,8 @@ class Grids(problem.Problem):
                 f_X[2 * i1 : 2 * i2, 2 * j1 : 2 * j2] = c[0]
 
             X[i, j] = c[1]
-            f_X[0:2, 0:2] = c[1]
+            # f_X[0:2, 0:2] = c[1]
+            f_X[i, j] = c[1]
 
     # @torch.compile
     def task_symbols(self, A, f_A, B, f_B):
@@ -1066,8 +1069,9 @@ class Grids(problem.Problem):
                     break
 
             X[...] = (A > 0) * c[0]
-            X[i, j] = c[1]
             f_X[...] = (A == A[i, j]) * c[1] + ((A > 0) & (A != A[i, j])) * c[0]
+            f_X[i, j] = X[i, j]
+            X[i, j] = c[1]
 
     # @torch.compile
     def task_stack(self, A, f_A, B, f_B):
@@ -1261,8 +1265,8 @@ if __name__ == "__main__":
     nb, nrow = 128, 4
     # nb, nrow = 8, 2
 
-    for t in grids.all_tasks:
-    for t in [grids.task_compute]:
+    for t in grids.all_tasks:
+        # for t in [grids.task_compute]:
         print(t.__name__)
         prompts, answers = grids.generate_prompts_and_answers_(nb, tasks=[t])
         grids.save_quiz_illustrations(