<commit_before><commit_msg>Begin design of unit tests for errors.py functions<commit_after>"""
test_errors.py - Unit tests for YANN core error functions
defined in yann/core/errors.py
"""

import unittest
import numpy as np
import theano
import theano.tensor as T
import yann.core.errors as E


class TestActivations(unittest.TestCase):
    """
    """

    def setUp(self):
        """
        """

        self.theano_input = T.lvector()
        # TO-DO: Find out proper numpy_input dimensionality
        self.numpy_input = np.array([1, 2])

    def test_cross_entropy(self):
        expected_array = 'mean'
        theano_result = E.cross_entropy(self.theano_input, self.numpy_input).eval({self.theano_input: self.numpy_input})
        self.assertEqual(theano_result.shape, expected_array.shape)
        self.assertTrue(np.allclose(theano_result, expected_array))
{'fraction_non_alphanumeric': 0.10380622837370242, 'fraction_numerical': 0.002306805074971165, 'mean_word_length': 3.4974093264248705, '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': '3178393', 'n_tokens_mistral': 274, 'n_tokens_neox': 268, 'n_words': 62}