Skip to content

Commit 8f10a1a

Browse files
Merge pull request #5 from SciML/master
minor changes to testing
2 parents 6ddddd2 + ae78557 commit 8f10a1a

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SymbolicNumericIntegration"
22
uuid = "78aadeae-fbc0-11eb-17b6-c7ec0477ba9e"
33
authors = ["Shahriar Iravanian <[email protected]>"]
4-
version = "0.8.1"
4+
version = "0.8.2"
55

66
[deps]
77
DataDrivenDiffEq = "2445eb08-9709-466a-b3fc-47e12bd697a2"

src/integral.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ using LinearAlgebra
22
using Statistics: mean, std
33

44
Base.signbit(z::Complex{T}) where T<:Number = signbit(real(z))
5+
Base.signbit(x::SymbolicUtils.Sym{Number, Nothing}) = false
6+
57

68
"""
79
integrate is the main entry point

test/axiom.jl

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ using Symbolics
66
using PyCall
77
sympy = pyimport("sympy")
88

9-
# @syms x 𝐞 a b c d e p t m n z
10-
@variables x 𝐞 a b c d e p t m n z
11-
12-
axion_rules = [
13-
@rule ^(𝐞, ~k) => exp(~k)
14-
@rule 𝐞 => MathConstants.e
15-
]
9+
@variables x a b c d e p t m n z
1610

1711
function convert_axiom(name::AbstractString)
1812
fd = open(name, "r")
@@ -29,16 +23,14 @@ function convert_axiom(name::AbstractString)
2923
if ma != nothing
3024
line = ma.match
3125
println(line)
32-
line = replace(line, "%e" => 𝐞)
26+
line = replace(line, "%e" => MathConstants.e)
3327
line = replace(line, "%i" => im)
3428

3529
try
3630
expr = Meta.parse(line)
3731
P = eval(expr)
3832

3933
print(lineno, ": ", P[1], " => ")
40-
P[1] = Prewalk(PassThrough(Chain(axion_rules)))(P[1])
41-
P[4] = Prewalk(PassThrough(Chain(axion_rules)))(P[4])
4234

4335
for ν in Symbolics.get_variables(P[1])
4436
if !isequal(ν, x) && !haskey(D, ν)
@@ -49,6 +41,7 @@ function convert_axiom(name::AbstractString)
4941
P[1] = substitute(P[1], D)
5042
P[4] = substitute(P[4], D)
5143

44+
printstyled(length(L)+1, ": "; color=:red)
5245
println(P[1])
5346
push!(L, P)
5447
catch err
@@ -108,10 +101,11 @@ function accept_integral(sol, ans, x; radius=1.0, abstol=1e-3, n=5)
108101
ϵ = zeros(n)
109102
for i = 1:n
110103
x₀ = test_point(true, radius)
111-
ϵ[i] = abs(substitute(sol - ans, Dict(x => x₀)))
104+
ϵ[i] = value(abs(substitute(sol - ans, Dict(x => x₀))))
112105
end
113-
return maximum(ϵ) - minimum(ϵ) < abstol
106+
return maximum(ϵ) - minimum(ϵ) <= abstol
114107
catch e
108+
println(e)
115109
end
116110
return false
117111
end
@@ -137,7 +131,7 @@ function test_axiom(L, try_sympy=true; kwargs...)
137131
if isequal(sol, 0)
138132
printstyled("\tFailure\n"; color=:red)
139133
n_fail += 1
140-
elseif accept_integral(sol, ans, x)
134+
elseif accept_integral(value(sol), value(ans), x)
141135
printstyled("\tSuccess:\t", sol, '\n'; color=:cyan)
142136
n_ok += 1
143137
else

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using SymbolicNumericIntegration
1+
# using SymbolicNumericIntegration
22
using SymbolicUtils
33
using Test
44

0 commit comments

Comments
 (0)