def map_constant(self, expr):
    if isinstance(expr, complex):
        r = expr.real
        i = expr.imag
        if (abs(r) < 1e-15):
            r = 0
        if (abs(i) < 1e-15):
            i = 0
        return complex(r, i)
    else:
        return expr
def map_constant(self, expr):
    if isinstance(expr, complex):
        r = expr.real
        i = expr.imag
        if (abs(r) < 1e-15):
            r = 0
        if (abs(i) < 1e-15):
            i = 0
        return complex(r, i)
    else:
        return expr