<jupyter_start><jupyter_text>Task 1: 6f8cd79b.json 1. Pull the json file in2. Pull out the matrix value for the training and testing data (inputs only)3. Convert to a numpy array4. Run through the function to change to desired output<jupyter_code>import numpy as np
import json
from IPython.display import Image<jupyter_output><empty_output><jupyter_text>Below is the image of the operation we wish to perform. We want to encase all the outer cells of the matrix with the numeric value corresponding to the colour light blue here, for any size matrix.<jupyter_code>Image("C://Users/oisin/Documents/College/PTAI/Assignment 3/ARC/ob_work/test_train_plots/6f8cd79b.PNG")<jupyter_output><empty_output><jupyter_text>The matrix interpretation of this is shown below<jupyter_code>with open("C://Users/oisin/Documents/College/PTAI/Assignment 3/ARC/data/training/6f8cd79b.json") as f:
    data = json.load(f)

data<jupyter_output><empty_output><jupyter_text>$8 = \text{light blue}$ , $0 = black$ The data can be split into training and testing<jupyter_code>train = data['train']
train = [i['input'] for i in train]
train = [np.array(i) for i in train]
train
test = data['test']
test = [i['input'] for i in test]
test = np.array(test)
test
def solve_6f8cd79b(x: np.array):
    '''
    
    This function takes in a numpy array filled with a single value (or colour) of size n x m 
    The function makes a 'wall' around the array and returns a new array surrounded by 8 (sky blue) on the top, bottom, right and left walls of the matrix
    Parameters:
        x (np.array): A numpy array
    
    >>> solve_6f8cd79b(train[0])
    array([[8, 8, 8],
           [8, 0, 8],
           [8, 8, 8]])
       
    >>> solve_6f8cd79b(np.zeros([10, 10]))
    array([[8., 8., 8., 8., 8., 8., 8., 8., 8., 8.],
           [8., 0., 0., 0., 0., 0., 0., 0., 0., 8.],
           [8., 0., 0., 0., 0., 0., 0., 0., 0., 8.],
           [8., 0., 0., 0., 0., 0., 0., 0., 0., 8.],
           [8., 0., 0., 0., 0., 0., 0., 0., 0., 8.],
           [8., 0., 0., 0., 0., 0., 0., 0., 0., 8.],
           [8., 0., 0., 0., 0., 0., 0., 0., 0., 8.],
           [8., 0., 0., 0., 0., 0., 0., 0., 0., 8.],
           [8., 0., 0., 0., 0., 0., 0., 0., 0., 8.],
           [8., 8., 8., 8., 8., 8., 8., 8., 8., 8.]])
    
    The function works on all of the three training inputs as well as the test input
    
    '''
    # Make a copy of x so we don't alter the original data
    y = x.copy()
    # Top row
    y[:, 0] = 8
    # Left most column
    y[0, :] = 8 
    # Bottom row
    y[-1, :] = 8 
    # Right most column
    y[:, -1] = 8
    # Pull back new matrix
    return y
# Testing function on training data
[solve_6f8cd79b(train[i]) for i in range(len(train))]
solve_6f8cd79b(test[0])<jupyter_output><empty_output><jupyter_text>Important to note that this function will also work on any numpy array passed into it of whatever n x m size filled with 0 values - It will also work on multi integer arrays but not the way the function was intended for when built. See below for example.<jupyter_code>solve_6f8cd79b(np.array([[1, 2, 3, 4, 5],[1, 2, 3, 4, 5],[1, 2, 3, 4, 5],[1, 2, 3, 4, 5],[1, 2, 3, 4, 5]]))
import doctest
doctest.testmod()
print(test)
print(solve_6f8cd79b(test[0]))<jupyter_output>[[8 8 8 8 8 8]
 [8 0 0 0 0 8]
 [8 0 0 0 0 8]
 [8 0 0 0 0 8]
 [8 0 0 0 0 8]
 [8 0 0 0 0 8]
 [8 8 8 8 8 8]]
{'fraction_non_alphanumeric': 0.15986900863352188, 'fraction_numerical': 0.07204525156296517, 'mean_word_length': 2.6561479869423286, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '596179', 'license': 'Apache-2.0', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1233, 'n_words': 484, 'path': 'ob_work/Task1_6f8cd79bjson.ipynb', 'repo_name': 'OisinB-2814/ARC', 'size': '3359'}