task

Classes for representing and visualizing ARC tasks

source

ArcGrid

 ArcGrid (data:numpy.ndarray)

A single ARC grid

Type Details
data ndarray 2d array of integers (0–9)

Each ARC task is made up of pairs of input and output “grids”, which are 2-d arrays/matrices of integers

This class stores a single ARC grid as a numpy array. We can then easily visualise the grid using the plot() method

in_arr = np.random.randint(0,9, (4,4))
in_grid = ArcGrid(in_arr); in_grid
Grid(shape=(4, 4))
in_grid.plot()

The plot method also supports returning the base64-encoded string of the image directly

print(f"Base64 string: '{in_grid.plot(to_base64=True)[:20]}...'")
Base64 string: 'b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x01H'...'

ArcGrids support equality checks, making it easy to test predicted grids

assert in_grid != ArcGrid(np.ones((3,3), dtype=int))
assert in_grid == ArcGrid(in_arr)

source

ArcPair

 ArcPair (input_grid:__main__.ArcGrid|numpy.ndarray,
          output_grid:__main__.ArcGrid|numpy.ndarray)

A pair of ARC grids, typically [input, output]. Can also be used for [output, prediction]

Type Details
input_grid main.ArcGrid | numpy.ndarray Input grid
output_grid main.ArcGrid | numpy.ndarray Output grid
out_arr = np.random.randint(0, 9, (16,16))
pair = ArcPair(in_grid, ArcGrid(out_arr))
pair.plot()

The output grids in ARC tasks are often a different size to the input grids. When plotting pairs of grids, we can specify whether we want the grids to be on the same scale (i.e. one cell is equal size in both plots) or whether to rescale each grid to fill its half of the plot.

pair.plot(same_scale=False)


source

ArcTask

 ArcTask (task_id:str, split:str='train',
          data_dir:str|pathlib.Path|None=None)

An ARC task

Type Default Details
task_id str 8-digit task id
split str train ARC public dataset split (‘train’ or ‘eval’)
data_dir str | pathlib.Path | None None Path to ARC data directory (defaults to '/path/to/arcsolver/arc_data/data')
t = [f.split('.')[0] for f in os.listdir('../arcsolver/arc_data/data/training')][1]
task = ArcTask(t); task
ArcTask(id='c8cbb738', train_examples=3, test_examples=1)

An ArcTask stores the training and test examples, each as a list of ArcPair objects.

task.train
[ArcPair(input_shape=(12, 11), output_shape=(5, 5)),
 ArcPair(input_shape=(10, 8), output_shape=(3, 3)),
 ArcPair(input_shape=(12, 14), output_shape=(5, 5))]
task.plot()

Again, we can choose whether to rescale the plots

task.plot(same_scale=False)


source

get_task_files

 get_task_files (split:str)

Get list of files from either training or evaluation data.

Type Details
split str ‘train’ or ‘eval’
Returns list