import os
import sys
import time
import traceback
import project1_Copy as p1
import numpy as np

verbose = False

def green(s):
    return '\033[1;32m%s\033[m' % s

def yellow(s):
    return '\033[1;33m%s\033[m' % s

def red(s):
    return '\033[1;31m%s\033[m' % s

def log(*m):
    print(" ".join(map(str, m)))

def log_exit(*m):
    log(red("ERROR:"), *m)
    exit(1)


def check_real(ex_name, f, exp_res, *args):
    try:
        res = f(*args)
    except NotImplementedError:
        log(red("FAIL"), ex_name, ": not implemented")
        return True
    if not np.isreal(res):
        log(red("FAIL"), ex_name, ": does not return a real number, type: ", type(res))
        return True
    if res != exp_res:
        log(red("FAIL"), ex_name, ": incorrect answer. Expected", exp_res, ", got: ", res)
        return True


def equals(x, y):
    if type(y) == np.ndarray:
        return (x == y).all()
    return x == y

def check_tuple(ex_name, f, exp_res, *args, **kwargs):
    try:
        res = f(*args, **kwargs)
    except NotImplementedError:
        log(red("FAIL"), ex_name, ": not implemented")
        return True
    if not type(res) == tuple:
        log(red("FAIL"), ex_name, ": does not return a tuple, type: ", type(res))
        return True
    if not len(res) == len(exp_res):
        log(red("FAIL"), ex_name, ": expected a tuple of size ", len(exp_res), " but got tuple of size", len(res))
        return True
    if not all(equals(x, y) for x, y in zip(res, exp_res)):
        log(red("FAIL"), ex_name, ": incorrect answer. Expected", exp_res, ", got: ", res)
        return True

def check_array(ex_name, f, exp_res, *args):
    try:
        res = f(*args)
    except NotImplementedError:
        log(red("FAIL"), ex_name, ": not implemented")
        return True
    if not type(res) == np.ndarray:
        log(red("FAIL"), ex_name, ": does not return a numpy array, type: ", type(res))
        return True
    if not len(res) == len(exp_res):
        log(red("FAIL"), ex_name, ": expected an array of shape ", exp_res.shape, " but got array of shape", res.shape)
        return True
    if not all(equals(x, y) for x, y in zip(res, exp_res)):
        log(red("FAIL"), ex_name, ": incorrect answer. Expected", exp_res, ", got: ", res)
        return True

def check_list(ex_name, f, exp_res, *args):
    try:
        res = f(*args)
    except NotImplementedError:
        log(red("FAIL"), ex_name, ": not implemented")
        return True
    if not type(res) == list:
        log(red("FAIL"), ex_name, ": does not return a list, type: ", type(res))
        return True
    if not len(res) == len(exp_res):
        log(red("FAIL"), ex_name, ": expected a list of size ", len(exp_res), " but got list of size", len(res))
        return True
    if not all(equals(x, y) for x, y in zip(res, exp_res)):
        log(red("FAIL"), ex_name, ": incorrect answer. Expected", exp_res, ", got: ", res)
        return True


def check_get_order():
    ex_name = "Get order"
    if check_list(
            ex_name, p1.get_order,
            [0], 1):
        log("You should revert `get_order` to its original implementation for this test to pass")
        return
    if check_list(
            ex_name, p1.get_order,
            [1, 0], 2):
        log("You should revert `get_order` to its original implementation for this test to pass")
        return
    log(green("PASS"), ex_name, "")


def check_hinge_loss_single():
    ex_name = "Hinge loss single"

    feature_vector = np.array([1, 2])
    label, theta, theta_0 = 1, np.array([-1, 1]), -0.2
    exp_res = 1 - 0.8
    if check_real(
            ex_name, p1.hinge_loss_single,
            exp_res, feature_vector, label, theta, theta_0):
        return
    log(green("PASS"), ex_name, "")


def check_hinge_loss_full():
    ex_name = "Hinge loss full"

    feature_vector = np.array([[1, 2], [1, 2]])
    label, theta, theta_0 = np.array([1, 1]), np.array([-1, 1]), -0.2
    exp_res = 1 - 0.8
    if check_real(
            ex_name, p1.hinge_loss_full,
            exp_res, feature_vector, label, theta, theta_0):
        return

    log(green("PASS"), ex_name, "")


