<commit_before>from greengraph.map import Map
import numpy as np
from nose.tools import assert_equal
from mock import patch
import os

@patch('requests.get')
@patch('matplotlib.image.imread')
@patch('StringIO.StringIO')
def test_green(mock_get,mock_imread,mock_StringIO):

    def assert_images_equal(r,g,b,checkArray):
        testMap.pixels = np.dstack((r,g,b))
        np.testing.assert_array_equal(testMap.green(threshold),checkArray)

    lat = 50
    lon = 50
    testMap = Map(lat,lon)

    size = (400,400)
    trueArray = np.ones(size,dtype=bool)
    falseArray = np.zeros(size,dtype=bool)
    threshold = 1

    #Check the returned array is false everywhere when the value of the green pixels is identical to the values of the red and blue pixels
    green = np.ones(size)
    red = np.ones(size)
    blue = np.ones(size)
    assert_images_equal(red,green,blue,falseArray)

    #Check the returned array is false everywhere when the value of the green pixels is greater than the value of the blue pixels but less than the value of the red pixels
    blue = np.zeros(size)
    assert_images_equal(red,green,blue,falseArray)

    #As above but with red and blue pixels switched
    red = np.zeros(size)
    blue = np.ones(size)
    assert_images_equal(red,green,blue,falseArray)

    #Check the returned array is true everywhere when the value of the green pixels is greater than the value of the red and blue pixels
    blue = np.zeros(size)
    assert_images_equal(red,green,blue,trueArray)<commit_msg>Add test for count_green() method<commit_after>from greengraph.map import Map
import numpy as np
from nose.tools import assert_equal
from mock import patch
import os

@patch('requests.get')
@patch('matplotlib.image.imread')
@patch('StringIO.StringIO')
def test_green(mock_get,mock_imread,mock_StringIO):

    def assert_images_equal(r,g,b,checkArray):
        testMap.pixels = np.dstack((r,g,b))
        np.testing.assert_array_equal(testMap.green(threshold),checkArray)

    lat = 50
    lon = 50
    testMap = Map(lat,lon)

    size = (10,10)
    trueArray = np.ones(size,dtype=bool)
    falseArray = np.zeros(size,dtype=bool)
    threshold = 1

    #Check the returned array is false everywhere when the value of the green pixels is identical to the values of the red and blue pixels
    green = np.ones(size)
    red = np.ones(size)
    blue = np.ones(size)
    assert_images_equal(red,green,blue,falseArray)

    #Check the returned array is false everywhere when the value of the green pixels is greater than the value of the blue pixels but less than the value of the red pixels
    blue = np.zeros(size)
    assert_images_equal(red,green,blue,falseArray)

    #As above but with red and blue pixels switched
    red = np.zeros(size)
    blue = np.ones(size)
    assert_images_equal(red,green,blue,falseArray)

    #Check the returned array is true everywhere when the value of the green pixels is greater than the value of the red and blue pixels
    blue = np.zeros(size)
    assert_images_equal(red,green,blue,trueArray)

@patch('requests.get')
@patch('matplotlib.image.imread')
@patch('StringIO.StringIO')
def test_count_green(mock_get,mock_imread,mock_StringIO):

    lat = 50
    lon = 50
    testMap = Map(lat,lon)
    size = (10,10)

    #Test that the number sum of the green pixels with values greater than the values of both the red and blue pixels is zero for an empty image (zeros everywhere)
    green = np.zeros(size)
    red = np.zeros(size)
    blue = np.zeros(size)
    testMap.pixels = np.dstack((red,green,blue))
    assert_equal(testMap.count_green(),0)

    #Test that the sum of the green pixels with values greater than the values of both the red and blue pixels is n*m for a n*m*3 array with the value of green pixels equal to one and red/blue pixels equal to zero
    green = np.ones(size)
    testMap.pixels = np.dstack((red,green,blue))
    assert_equal(testMap.count_green(),size[0]*size[1])
{'fraction_non_alphanumeric': 0.0886011678090886, 'fraction_numerical': 0.008123889312008125, 'mean_word_length': 3.9810366624525915, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7290905', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1218, 'n_words': 404}