<commit_before>from PIL import Image, ImageDraw
from beautifulhue.api import Bridge
from lib import ColorHelper, Converter
import pyscreenshot as ImageGrab
import time
import colorsys
import math
import os

sample_rate = 5                             # Frames per Second. Philips Hue documentation recommends no more than 10 requests per second, so try and stay below 10.
sample_size = 50                            # Resize the screenshot to this size
brightness_threshold = 5                    # Turn the lights off completely when brightness below this value (max 255)
density_threshold = 0.01                    # Ignore colours below a certain density
num_globes = 3                              # Number of hue globes to update
ip = os.environ['HUE_BRIDGE_IP']            # IP of your Hue Bridge. nano ~/.bash_profile and add: export HUE_BRIDGE_IP="XXX.XXX.XXX.XXX"
username = os.environ['HUE_USERNAME']       # Username set up on your Hue Bridge.

bridge = Bridge(device={ 'ip': ip }, user={ 'name': username })
converter = Converter()

def get_colors(image, resize, numcolors):
    image = image.resize((resize, resize))
    result = image.convert('P', palette=Image.ADAPTIVE, colors=numcolors)
    result.putalpha(0)
    #result.save('screenshot.gif')
    colors = result.getcolors()

    return sorted(colors, reverse=True)

def colour_density(val,size):
    return val/math.pow(size,2)

def run():
    screenshot = ImageGrab.grab()
    colors = get_colors(screenshot, sample_size, num_globes)
    colors = [c for c in colors]
    colors += [None]*(3-len(colors))
    x = 0

    for color in colors:
        x = x+1
        if color is None:
            resource = {
                'which': x,
                'data':{
                    'state':{'on':False}
                }
            }
        else:
            amt = color[0]
            r = color[1][0]
            g = color[1][1]
            b = color[1][2]

            hsv = colorsys.rgb_to_hsv(r, g, b)<commit_msg>Changed variable names<commit_after>from PIL import Image, ImageDraw
from beautifulhue.api import Bridge
from lib import ColorHelper, Converter
import pyscreenshot as ImageGrab
import time
import colorsys
import math
import os

sample_rate = 5                             # Frames per Second. Philips Hue documentation recommends no more than 10 requests per second, so try and stay below 10.
sample_size = 50                            # Resize the screenshot to this size
brightness_threshold = 5                    # Turn the lights off completely when brightness below this value (max 255)
density_threshold = 0.01                    # Ignore colours below a certain density
num_globes = 3                              # Number of hue globes to update
ip = os.environ['HUE_BRIDGE_IP']            # IP of your Hue Bridge. nano ~/.bash_profile and add: export HUE_BRIDGE_IP="XXX.XXX.XXX.XXX"
username = os.environ['HUE_USERNAME']       # Username set up on your Hue Bridge.

bridge = Bridge(device={ 'ip': ip }, user={ 'name': username })
converter = Converter()

def get_colours(image, resize, palettesize):
    image = image.resize((resize, resize))
    result = image.convert('P', palette=Image.ADAPTIVE, colors=palettesize)
    result.putalpha(0)
    colors = result.getcolors()

    return sorted(colors, reverse=True)

def colour_density(val,size):
    return val/math.pow(size,2)

def run():
    screenshot = ImageGrab.grab()
    colors = get_colours(screenshot, sample_size, num_globes)
    colors = [c for c in colors]
    colors += [None]*(3-len(colors))
    x = 0

    for color in colors:
        x = x+1
        if color is None:
            resource = {
                'which': x,
                'data':{
                    'state':{'on':False}
                }
            }
        else:
            amt = color[0]
            r = color[1][0]
            g = color[1][1]
            b = color[1][2]

            hsv = colorsys.rgb_to_hsv(r, g, b)
{'fraction_non_alphanumeric': 0.09529828109201213, 'fraction_numerical': 0.013650151668351871, 'mean_word_length': 2.2014563106796117, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1911654', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1148, 'n_words': 370}