def check_perceptron_single_update():
    ex_name = "Perceptron single update"

    feature_vector = np.array([1, 2])
    label, theta, theta_0 = 1, np.array([-1, 1]), -1.5
    exp_res = (np.array([0, 3]), -0.5)
    if check_tuple(
            ex_name, p1.perceptron_single_step_update,
            exp_res, feature_vector, label, theta, theta_0):
        return

    feature_vector = np.array([1, 2])
    label, theta, theta_0 = 1, np.array([-1, 1]), -1
    exp_res = (np.array([0, 3]), 0)
    if check_tuple(
            ex_name + " (boundary case)", p1.perceptron_single_step_update,
            exp_res, feature_vector, label, theta, theta_0):
        return

    log(green("PASS"), ex_name, "")


def check_perceptron():
    ex_name = "Perceptron"

    feature_matrix = np.array([[1, 2]])
    labels = np.array([1])
    T = 1
    exp_res = (np.array([1, 2]), 1)
    if check_tuple(
            ex_name, p1.perceptron,
            exp_res, feature_matrix, labels, T):
        return

    feature_matrix = np.array([[1, 2], [-1, 0]])
    labels = np.array([1, 1])
    T = 1
    exp_res = (np.array([0, 2]), 2)
    if check_tuple(
            ex_name, p1.perceptron,
            exp_res, feature_matrix, labels, T):
        return

    feature_matrix = np.array([[1, 2]])
    labels = np.array([1])
    T = 2
    exp_res = (np.array([1, 2]), 1)
    if check_tuple(
            ex_name, p1.perceptron,
            exp_res, feature_matrix, labels, T):
        return

    feature_matrix = np.array([[1, 2], [-1, 0]])
    labels = np.array([1, 1])
    T = 2
    exp_res = (np.array([0, 2]), 2)
    if check_tuple(
            ex_name, p1.perceptron,
            exp_res, feature_matrix, labels, T):
        return

    log(green("PASS"), ex_name, "")


def check_average_perceptron():
    ex_name = "Average perceptron"

    feature_matrix = np.array([[1, 2]])
    labels = np.array([1])
    T = 1
    exp_res = (np.array([1, 2]), 1)
    if check_tuple(
            ex_name, p1.average_perceptron,
            exp_res, feature_matrix, labels, T):
        return

    feature_matrix = np.array([[1, 2], [-1, 0]])
    labels = np.array([1, 1])
    T = 1
    exp_res = (np.array([-0.5, 1]), 1.5)
    if check_tuple(
            ex_name, p1.average_perceptron,
            exp_res, feature_matrix, labels, T):
        return

    feature_matrix = np.array([[1, 2]])
    labels = np.array([1])
    T = 2
    exp_res = (np.array([1, 2]), 1)
    if check_tuple(
            ex_name, p1.average_perceptron,
            exp_res, feature_matrix, labels, T):
        return

    feature_matrix = np.array([[1, 2], [-1, 0]])
    labels = np.array([1, 1])
    T = 2
    exp_res = (np.array([-0.25, 1.5]), 1.75)
    if check_tuple(
            ex_name, p1.average_perceptron,
            exp_res, feature_matrix, labels, T):
        return

    log(green("PASS"), ex_name, "")


def check_pegasos_single_update():
    ex_name = "Pegasos single update"

    feature_vector = np.array([1, 2])
    label, theta, theta_0 = 1, np.array([-1, 1]), -1.5
    L = 0.2
    eta = 0.1
    exp_res = (np.array([-0.88, 1.18]), -1.4)
    if check_tuple(
            ex_name, p1.pegasos_single_step_update,
            exp_res,
            feature_vector, label, L, eta, theta, theta_0):
        return

    feature_vector = np.array([1, 1])
    label, theta, theta_0 = 1, np.array([-1, 1]), 1
    L = 0.2
    eta = 0.1
    exp_res = (np.array([-0.88, 1.08]), 1.1)
    if check_tuple(
            ex_name +  " (boundary case)", p1.pegasos_single_step_update,
            exp_res,
            feature_vector, label, L, eta, theta, theta_0):
        return

    feature_vector = np.array([1, 2])
    label, theta, theta_0 = 1, np.array([-1, 1]), -2
    L = 0.2
    eta = 0.1
    exp_res = (np.array([-0.88, 1.18]), -1.9)
    if check_tuple(
            ex_name, p1.pegasos_single_step_update,
            exp_res,
            feature_vector, label, L, eta, theta, theta_0):
        return

    log(green("PASS"), ex_name, "")


