SymbolicUtils.jl
SymbolicUtils.jl copied to clipboard
Simplify printing of Term(identity, x)
It can be helpful to encode a quantity q that should not be evaluated as Term(identity, q). This is the idea behind JuliaSymbolics/Symbolics.jl#638, which allows irrationals like π to be treated symbolically, rather than (typically) as Float64 in symbolic expressions. But that means that identity(π) appears everywhere we would normally just write π. This PR simply adds another case to show_term, to check if the function is identity, and just shows the argument instead.
@shashi @YingboMa Given that https://github.com/JuliaSymbolics/Symbolics.jl/pull/638 has been merged, I think this is more relevant now. Any thoughts?
Ahh. Well I don't know how I feel about this haha. Can we take this branch only if args[1] is not issym(..) or istree(..) that way it should only do it for constants. At the very least I agree we should do it for Irrationals. @YingboMa
Yeah, I agree. We should check that args[1] is not symbolic.
@shashi Tests pass locally. I added the new test at the bottom of test/code.jl; let me know if you want it somewhere else.
You can just use repr to get a string... but looks good.