Skip to content

Commit 942c08a

Browse files
Merge pull request #482 from SciML/revert-476-kg/cbfix
Revert "Fix bisection to make it not return tprev"
2 parents 1aa1d3e + c1be9ab commit 942c08a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/callbacks.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ end
567567
# rough implementation, needs multiple type handling
568568
# always ensures that if r = bisection(f, (x0, x1))
569569
# then either f(nextfloat(r)) == 0 or f(nextfloat(r)) * f(r) < 0
570-
function bisection(f, tup, tdir; maxiters=100, noleft=false)
570+
function bisection(f, tup, tdir; maxiters=100)
571571
x0, x1 = tup
572572
fx0x1 = f(x0) * f(x1)
573573
fzero = zero(fx0x1)
@@ -600,7 +600,7 @@ function bisection(f, tup, tdir; maxiters=100, noleft=false)
600600
end
601601
end
602602
end
603-
(left === mid || right === mid) && return ((left === tup[1]) && noleft ? right : left)
603+
(left === mid || right === mid) && return left
604604
if sign(y) === sign(f(left))
605605
left = mid
606606
else
@@ -650,7 +650,7 @@ function find_callback_time(integrator,callback::ContinuousCallback,counter)
650650
end
651651
iter == 12 && error("Double callback crossing floating pointer reducer errored. Report this issue.")
652652
end
653-
Θ = bisection(zero_func, (bottom_t, top_t), integrator.tdir; noleft=(bottom_t==integrator.tprev))
653+
Θ = bisection(zero_func, (bottom_t, top_t), integrator.tdir)
654654
integrator.last_event_error = ODE_DEFAULT_NORM(zero_func(Θ), Θ)
655655
end
656656
#Θ = prevfloat(...)
@@ -717,7 +717,7 @@ function find_callback_time(integrator,callback::VectorContinuousCallback,counte
717717
end
718718
iter == 12 && error("Double callback crossing floating pointer reducer errored. Report this issue.")
719719
end
720-
Θ = bisection(zero_func, (bottom_t,top_t), integrator.tdir; noleft=(bottom_t==integrator.tprev))
720+
Θ = bisection(zero_func, (bottom_t,top_t), integrator.tdir)
721721
if integrator.tdir * Θ < integrator.tdir * min_t
722722
integrator.last_event_error = ODE_DEFAULT_NORM(zero_func(Θ), Θ)
723723
end

src/init.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function __init__()
8585

8686
get_tmp(dc::DiffCache, u::AbstractArray) = dc.du
8787

88-
bisection(f, tup::Tuple{T,T}, tdir; kwargs...) where {T<:ForwardDiff.Dual} = find_zero(f, tup, Roots.AlefeldPotraShi())
88+
bisection(f, tup::Tuple{T,T}, tdir) where {T<:ForwardDiff.Dual} = find_zero(f, tup, Roots.AlefeldPotraShi())
8989
end
9090

9191
@require Measurements="eff96d63-e80a-5855-80a2-b1b0885c5ab7" begin

0 commit comments

Comments
 (0)