<commit_before>import numpy as np
import unittest

from chainer import iterators
from chainer import link
from chainer import reporter as reporter_module
from chainer import testing

from chainer.functions.evaluation import accuracy
from chainer.training import evaluator as evaluator_module


class TestStandardEvaluator(unittest.TestCase):
    def test_it(self):
        class MyChain(link.Chain):
            def __call__(self, x, t):
                reporter_module.report({
                    'accuracy': accuracy.accuracy(x, t),
                })

        data = [
            (np.asarray([1, 0], dtype=np.float32), np.int32(0)),  # true
            (np.asarray([1, 0], dtype=np.float32), np.int32(0)),  # true
            (np.asarray([1, 0], dtype=np.float32), np.int32(0)),  # true
            (np.asarray([0, 1], dtype=np.float32), np.int32(1)),  # true
            (np.asarray([0, 1], dtype=np.float32), np.int32(1)),  # true
            (np.asarray([0, 1], dtype=np.float32), np.int32(1)),  # true
            (np.asarray([0, 1], dtype=np.float32), np.int32(0)),  # false
            (np.asarray([1, 0], dtype=np.float32), np.int32(1)),  # false
        ]
        iterator = iterators.SerialIterator(data, 4, repeat=False)

        model = MyChain()
        evaluator = evaluator_module.StandardEvaluator(iterator, model)

        result = evaluator.run()

        testing.assert_allclose(6. / 8, result['accuracy'])<commit_msg>make test runnable<commit_after>import numpy as np
import unittest

from chainer import iterators
from chainer import link
from chainer import reporter as reporter_module
from chainer import testing

from chainer.functions.evaluation import accuracy
from chainer.training import evaluator as evaluator_module


class TestStandardEvaluator(unittest.TestCase):

    def test_it(self):

        class MyChain(link.Chain):

            def __call__(self, x, t):
                reporter_module.report({
                    'accuracy': accuracy.accuracy(x, t),
                })

        data = [
            (np.asarray([1, 0], dtype=np.float32), np.int32(0)),  # true
            (np.asarray([1, 0], dtype=np.float32), np.int32(0)),  # true
            (np.asarray([1, 0], dtype=np.float32), np.int32(0)),  # true
            (np.asarray([0, 1], dtype=np.float32), np.int32(1)),  # true
            (np.asarray([0, 1], dtype=np.float32), np.int32(1)),  # true
            (np.asarray([0, 1], dtype=np.float32), np.int32(1)),  # true
            (np.asarray([0, 1], dtype=np.float32), np.int32(0)),  # false
            (np.asarray([1, 0], dtype=np.float32), np.int32(1)),  # false
        ]
        iterator = iterators.SerialIterator(data, 4, repeat=False)

        model = MyChain()
        evaluator = evaluator_module.StandardEvaluator(iterator, model)

        result = evaluator.run()

        testing.assert_allclose(6. / 8, result['accuracy'])


testing.run_module(__name__, __file__)
{'fraction_non_alphanumeric': 0.13988399863527806, 'fraction_numerical': 0.04025929716820198, 'mean_word_length': 2.615289765721332, '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': '5995646', 'n_tokens_mistral': 1000, 'n_tokens_neox': 931, 'n_words': 209}