@parameterized.named_parameters(jtu.cases_from_list(({'testcase_name': jtu.format_test_name_suffix(op, [()], [dtype]), 'dtype': dtype, 'op': op} for dtype in float_dtypes for op in ('sqrt', 'arccos', 'arcsin', 'arctan', 'sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh', 'arccosh', 'arcsinh', 'arctanh', 'exp', 'log', 'expm1', 'log1p'))))
def testMathSpecialFloatValues(self, op, dtype):
    onp_op = getattr(onp, op)
    onp_op = jtu.ignore_warning(category=RuntimeWarning, message='invalid value.*')(onp_op)
    onp_op = jtu.ignore_warning(category=RuntimeWarning, message='divide by zero.*')(onp_op)
    onp_op = jtu.ignore_warning(category=RuntimeWarning, message='overflow.*')(onp_op)
    jnp_op = getattr(jnp, op)
    dtype = onp.dtype(dtypes.canonicalize_dtype(dtype)).type
    for x in (onp.nan, (- onp.inf), (- 100.0), (- 2.0), (- 1.0), 0.0, 1.0, 2.0, 100.0, onp.inf, jnp.finfo(dtype).max, onp.sqrt(jnp.finfo(dtype).max), (onp.sqrt(jnp.finfo(dtype).max) * 2.0)):
        if (onp.isnan(x) and (op in ('sinh', 'cosh', 'expm1', 'exp'))):
            continue
        if ((op in ('sin', 'cos', 'tan', 'arctan')) and (jtu.device_under_test() == 'tpu')):
            continue
        x = dtype(x)
        expected = onp_op(x)
        actual = jnp_op(x)
        tol = jtu.tolerance(dtype, {onp.float32: 0.001, onp.float64: 1e-07})
        self.assertAllClose(expected, actual, check_dtypes=True, atol=tol, rtol=tol)
@parameterized.named_parameters(jtu.cases_from_list(({'testcase_name': jtu.format_test_name_suffix(op, [()], [dtype]), 'dtype': dtype, 'op': op} for dtype in float_dtypes for op in ('sqrt', 'arccos', 'arcsin', 'arctan', 'sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh', 'arccosh', 'arcsinh', 'arctanh', 'exp', 'log', 'expm1', 'log1p'))))
def testMathSpecialFloatValues(self, op, dtype):
    onp_op = getattr(onp, op)
    onp_op = jtu.ignore_warning(category=RuntimeWarning, message='invalid value.*')(onp_op)
    onp_op = jtu.ignore_warning(category=RuntimeWarning, message='divide by zero.*')(onp_op)
    onp_op = jtu.ignore_warning(category=RuntimeWarning, message='overflow.*')(onp_op)
    jnp_op = getattr(jnp, op)
    dtype = onp.dtype(dtypes.canonicalize_dtype(dtype)).type
    for x in (onp.nan, (- onp.inf), (- 100.0), (- 2.0), (- 1.0), 0.0, 1.0, 2.0, 100.0, onp.inf, jnp.finfo(dtype).max, onp.sqrt(jnp.finfo(dtype).max), (onp.sqrt(jnp.finfo(dtype).max) * 2.0)):
        if (onp.isnan(x) and (op in ('sinh', 'cosh', 'expm1', 'exp'))):
            continue
        if ((op in ('sin', 'cos', 'tan', 'arctan')) and (jtu.device_under_test() == 'tpu')):
            continue
        x = dtype(x)
        expected = onp_op(x)
        actual = jnp_op(x)
        tol = jtu.tolerance(dtype, {onp.float32: 0.001, onp.float64: 1e-07})
        self.assertAllClose(expected, actual, check_dtypes=True, atol=tol, rtol=tol)