Skip to content

Commit 60e6f01

Browse files
Merge pull request #104 from shahriariravanian/main
Adding TermInterface and updating compat
2 parents 801e41e + d930394 commit 60e6f01

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

Project.toml

+3-1
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 = "1.8.0"
4+
version = "1.9.0"
55

66
[deps]
77
DataDrivenDiffEq = "2445eb08-9709-466a-b3fc-47e12bd697a2"
@@ -12,6 +12,7 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1212
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1313
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
1414
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
15+
TermInterface = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"
1516

1617
[compat]
1718
DataDrivenDiffEq = "1.5"
@@ -22,6 +23,7 @@ SpecialFunctions = "2"
2223
Statistics = "<0.0.1, 1"
2324
SymbolicUtils = "2.1, 3"
2425
Symbolics = "6"
26+
TermInterface = "2"
2527
julia = "1.9"
2628

2729
[extras]

src/SymbolicNumericIntegration.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module SymbolicNumericIntegration
22

3+
using TermInterface: iscall
34
using SymbolicUtils
4-
using SymbolicUtils: iscall, operation, arguments
5+
using SymbolicUtils: operation, arguments
56
using Symbolics
67
using Symbolics: value, get_variables, expand_derivatives, coeff, Equation
78
using SymbolicUtils.Rewriters
@@ -33,7 +34,6 @@ export Ei, Si, Ci, Li
3334

3435
include("numeric_utils.jl")
3536
include("sparse.jl")
36-
# include("optim.jl")
3737
include("integral.jl")
3838

3939
export integrate, generate_basis, best_hints

src/integral.jl

+15-8
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,7 @@ function integrate_term(eq, x; kwargs...)
226226
end
227227

228228
if symbolic
229-
y = integrate_symbolic(eq, x; plan)
230-
if y == nothing
231-
if has_sym_consts
232-
@info("Symbolic integration failed. Try changing constant parameters ([$(join(params, ", "))]) to numerical values.")
233-
end
234-
235-
return 0, eq, Inf
236-
end
229+
return try_symbolic(eq, x, has_sym_consts, params)
237230
end
238231

239232
eq = cache(eq)
@@ -308,6 +301,20 @@ function try_integrate(eq, x, basis; plan = default_plan())
308301
return solve_sparse(eq, x, basis; plan)
309302
end
310303

304+
function try_symbolic(eq, x, has_sym_consts = false, params = []; plan = default_plan())
305+
y = integrate_symbolic(eq, x; plan)
306+
307+
if y == nothing
308+
if has_sym_consts && !isempty(params)
309+
@info("Symbolic integration failed. Try changing constant parameters ([$(join(params, ", "))]) to numerical values.")
310+
end
311+
312+
return 0, eq, Inf
313+
else
314+
return y, 0, 0
315+
end
316+
end
317+
311318
function deprecation_warnings(; use_optim = false, homotopy = true)
312319
if use_optim
313320
@warn("use_optim is deprecated and will be removed in a future version")

0 commit comments

Comments
 (0)