Skip to content

Commit

Permalink
Merge pull request #104 from shahriariravanian/main
Browse files Browse the repository at this point in the history
Adding TermInterface and updating compat
  • Loading branch information
shahriariravanian authored Aug 24, 2024
2 parents 801e41e + d930394 commit 60e6f01
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SymbolicNumericIntegration"
uuid = "78aadeae-fbc0-11eb-17b6-c7ec0477ba9e"
authors = ["Shahriar Iravanian <siravan@svtsim.com>"]
version = "1.8.0"
version = "1.9.0"

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

[compat]
DataDrivenDiffEq = "1.5"
Expand All @@ -22,6 +23,7 @@ SpecialFunctions = "2"
Statistics = "<0.0.1, 1"
SymbolicUtils = "2.1, 3"
Symbolics = "6"
TermInterface = "2"
julia = "1.9"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions src/SymbolicNumericIntegration.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module SymbolicNumericIntegration

using TermInterface: iscall
using SymbolicUtils
using SymbolicUtils: iscall, operation, arguments
using SymbolicUtils: operation, arguments
using Symbolics
using Symbolics: value, get_variables, expand_derivatives, coeff, Equation
using SymbolicUtils.Rewriters
Expand Down Expand Up @@ -33,7 +34,6 @@ export Ei, Si, Ci, Li

include("numeric_utils.jl")
include("sparse.jl")
# include("optim.jl")
include("integral.jl")

export integrate, generate_basis, best_hints
Expand Down
23 changes: 15 additions & 8 deletions src/integral.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,7 @@ function integrate_term(eq, x; kwargs...)
end

if symbolic
y = integrate_symbolic(eq, x; plan)
if y == nothing
if has_sym_consts
@info("Symbolic integration failed. Try changing constant parameters ([$(join(params, ", "))]) to numerical values.")
end

return 0, eq, Inf
end
return try_symbolic(eq, x, has_sym_consts, params)
end

eq = cache(eq)
Expand Down Expand Up @@ -308,6 +301,20 @@ function try_integrate(eq, x, basis; plan = default_plan())
return solve_sparse(eq, x, basis; plan)
end

function try_symbolic(eq, x, has_sym_consts = false, params = []; plan = default_plan())
y = integrate_symbolic(eq, x; plan)

if y == nothing
if has_sym_consts && !isempty(params)
@info("Symbolic integration failed. Try changing constant parameters ([$(join(params, ", "))]) to numerical values.")
end

return 0, eq, Inf
else
return y, 0, 0
end
end

function deprecation_warnings(; use_optim = false, homotopy = true)
if use_optim
@warn("use_optim is deprecated and will be removed in a future version")
Expand Down

0 comments on commit 60e6f01

Please sign in to comment.