@parameterized.named_parameters(jtu.cases_from_list(({'testcase_name': 'op={}_xshape=[{}]_yshape=[{}]_mode={}'.format(op, jtu.format_shape_dtype_string(xshape, dtype), jtu.format_shape_dtype_string(yshape, dtype), mode), 'xshape': xshape, 'yshape': yshape, 'dtype': dtype, 'mode': mode, 'rng_factory': jtu.rand_default, 'jnp_op': getattr(jnp, op), 'onp_op': getattr(onp, op)} for mode in ['full', 'same', 'valid'] for op in ['convolve', 'correlate'] for dtype in default_dtypes for xshape in one_dim_array_shapes for yshape in one_dim_array_shapes)))
def testConvolutions(self, xshape, yshape, dtype, mode, rng_factory, jnp_op, onp_op):
    rng = rng_factory()
    args_maker = (lambda : [rng(xshape, dtype), rng(yshape, dtype)])
    onp_fun = partial(onp_op, mode=mode)
    jnp_fun = partial(jnp_op, mode=mode)
    tol = (0.01 if (jtu.device_under_test() != 'tpu') else 0.5)
    self._CheckAgainstNumpy(onp_fun, jnp_fun, args_maker, check_dtypes=False, tol=tol)
    self._CompileAndCheck(jnp_fun, args_maker, check_dtypes=True)
@parameterized.named_parameters(jtu.cases_from_list(({'testcase_name': 'op={}_xshape=[{}]_yshape=[{}]_mode={}'.format(op, jtu.format_shape_dtype_string(xshape, dtype), jtu.format_shape_dtype_string(yshape, dtype), mode), 'xshape': xshape, 'yshape': yshape, 'dtype': dtype, 'mode': mode, 'rng_factory': jtu.rand_default, 'jnp_op': getattr(jnp, op), 'onp_op': getattr(onp, op)} for mode in ['full', 'same', 'valid'] for op in ['convolve', 'correlate'] for dtype in default_dtypes for xshape in one_dim_array_shapes for yshape in one_dim_array_shapes)))
def testConvolutions(self, xshape, yshape, dtype, mode, rng_factory, jnp_op, onp_op):
    rng = rng_factory()
    args_maker = (lambda : [rng(xshape, dtype), rng(yshape, dtype)])
    onp_fun = partial(onp_op, mode=mode)
    jnp_fun = partial(jnp_op, mode=mode)
    tol = (0.01 if (jtu.device_under_test() != 'tpu') else 0.5)
    self._CheckAgainstNumpy(onp_fun, jnp_fun, args_maker, check_dtypes=False, tol=tol)
    self._CompileAndCheck(jnp_fun, args_maker, check_dtypes=True)