From 0004043013d2ad4f18fa6be94fb6845096445b9b Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Thu, 26 Aug 2021 17:19:30 -0400 Subject: [PATCH 1/2] Optimized ordering computation --- src/ordering.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ordering.jl b/src/ordering.jl index 4c633828d..930552678 100644 --- a/src/ordering.jl +++ b/src/ordering.jl @@ -10,7 +10,11 @@ arglength(a) = length(arguments(a)) function <ₑ(a, b) - if !istree(a) && !istree(b) + if a isa Term && (b isa Symbolic && !(b isa Term)) + return false + elseif b isa Term && (a isa Symbolic && !(a isa Term)) + return true + elseif !istree(a) && !istree(b) T = typeof(a) S = typeof(b) return T===S ? (T <: Number ? isless(a, b) : hash(a) < hash(b)) : nameof(T) < nameof(S) From 306dbb4f126e7c3ba190b89926e81822dcd39511 Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Wed, 1 Sep 2021 10:03:34 -0400 Subject: [PATCH 2/2] Update tests --- test/order.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/order.jl b/test/order.jl index 38ab697d7..1a8bf67c8 100644 --- a/test/order.jl +++ b/test/order.jl @@ -5,7 +5,7 @@ SymbolicUtils.show_simplified[] = false @syms a b c -function istotal(x,y) +function istotal(x, y) #either if x <ₑ y return !(y <ₑ x) @@ -13,7 +13,7 @@ function istotal(x,y) return !(x <ₑ y) # already tested else # neither, equal - return true + return isequal(x, y) end end @@ -81,8 +81,7 @@ end @testset "small terms" begin # this failing was a cause of a nasty stackoverflow #82 @syms a - @test Term(^, [a, -1]) <ₑ (a + 2) - @test !((a + 2) <ₑ Term(^, [a, -1])) + istotal(Term(^, [a, -1]), (a + 2)) end @testset "transitivity" begin