@parameterized.named_parameters(jtu.cases_from_list(({'testcase_name': '_shape={}_axis={}_weights={}_returned={}'.format(jtu.format_shape_dtype_string(shape, dtype), axis, (None if (weights_shape is None) else jtu.format_shape_dtype_string(weights_shape, dtype)), returned), 'rng_factory': jtu.rand_default, 'shape': shape, 'dtype': dtype, 'axis': axis, 'weights_shape': weights_shape, 'returned': returned} for (shape, dtype) in _shape_and_dtypes(nonempty_shapes, number_dtypes) for axis in (list(range((- len(shape)), len(shape))) + [None]) for weights_shape in ([None, shape] if ((axis is None) or (len(shape) == 1)) else [None, (shape[axis],), shape]) for returned in [False, True])))
def testAverage(self, shape, dtype, axis, weights_shape, returned, rng_factory):
    rng = rng_factory()
    if (weights_shape is None):
        onp_fun = (lambda x: onp.average(x, axis, returned=returned))
        jnp_fun = (lambda x: jnp.average(x, axis, returned=returned))
        args_maker = (lambda : [rng(shape, dtype)])
    else:
        onp_fun = (lambda x, weights: onp.average(x, axis, weights, returned))
        jnp_fun = (lambda x, weights: jnp.average(x, axis, weights, returned))
        args_maker = (lambda : [rng(shape, dtype), rng(weights_shape, dtype)])
    onp_fun = _promote_like_jnp(onp_fun, inexact=True)
    tol = {onp.float16: 0.01, onp.float32: 1e-06, onp.float64: 1e-12}
    check_dtypes = (shape is not jtu.PYTHON_SCALAR_SHAPE)
    try:
        self._CheckAgainstNumpy(onp_fun, jnp_fun, args_maker, check_dtypes=check_dtypes, tol=tol)
    except ZeroDivisionError:
        self.skipTest("don't support checking for ZeroDivisionError")
    self._CompileAndCheck(jnp_fun, args_maker, check_dtypes=check_dtypes, rtol=tol, atol=tol)
@parameterized.named_parameters(jtu.cases_from_list(({'testcase_name': '_shape={}_axis={}_weights={}_returned={}'.format(jtu.format_shape_dtype_string(shape, dtype), axis, (None if (weights_shape is None) else jtu.format_shape_dtype_string(weights_shape, dtype)), returned), 'rng_factory': jtu.rand_default, 'shape': shape, 'dtype': dtype, 'axis': axis, 'weights_shape': weights_shape, 'returned': returned} for (shape, dtype) in _shape_and_dtypes(nonempty_shapes, number_dtypes) for axis in (list(range((- len(shape)), len(shape))) + [None]) for weights_shape in ([None, shape] if ((axis is None) or (len(shape) == 1)) else [None, (shape[axis],), shape]) for returned in [False, True])))
def testAverage(self, shape, dtype, axis, weights_shape, returned, rng_factory):
    rng = rng_factory()
    if (weights_shape is None):
        onp_fun = (lambda x: onp.average(x, axis, returned=returned))
        jnp_fun = (lambda x: jnp.average(x, axis, returned=returned))
        args_maker = (lambda : [rng(shape, dtype)])
    else:
        onp_fun = (lambda x, weights: onp.average(x, axis, weights, returned))
        jnp_fun = (lambda x, weights: jnp.average(x, axis, weights, returned))
        args_maker = (lambda : [rng(shape, dtype), rng(weights_shape, dtype)])
    onp_fun = _promote_like_jnp(onp_fun, inexact=True)
    tol = {onp.float16: 0.01, onp.float32: 1e-06, onp.float64: 1e-12}
    check_dtypes = (shape is not jtu.PYTHON_SCALAR_SHAPE)
    try:
        self._CheckAgainstNumpy(onp_fun, jnp_fun, args_maker, check_dtypes=check_dtypes, tol=tol)
    except ZeroDivisionError:
        self.skipTest("don't support checking for ZeroDivisionError")
    self._CompileAndCheck(jnp_fun, args_maker, check_dtypes=check_dtypes, rtol=tol, atol=tol)