def check_pegasos():
    ex_name = "Pegasos"

    feature_matrix = np.array([[1, 2]])
    labels = np.array([1])
    T = 1
    L = 0.2
    exp_res = (np.array([1, 2]), 1)
    if check_tuple(
            ex_name, p1.pegasos,
            exp_res, feature_matrix, labels, T, L):
        return

    feature_matrix = np.array([[1, 1], [1, 1]])
    labels = np.array([1, 1])
    T = 1
    L = 1
    exp_res = (np.array([1-1/np.sqrt(2), 1-1/np.sqrt(2)]), 1)
    if check_tuple(
            ex_name, p1.pegasos,
            exp_res, feature_matrix, labels, T, L):
        return

    log(green("PASS"), ex_name, "")


def check_classify():
    ex_name = "Classify"

    feature_matrix = np.array([[1, 1], [1, 1], [1, 1]])
    theta = np.array([1, 1])
    theta_0 = 0
    exp_res = np.array([1, 1, 1])
    if check_array(
            ex_name, p1.classify,
            exp_res, feature_matrix, theta, theta_0):
        return

    feature_matrix = np.array([[-1, 1]])
    theta = np.array([1, 1])
    theta_0 = 0
    exp_res = np.array([-1])
    if check_array(
            ex_name + " (boundary case)", p1.classify,
            exp_res, feature_matrix, theta, theta_0):
        return

    log(green("PASS"), ex_name, "")

def check_classifier_accuracy():
    ex_name = "Classifier accuracy"

    train_feature_matrix = np.array([[1, 0], [1, -1], [2, 3]])
    val_feature_matrix = np.array([[1, 1], [2, -1]])
    train_labels = np.array([1, -1, 1])
    val_labels = np.array([-1, 1])
    exp_res = 1, 0
    T=1
    if check_tuple(
            ex_name, p1.classifier_accuracy,
            exp_res,
            p1.perceptron,
            train_feature_matrix, val_feature_matrix,
            train_labels, val_labels,
            T=T):
        return

    train_feature_matrix = np.array([[1, 0], [1, -1], [2, 3]])
    val_feature_matrix = np.array([[1, 1], [2, -1]])
    train_labels = np.array([1, -1, 1])
    val_labels = np.array([-1, 1])
    exp_res = 1, 0
    T=1
    L=0.2
    if check_tuple(
            ex_name, p1.classifier_accuracy,
            exp_res,
            p1.pegasos,
            train_feature_matrix, val_feature_matrix,
            train_labels, val_labels,
            T=T, L=L):
        return

    log(green("PASS"), ex_name, "")

def check_bag_of_words():
    ex_name = "Bag of words"

    texts = [
        "He loves to walk on the beach",
        "There is nothing better"]

    try:
        res = p1.bag_of_words(texts)
    except NotImplementedError:
        log(red("FAIL"), ex_name, ": not implemented")
        return
    if not type(res) == dict:
        log(red("FAIL"), ex_name, ": does not return a tuple, type: ", type(res))
        return

    vals = sorted(res.values())
    exp_vals = list(range(len(res.keys())))
    if not vals == exp_vals:
        log(red("FAIL"), ex_name, ": wrong set of indices. Expected: ", exp_vals, " got ", vals)
        return

    log(green("PASS"), ex_name, "")

    keys = sorted(res.keys())
    exp_keys = ['beach', 'better', 'he', 'is', 'loves', 'nothing', 'on', 'the', 'there', 'to', 'walk']
    stop_keys = ['beach', 'better', 'loves', 'nothing', 'walk']

    if keys == exp_keys:
        log(yellow("WARN"), ex_name, ": does not remove stopwords:", [k for k in keys if k not in stop_keys])
    elif keys == stop_keys:
        log(green("PASS"), ex_name, " stopwords removed")
    else:
        log(red("FAIL"), ex_name, ": keys are missing:", [k for k in stop_keys if k not in keys], " or are not unexpected:", [k for k in keys if k not in stop_keys])


def check_extract_bow_feature_vectors():
    ex_name = "Extract bow feature vectors"
    texts = [
        "He loves her ",
        "He really really loves her"]
    keys = ["he", "loves", "her", "really"]
    dictionary = {k:i for i, k in enumerate(keys)}
    exp_res = np.array(
        [[1, 1, 1, 0],
        [1, 1, 1, 1]])
    non_bin_res = np.array(
        [[1, 1, 1, 0],
        [1, 1, 1, 2]])


    try:
        res = p1.extract_bow_feature_vectors(texts, dictionary)
    except NotImplementedError:
        log(red("FAIL"), ex_name, ": not implemented")
        return

    if not type(res) == np.ndarray:
        log(red("FAIL"), ex_name, ": does not return a numpy array, type: ", type(res))
        return
    if not len(res) == len(exp_res):
        log(red("FAIL"), ex_name, ": expected an array of shape ", exp_res.shape, " but got array of shape", res.shape)
        return

    log(green("PASS"), ex_name)

    if (res == exp_res).all():
        log(yellow("WARN"), ex_name, ": uses binary indicators as features")
    elif (res == non_bin_res).all():
        log(green("PASS"), ex_name, ": correct non binary features")
    else:
        log(red("FAIL"), ex_name, ": unexpected feature matrix")
        return

