Skip to content

Commit

Permalink
warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rbed committed Aug 17, 2024
1 parent 5522b9a commit 968fd9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
11 changes: 5 additions & 6 deletions src/solver/ia_main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function isolate(lhs, var; warns=true, conditions=[])
return roots, conditions
end

isequal(old_lhs, lhs) && (warns &&
(@warn("This expression cannot be solved with the methods available to ia_solve. Try \
a numerical method instead.");
return nothing) || return nothing)
if isequal(old_lhs, lhs)
warns && @warn("This expression cannot be solved with the methods available to ia_solve. Try a numerical method instead.")
return nothing
end

old_lhs = deepcopy(lhs)

Expand Down Expand Up @@ -173,8 +173,7 @@ function attract(lhs, var; warns = true)
if sqrt_poly
return attract_and_solve_sqrtpoly(lhs, var), conditions
else
warns &&
@warn("This expression cannot be solved with the methods available to ia_solve. Try \
warns && @warn("This expression cannot be solved with the methods available to ia_solve. Try \
a numerical method instead.")
return nothing, conditions
end
Expand Down
26 changes: 14 additions & 12 deletions src/solver/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ function symbolic_solve(expr, x::T; dropmultiplicity = true, warns = true) where
for i in eachindex(expr)
expr[i] = expr[i] isa Equation ? expr[i].lhs - expr[i].rhs : expr[i]
check_expr_validity(expr[i])
!check_poly_inunivar(expr[i], x) && (warns &&
(@warn "Solve can not solve this input currently"; return nothing) ||
return nothing)
if !check_poly_inunivar(expr[i], x)
warns && @warn("Solve can not solve this input currently")
return nothing
end
end
expr = Vector{Num}(expr)
end
Expand All @@ -148,9 +149,10 @@ function symbolic_solve(expr, x::T; dropmultiplicity = true, warns = true) where
isequal(sols, nothing) && return nothing
else
for i in eachindex(expr)
!check_poly_inunivar(expr[i], x) && (warns &&
(@warn("Solve can not solve this input currently"); return nothing) ||
return nothing)
if !check_poly_inunivar(expr[i], x)
warns && @warn("Solve can not solve this input currently")
return nothing
end
end
sols = solve_multipoly(
expr, x, dropmultiplicity = dropmultiplicity, warns = warns)
Expand All @@ -164,11 +166,10 @@ function symbolic_solve(expr, x::T; dropmultiplicity = true, warns = true) where
if !expr_univar && !x_univar
for e in expr
for var in x
!check_poly_inunivar(e, var) &&
((warns &&
@warn("This system can not be currently solved by solve.");
return nothing) ||
return nothing)
if !check_poly_inunivar(e, var)
warns && @warn("This system can not be currently solved by solve.")
return nothing
end
end
end

Expand Down Expand Up @@ -276,7 +277,8 @@ function solve_multipoly(polys::Vector, x::Num; dropmultiplicity = true, warns =
polys = unique(polys)

if length(polys) < 1
warns && (@warn("No expressions entered"); return nothing || return nothing)
warns && @warn("No expressions entered")
return nothing
end
if length(polys) == 1
return solve_univar(polys[1], x, dropmultiplicity = dropmultiplicity)
Expand Down

0 comments on commit 968fd9e

Please sign in to comment.