<commit_before>import unittest

import numpy

import chainer
import chainer.functions as F
from chainer import testing


@testing.parameterize(*testing.product({
    'dtype': [numpy.float16, numpy.float32, numpy.float64]
}))
@testing.inject_backend_tests(
    None,
    # CPU tests
    [
        {},
    ]
    # GPU tests
    + testing.product({
        'use_cuda': [True],
        'cuda_device': [0, 1],
    })
    # ChainerX tests
    + testing.product({
        'use_chainerx': [True],
        'chainerx_device': ['native:0', 'cuda:0', 'cuda:1']
    })
)
@testing.with_requires('scipy')
class TestZeta(testing.FunctionTestCase):

    def setUp(self):
        if self.dtype == numpy.float16:
            self.check_forward_options = {'atol': 1e-2, 'rtol': 1e-2}
        else:
            self.check_forward_options = {'atol': 1e-4, 'rtol': 1e-4}
        self.check_backward_options = {'atol': 1e-4, 'rtol': 1e-4}
        self.check_double_backward_options = {'atol': 1e-4, 'rtol': 1e-4}

    def generate_inputs(self):
        x = numpy.array(numpy.random.rand(1).astype(numpy.float64))
        q = numpy.array(numpy.random.uniform(1, 10))
        return x, q

    def forward_expected(self, inputs):
        x, q = inputs
        import scipy
        y_expect = scipy.special.zeta(x, q)
        return y_expect.astype(numpy.float64),

    def forward(self, inputs, device):
        x, q = inputs
        y = F.zeta(x, q)
        return y,


@testing.parameterize(*testing.product({
    'dtype': [numpy.float16, numpy.float32, numpy.float64]
}))
@testing.without_requires('scipy')
class TestZetaExceptions(unittest.TestCase):
    def setUp(self):
        self.x = \
            numpy.array(numpy.random.uniform(1, 10))
        self.q = numpy.array(numpy.random.rand(1).astype(numpy.float64))
        self.func = F.zeta

    def check_forward(self, q_data, x_data):
        x = chainer.Variable(x_data)
        q = chainer.Variable(q_data)<commit_msg>Changes for zeta_test<commit_after>import unittest

import numpy

import chainer
import chainer.functions as F
from chainer import testing


@testing.parameterize(*testing.product({
    'dtype': [numpy.float16, numpy.float32, numpy.float64]
}))
@testing.inject_backend_tests(
    None,
    # CPU tests
    [
        {},
    ]
    # GPU tests
    + testing.product({
        'use_cuda': [True],
        'cuda_device': [0, 1],
    })
    # ChainerX tests
    + testing.product({
        'use_chainerx': [True],
        'chainerx_device': ['native:0', 'cuda:0', 'cuda:1']
    })
)
@testing.with_requires('scipy')
class TestZeta(testing.FunctionTestCase):

    def setUp(self):
        if self.dtype == numpy.float16:
            self.check_forward_options = {'atol': 1e-2, 'rtol': 1e-2}
        else:
            self.check_forward_options = {'atol': 1e-4, 'rtol': 1e-4}
        self.check_backward_options = {'atol': 1e-4, 'rtol': 1e-4}
        self.check_double_backward_options = {'atol': 1e-4, 'rtol': 1e-4}

    def generate_inputs(self):
        x = numpy.array(numpy.random.uniform(5, 10))
        q = numpy.array(numpy.random.uniform(1, 10))
        return x, q

    def forward_expected(self, inputs):
        x, q = inputs
        import scipy
        y_expect = scipy.special.zeta(x, q)
        return numpy.array(y_expect)
        ,

    def forward(self, inputs, device):
        x, q = inputs
        y = F.zeta(x, q)
        return y,


@testing.parameterize(*testing.product({
    'dtype': [numpy.float16, numpy.float32, numpy.float64]
}))
@testing.without_requires('scipy')
class TestZetaExceptions(unittest.TestCase):
    def setUp(self):
        self.x = \
            numpy.array(numpy.random.uniform(1, 10))
        self.q = numpy.array(numpy.random.uniform(5, 10))
        self.func = F.zeta

    def check_forward(self, q_data, x_data):
        x = chainer.Variable(x_data)
        q = chainer.Variable(q_data)
{'fraction_non_alphanumeric': 0.14399793920659454, 'fraction_numerical': 0.02472952086553323, 'mean_word_length': 2.6391752577319587, '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': '3137756', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1358, 'n_words': 261}