def _print_sign(self, expr): from sympy import Abs arg, = expr.args if arg.is_integer: new_expr = merge(0, isign(1, arg), Eq(arg, 0)) elif arg.is_complex: new_expr = merge(cmplx(literal_dp(0), literal_dp(0)), arg/Abs(arg), Eq(Abs(arg), literal_dp(0))) else: new_expr = merge(literal_dp(0), dsign(literal_dp(1), arg), Eq(arg, literal_dp(0))) return self._print(new_expr)
def test_literal_dp(): assert fcode(literal_dp(0), source_format='free') == '0d0'
def test_dsign(): x = Symbol('x') assert dsign(1, x) == dsign(1, x) assert fcode(dsign(literal_dp(1), x), standard=95, source_format='free') == 'dsign(1d0, x)'