<commit_before>import matplotlib.pyplot as plt
import numpy as np
import random

JITTER = False

world = np.zeros((256, 256));
nodex = range(2, 256, 4)
nodey = range(2, 256, 4)

#Jitter
if JITTER:
    jnode = [(y+random.randint(-3, 3), x+random.randint(-3, 3)) for y in nodey for x in nodex]
    jnode = [(y, x) for (y, x) in jnode if y>=0 and y<256 and x>=0 and x<256]
else:
    jnode = [(y, x) for y in nodey for x in nodex]


for coor in jnode:
    world[coor[0]][coor[1]] = 1

plt.gray()

plt.imshow(world)
plt.show()

<commit_msg>Made changes to environment figure creator<commit_after>import matplotlib.pyplot as plt
import numpy as np
import random
import os
from math import floor
from scipy.misc import imsave

#Params
#Node radius is how big to make the dot.
#Radius of 1 means it's expanded to a square that's 3 by 3, with orig dot in center
#Note: there is a change for nodes to overlap in the image
nodeRadius = 1

jitterVal = 9
worldSize = (256, 256) #y by x
bidsSize = (20, 20) #y by x, number of bids nodes in world
outputDir = "./envFigs/"
filename = "envFig_"
ext = ".png"

def makeFig(jitterVal, worldSize, bidsSize, nodeRadius, outputFilename):
    world = np.zeros(worldSize);
    spacing = (float(worldSize[0])/bidsSize[0], float(worldSize[1])/bidsSize[1])

    #Make sure radius isn't going to make node go off screen without jitter
    if floor(float(spacing[0])/2) <= nodeRadius:
        print "Radius too big, max val", floor(float(spacing[0]/2)) - 1
        return
    #Start spacing halfway spacing
    nodes = (list(np.arange(float(spacing[0])/2, worldSize[0], spacing[0])),
             list(np.arange(float(spacing[1])/2, worldSize[1], spacing[1])))

    #Jitter
    jnode = [(floor(y+random.randint(-1 * jitterVal, jitterVal)), floor(x+random.randint(-1 * jitterVal, jitterVal))) for y in nodes[0] for x in nodes[1]]
    #Make sure that boundary conditions consider node radius as well.
    #A node will only be shown if the node in it's entirety is in bounds
    jnode = [(y, x) for (y, x) in jnode if y - nodeRadius>=0 and y + nodeRadius<worldSize[0] and x - nodeRadius>=0 and x + nodeRadius<worldSize[1]]

    #if JITTER:
    #    jnode = [(floor(y+random.randint(-1 * jitterVal, jitterVal)), floor(x+random.randint(-1 * jitterVal, jitterVal))) for y in nodes[0] for x in nodes[1]]
    #    jnode = [(y, x) for (y, x) in jnode if y>=0 and y<worldSize[0] and x>=0 and x<worldSize[1]]
    #else:
    #    jnode = [(floor(y), floor(x)) for y in nodes[0] for x in nodes[1]]


    for coor in jnode:
        for curRadius in range(nodeRadius + 1):
            #Square
            for horL in range(int(coor[1]-curRadius), int(coor[1]+curRadius+1)):
                #Top line
                world[coor[0]-curRadius][horL] = 1
                #Bot line
                world[coor[0]+curRadius][horL] = 1
            for vertL in range(int(coor[0]-curRadius), int(coor[0]+curRadius+1)):
                #Left line
                world[vertL][coor[1]-curRadius] = 1
                #Right line
                world[vertL][coor[1]+curRadius] = 1


    #save img
    imsave(outputFilename, world)


if not os.path.exists(outputDir):
    os.makedirs(outputDir)

#No jitter
makeFig(0, worldSize, bidsSize, nodeRadius, outputDir + filename + "nj" + ext)
#jitter
makeFig(jitterVal, worldSize, bidsSize, nodeRadius, outputDir + filename + "j" + ext)

{'fraction_non_alphanumeric': 0.13256227758007116, 'fraction_numerical': 0.028766310794780547, 'mean_word_length': 3.195273631840796, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7538814', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1171, 'n_words': 385}