Skip to content

Commit 662acb5

Browse files
authored
Merge branch 'master' into b/fix-unary-binary-operator-printing
2 parents 55f48e0 + 7a9f0c5 commit 662acb5

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SymbolicUtils"
22
uuid = "d1185830-fcd6-423d-90d6-eec64667417b"
33
authors = ["Shashi Gowda"]
4-
version = "1.0.3"
4+
version = "1.0.4"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

src/types.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -782,10 +782,11 @@ function show_call(io, f, args)
782782
if Base.isunaryoperator(fname) && len_args == 1
783783
print(io, "$fname")
784784
print_arg(io, first(args), paren=true)
785-
elseif Base.isbinaryoperator(fname) && len_args == 2
786-
print_arg(io, first(args), paren=true)
787-
print(io, " $fname ")
788-
print_arg(io, last(args), paren=true)
785+
elseif Base.isbinaryoperator(fname) && len_args > 1
786+
for (i, t) in enumerate(args)
787+
i != 1 && print(io, " $fname ")
788+
print_arg(io, t, paren=true)
789+
end
789790
else
790791
if issym(f)
791792
Base.show_unquoted(io, nameof(f))

test/basics.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using SymbolicUtils: Symbolic, Sym, FnType, Term, Add, Mul, Pow, symtype, operation, arguments, issym, isterm, BasicSymbolic
1+
using SymbolicUtils: Symbolic, Sym, FnType, Term, Add, Mul, Pow, symtype, operation, arguments, issym, isterm, BasicSymbolic, term
22
using SymbolicUtils
33
using IfElse: ifelse
44
using Setfield
@@ -173,6 +173,7 @@ end
173173
@syms a b c
174174
@test repr(a+b) == "a + b"
175175
@test repr(-a) == "-a"
176+
@test repr(term(-, a; type = Real)) == "-(a)"
176177
@test repr(-a + 3) == "3 - a"
177178
@test repr(-(a + b)) == "-a - b"
178179
@test repr((2a)^(-2a)) == "(2a)^(-2a)"

0 commit comments

Comments
 (0)