def main():
    log(green("PASS"), "Import project1")
    try:
        check_get_order()
        check_hinge_loss_single()
        check_hinge_loss_full()
        check_perceptron_single_update()
        check_perceptron()
        check_average_perceptron()
        check_pegasos_single_update()
        check_pegasos()
        check_classify()
        check_classifier_accuracy()
        check_bag_of_words()
        check_extract_bow_feature_vectors()
    except Exception:
        log_exit(traceback.format_exc())

if __name__ == "__main__":
    main()

[((113, 21, 113, 37), 'numpy.array', 'np.array', ({(113, 30, 113, 36): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((126, 21, 126, 47), 'numpy.array', 'np.array', ({(126, 30, 126, 46): '[[1, 2], [1, 2]]'}, {}), '([[1, 2], [1, 2]])', True, 'import numpy as np\n'), ((140, 21, 140, 37), 'numpy.array', 'np.array', ({(140, 30, 140, 36): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((148, 21, 148, 37), 'numpy.array', 'np.array', ({(148, 30, 148, 36): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((162, 21, 162, 39), 'numpy.array', 'np.array', ({(162, 30, 162, 38): '[[1, 2]]'}, {}), '([[1, 2]])', True, 'import numpy as np\n'), ((163, 13, 163, 26), 'numpy.array', 'np.array', ({(163, 22, 163, 25): '[1]'}, {}), '([1])', True, 'import numpy as np\n'), ((171, 21, 171, 48), 'numpy.array', 'np.array', ({(171, 30, 171, 47): '[[1, 2], [-1, 0]]'}, {}), '([[1, 2], [-1, 0]])', True, 'import numpy as np\n'), ((172, 13, 172, 29), 'numpy.array', 'np.array', ({(172, 22, 172, 28): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((180, 21, 180, 39), 'numpy.array', 'np.array', ({(180, 30, 180, 38): '[[1, 2]]'}, {}), '([[1, 2]])', True, 'import numpy as np\n'), ((181, 13, 181, 26), 'numpy.array', 'np.array', ({(181, 22, 181, 25): '[1]'}, {}), '([1])', True, 'import numpy as np\n'), ((189, 21, 189, 48), 'numpy.array', 'np.array', ({(189, 30, 189, 47): '[[1, 2], [-1, 0]]'}, {}), '([[1, 2], [-1, 0]])', True, 'import numpy as np\n'), ((190, 13, 190, 29), 'numpy.array', 'np.array', ({(190, 22, 190, 28): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((204, 21, 204, 39), 'numpy.array', 'np.array', ({(204, 30, 204, 38): '[[1, 2]]'}, {}), '([[1, 2]])', True, 'import numpy as np\n'), ((205, 13, 205, 26), 'numpy.array', 'np.array', ({(205, 22, 205, 25): '[1]'}, {}), '([1])', True, 'import numpy as np\n'), ((213, 21, 213, 48), 'numpy.array', 'np.array', ({(213, 30, 213, 47): '[[1, 2], [-1, 0]]'}, {}), '([[1, 2], [-1, 0]])', True, 'import numpy as np\n'), ((214, 13, 214, 29), 'numpy.array', 'np.array', ({(214, 22, 214, 28): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((222, 21, 222, 39), 'numpy.array', 'np.array', ({(222, 30, 222, 38): '[[1, 2]]'}, {}), '([[1, 2]])', True, 'import numpy as np\n'), ((223, 13, 223, 26), 'numpy.array', 'np.array', ({(223, 22, 223, 25): '[1]'}, {}), '([1])', True, 'import numpy as np\n'), ((231, 21, 231, 48), 'numpy.array', 'np.array', ({(231, 30, 231, 47): '[[1, 2], [-1, 0]]'}, {}), '([[1, 2], [-1, 0]])', True, 'import numpy as np\n'), ((232, 13, 232, 29), 'numpy.array', 'np.array', ({(232, 22, 232, 28): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((246, 21, 246, 37), 'numpy.array', 'np.array', ({(246, 30, 246, 36): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((257, 21, 257, 37), 'numpy.array', 'np.array', ({(257, 30, 257, 36): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((268, 21, 268, 37), 'numpy.array', 'np.array', ({(268, 30, 268, 36): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((285, 21, 285, 39), 'numpy.array', 'np.array', ({(285, 30, 285, 38): '[[1, 2]]'}, {}), '([[1, 2]])', True, 'import numpy as np\n'), ((286, 13, 286, 26), 'numpy.array', 'np.array', ({(286, 22, 286, 25): '[1]'}, {}), '([1])', True, 'import numpy as np\n'), ((295, 21, 295, 47), 'numpy.array', 'np.array', ({(295, 30, 295, 46): '[[1, 1], [1, 1]]'}, {}), '([[1, 1], [1, 1]])', True, 'import numpy as np\n'), ((296, 13, 296, 29), 'numpy.array', 'np.array', ({(296, 22, 296, 28): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((311, 21, 311, 55), 'numpy.array', 'np.array', ({(311, 30, 311, 54): '[[1, 1], [1, 1], [1, 1]]'}, {}), '([[1, 1], [1, 1], [1, 1]])', True, 'import numpy as np\n'), ((312, 12, 312, 28), 'numpy.array', 'np.array', ({(312, 21, 312, 27): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((314, 14, 314, 33), 'numpy.array', 'np.array', ({(314, 23, 314, 32): '[1, 1, 1]'}, {}), '([1, 1, 1])', True, 'import numpy as np\n'), ((320, 21, 320, 40), 'numpy.array', 'np.array', ({(320, 30, 320, 39): '[[-1, 1]]'}, {}), '([[-1, 1]])', True, 'import numpy as np\n'), ((321, 12, 321, 28), 'numpy.array', 'np.array', ({(321, 21, 321, 27): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((323, 14, 323, 28), 'numpy.array', 'np.array', ({(323, 23, 323, 27): '[-1]'}, {}), '([-1])', True, 'import numpy as np\n'), ((334, 27, 334, 62), 'numpy.array', 'np.array', ({(334, 36, 334, 61): '[[1, 0], [1, -1], [2, 3]]'}, {}), '([[1, 0], [1, -1], [2, 3]])', True, 'import numpy as np\n'), ((335, 25, 335, 52), 'numpy.array', 'np.array', ({(335, 34, 335, 51): '[[1, 1], [2, -1]]'}, {}), '([[1, 1], [2, -1]])', True, 'import numpy as np\n'), ((336, 19, 336, 39), 'numpy.array', 'np.array', ({(336, 28, 336, 38): '[1, -1, 1]'}, {}), '([1, -1, 1])', True, 'import numpy as np\n'), ((337, 17, 337, 34), 'numpy.array', 'np.array', ({(337, 26, 337, 33): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((349, 27, 349, 62), 'numpy.array', 'np.array', ({(349, 36, 349, 61): '[[1, 0], [1, -1], [2, 3]]'}, {}), '([[1, 0], [1, -1], [2, 3]])', True, 'import numpy as np\n'), ((350, 25, 350, 52), 'numpy.array', 'np.array', ({(350, 34, 350, 51): '[[1, 1], [2, -1]]'}, {}), '([[1, 1], [2, -1]])', True, 'import numpy as np\n'), ((351, 19, 351, 39), 'numpy.array', 'np.array', ({(351, 28, 351, 38): '[1, -1, 1]'}, {}), '([1, -1, 1])', True, 'import numpy as np\n'), ((352, 17, 352, 34), 'numpy.array', 'np.array', ({(352, 26, 352, 33): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((410, 14, 412, 22), 'numpy.array', 'np.array', ({(411, 8, 412, 21): '[[1, 1, 1, 0], [1, 1, 1, 1]]'}, {}), '([[1, 1, 1, 0], [1, 1, 1, 1]])', True, 'import numpy as np\n'), ((413, 18, 415, 22), 'numpy.array', 'np.array', ({(414, 8, 415, 21): '[[1, 1, 1, 0], [1, 1, 1, 2]]'}, {}), '([[1, 1, 1, 0], [1, 1, 1, 2]])', True, 'import numpy as np\n'), ((33, 11, 33, 25), 'numpy.isreal', 'np.isreal', ({(33, 21, 33, 24): 'res'}, {}), '(res)', True, 'import numpy as np\n'), ((114, 31, 114, 48), 'numpy.array', 'np.array', ({(114, 40, 114, 47): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((127, 28, 127, 44), 'numpy.array', 'np.array', ({(127, 37, 127, 43): '[1, 1]'}, {}), '([1, 1])', True, 'import numpy as np\n'), ((127, 46, 127, 63), 'numpy.array', 'np.array', ({(127, 55, 127, 62): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((141, 31, 141, 48), 'numpy.array', 'np.array', ({(141, 40, 141, 47): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((142, 15, 142, 31), 'numpy.array', 'np.array', ({(142, 24, 142, 30): '[0, 3]'}, {}), '([0, 3])', True, 'import numpy as np\n'), ((149, 31, 149, 48), 'numpy.array', 'np.array', ({(149, 40, 149, 47): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((150, 15, 150, 31), 'numpy.array', 'np.array', ({(150, 24, 150, 30): '[0, 3]'}, {}), '([0, 3])', True, 'import numpy as np\n'), ((165, 15, 165, 31), 'numpy.array', 'np.array', ({(165, 24, 165, 30): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((174, 15, 174, 31), 'numpy.array', 'np.array', ({(174, 24, 174, 30): '[0, 2]'}, {}), '([0, 2])', True, 'import numpy as np\n'), ((183, 15, 183, 31), 'numpy.array', 'np.array', ({(183, 24, 183, 30): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((192, 15, 192, 31), 'numpy.array', 'np.array', ({(192, 24, 192, 30): '[0, 2]'}, {}), '([0, 2])', True, 'import numpy as np\n'), ((207, 15, 207, 31), 'numpy.array', 'np.array', ({(207, 24, 207, 30): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((216, 15, 216, 34), 'numpy.array', 'np.array', ({(216, 24, 216, 33): '[-0.5, 1]'}, {}), '([-0.5, 1])', True, 'import numpy as np\n'), ((225, 15, 225, 31), 'numpy.array', 'np.array', ({(225, 24, 225, 30): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((234, 15, 234, 37), 'numpy.array', 'np.array', ({(234, 24, 234, 36): '[-0.25, 1.5]'}, {}), '([-0.25, 1.5])', True, 'import numpy as np\n'), ((247, 31, 247, 48), 'numpy.array', 'np.array', ({(247, 40, 247, 47): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((250, 15, 250, 38), 'numpy.array', 'np.array', ({(250, 24, 250, 37): '[-0.88, 1.18]'}, {}), '([-0.88, 1.18])', True, 'import numpy as np\n'), ((258, 31, 258, 48), 'numpy.array', 'np.array', ({(258, 40, 258, 47): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((261, 15, 261, 38), 'numpy.array', 'np.array', ({(261, 24, 261, 37): '[-0.88, 1.08]'}, {}), '([-0.88, 1.08])', True, 'import numpy as np\n'), ((269, 31, 269, 48), 'numpy.array', 'np.array', ({(269, 40, 269, 47): '[-1, 1]'}, {}), '([-1, 1])', True, 'import numpy as np\n'), ((272, 15, 272, 38), 'numpy.array', 'np.array', ({(272, 24, 272, 37): '[-0.88, 1.18]'}, {}), '([-0.88, 1.18])', True, 'import numpy as np\n'), ((289, 15, 289, 31), 'numpy.array', 'np.array', ({(289, 24, 289, 30): '[1, 2]'}, {}), '([1, 2])', True, 'import numpy as np\n'), ((375, 14, 375, 36), 'project1_Copy.bag_of_words', 'p1.bag_of_words', ({(375, 30, 375, 35): 'texts'}, {}), '(texts)', True, 'import project1_Copy as p1\n'), ((419, 14, 419, 63), 'project1_Copy.extract_bow_feature_vectors', 'p1.extract_bow_feature_vectors', ({(419, 45, 419, 50): 'texts', (419, 52, 419, 62): 'dictionary'}, {}), '(texts, dictionary)', True, 'import project1_Copy as p1\n'), ((457, 17, 457, 39), 'traceback.format_exc', 'traceback.format_exc', ({}, {}), '()', False, 'import traceback\n'), ((299, 29, 299, 39), 'numpy.sqrt', 'np.sqrt', ({(299, 37, 299, 38): '(2)'}, {}), '(2)', True, 'import numpy as np\n'), ((299, 45, 299, 55), 'numpy.sqrt', 'np.sqrt', ({(299, 53, 299, 54): '(2)'}, {}), '(2)', True, 'import numpy as np\n')]