From 8553830230dfe2dbb1acb586f882b08d3b11f380 Mon Sep 17 00:00:00 2001 From: Nathan Smith Date: Fri, 15 Nov 2019 08:49:46 -0400 Subject: [PATCH] Update to use \euler instead of 'e' as Euler's number Julia >= 1.0 deprecated 'e' as Euler's number --- src/mexpr.jl | 15 +++++++-------- test/runtests.jl | 6 +++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/mexpr.jl b/src/mexpr.jl index cf5cb91..266e9bd 100644 --- a/src/mexpr.jl +++ b/src/mexpr.jl @@ -142,18 +142,17 @@ end const m_to_jl = Dict( - "%e" => "e", - "%pi" => "π", - "%i" => "im", + "%e" => "ℯ", + "%pi" => "π", + "%i" => "im", "%gamma" => "eulergamma", - "%phi" => "φ", - "inf" => "Inf", - "minf" => "-Inf" + "%phi" => "φ", + "inf" => "Inf", + "minf" => "-Inf" ) const jl_to_m = Dict( - "e" => "%e", - "eu" => "%e", + "ℯ" => "%e", "pi" => "%pi", "π" => "%pi", "γ" => "%gamma", diff --git a/test/runtests.jl b/test/runtests.jl index 755f010..c279d9e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -12,6 +12,10 @@ using Test @test MExpr(:(100x)) == m"100 * x" @test MExpr(:(-im)) == m"-%i" +# Julia special constant replacement +@test mcall(:(ℯ^(im * π))) == -1 +@test mcall(:(e^(im * π))) != -1 # We no longer support 'e' as euler number in Julia >= 1.0 + # Calculus tests @test integrate(:(sin(x)), :x) == :(-cos(x)) @test integrate("exp(-x^2)", "x", "minf", "inf") == "sqrt(%pi)" @@ -46,7 +50,7 @@ end @test logexpand(m"log(x/y)") == m"log(x) - log(y)" @test trigsimp(m"sin(x)^2 + cos(x)^2") |> parse == 1 @test trigrat(MExpr(:(exp(im*x) + exp(-im*x)))) == MExpr(:(2 * cos(x))) -@test rectform(:(R*e^(im*theta))) == :(im * R * sin(theta) + R * cos(theta)) +@test rectform(:(R*ℯ^(im*theta))) == :(im * R * sin(theta) + R * cos(theta)) @test polarform(m"a + %i*b") == m"sqrt(a^2 + b^2)*exp(%i * atan2(b, a))" @test realpart(m"a + %i*b") |> parse == :a @test imagpart(m"a + %i*b") |> parse == :b