<commit_before>from unittest import TestCase, main

from classes.solver import Perceptron


class TestPerceptronBasicProperties(TestCase):


    def setUp(self):
        def as_tuples(x):
            return [tuple(row) for row in x]
        self.processors = [
            lambda x: x,
            as_tuples,
            lambda x: set(as_tuples(x))
        ]
        pass


    def tearDown(self):
        pass


    def test_constructor(self):
        perceptron = Perceptron(1)
        self.assertIsInstance(perceptron, Perceptron)


    def test_setup_line(self):
        left = [[-1]]
        right = [[1]]
        for process in self.processors:
            perceptron = Perceptron(1)
            self.assertTrue(perceptron.setup(process(left), process(right)))


    def test_setup_one_by_one(self):
        left = [[-1]]
        right = [[1]]
        for process in self.processors:
            perceptron = Perceptron(1)
            self.assertTrue(perceptron.setup(left=process(left)))
            self.assertTrue(perceptron.setup(right=process(right)))



    def test_setup_plane(self):
        left = [[-1, 1], [-2, 1]]
        right = [[1, 1], [2, 1]]

        for process in self.processors:
            perceptron = Perceptron(2)
            self.assertTrue(perceptron.setup(process(left), process(right)))


    def test_classify_line_zero(self):
        left = [[-1]]
        right = [[1]]

        left_test = [[-5], [-10]]
        right_test = [[5], [10]]
        for process in self.processors:
            perceptron = Perceptron(1)<commit_msg>Updated PS unit test<commit_after>from unittest import TestCase, main

from classes.solver import Perceptron


class TestPerceptronBasicProperties(TestCase):


    def setUp(self):
        def as_tuples(x):
            return [tuple(row) for row in x]
        self.processors = [
            lambda x: x,
            as_tuples,
            lambda x: set(as_tuples(x))
        ]
        pass


    def tearDown(self):
        pass


    def test_constructor(self):
        perceptron = Perceptron(1)
        self.assertIsInstance(perceptron, Perceptron)


    def test_setup_line(self):
        left = [[-1]]
        right = [[1]]
        for process in self.processors:
            perceptron = Perceptron(1)
            self.assertTrue(perceptron.setup(process(left), process(right)))


    def test_setup_one_by_one(self):
        left = [[-1]]
        right = [[1]]
        for process in self.processors:
            perceptron = Perceptron(1)
            self.assertTrue(perceptron.setup())
            self.assertTrue(perceptron.setup(left=process(left)))
            self.assertTrue(perceptron.setup(right=process(right)))



    def test_setup_plane(self):
        left = [[-1, 1], [-2, 1]]
        right = [[1, 1], [2, 1]]

        for process in self.processors:
            perceptron = Perceptron(2)
            self.assertTrue(perceptron.setup(process(left), process(right)))


    def test_classify_line_zero(self):
        left = [[-1]]
        right = [[1]]

        left_test = [[-5], [-10]]
        right_test = [[5], [10]]
        for process in self.processors:
            perceptron = Perceptron(1)
{'fraction_non_alphanumeric': 0.11993720565149137, 'fraction_numerical': 0.015698587127158554, 'mean_word_length': 2.1022395326192793, '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': '5319043', 'n_tokens_mistral': 1049, 'n_tokens_neox': 971, 'n_words': 213}