JuliaIntervals / IntervalConstraintProgramming.jl

Calculate rigorously the feasible region for a set of real-valued inequalities with Julia
Other
63 stars 16 forks source link

Throw useful error when there is no comparison operator in `Separator` #156

Open dpsanders opened 4 years ago

dpsanders commented 4 years ago
julia> using IntervalConstraintProgramming, ModelingToolkit

julia> f(x) = (x - 0.2)*(x - 0.8)
f (generic function with 1 method)

julia> vars = @variables x
(x,)

julia> Separator(vars, f)
ERROR: MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(::Core.SimpleVector) at essentials.jl:600
  iterate(::Core.SimpleVector, ::Any) at essentials.jl:600
  iterate(::ExponentialBackOff) at error.jl:218
  ...
Stacktrace:
 [1] indexed_iterate(::Nothing, ::Int64) at ./tuple.jl:66
 [2] Separator(::Tuple{Operation}, ::Operation) at /Users/dpsanders/.julia/packages/IntervalConstraintProgramming/ta93g/src/separator.jl:199
 [3] Separator(::Tuple{Operation}, ::Function) at /Users/dpsanders/.julia/packages/IntervalConstraintProgramming/ta93g/src/separator.jl:205
 [4] top-level scope at REPL[6]:1

cc @yashcodes

dpsanders commented 4 years ago

Ah, it should be Separator(x, f(x) < 0). There should be a better warning message though.