Python chainer.testing.parameterize() Examples

The following are 2 code examples of chainer.testing.parameterize(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module chainer.testing , or try the search function .
Example #1
Source File: test_batch_renormalization.py    From chainer with MIT License 5 votes vote down vote up
def parameterize_batch_renormalization():
    return testing.parameterize(*(testing.product({
        'ndim': [0, 1, 2],
        'eps': [2e-5, 1e-1],
        'dtype': [numpy.float32],
        'update_statistics': [True, False],
    }) + testing.product({
        'ndim': [1],
        'eps': [2e-5, 1e-1],
        'dtype': [numpy.float16, numpy.float32, numpy.float64],
        'update_statistics': [True, False],
    }))) 
Example #2
Source File: parameterized.py    From chainercv with MIT License 5 votes vote down vote up
def parameterize(*params):
    """:func:`chainer.testing.parameterize` for `pytest-xdist`.

    :func:`chainer.testing.parameterize` cannot work with `pytest-xdist`
    when the params contain functions (lambdas), classes, and random values.
    This wrapper replaces the params with their indices
    and restore the original params in :meth:`setUp`.
    """

    def deco(cls):
        setUp_orig = cls.setUp

        def setUp(self):
            param = params[self._chainercv_parameterize_index]
            print('params: {}'.format(param))
            for k, v in six.iteritems(param):
                setattr(self, k, v)
            setUp_orig(self)

        cls.setUp = setUp

        params_indices = [
            {'_chainercv_parameterize_index': i} for i in range(len(params))]
        return testing.parameterize(*params_indices)(cls)

    return deco