Skip to content

Commit

Permalink
depwarn fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Jul 14, 2018
1 parent 6dd6716 commit bf3a43e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/ODEInterfaceDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using Reexport
@reexport using DiffEqBase

using ODEInterface, Compat, DataStructures, FunctionWrappers, Roots
using LinearAlgebra

import DiffEqBase: solve

Expand All @@ -14,7 +15,7 @@ const warnkeywords =
:calck, :progress, :timeseries_steps, :dense,:save_start)

function __init__()
const global warnlist = Set(warnkeywords)
global warnlist = Set(warnkeywords)
end

@compat const KW = Dict{Symbol,Any}
Expand Down
18 changes: 9 additions & 9 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ODEInterface.jl Algorithms

@compat abstract type ODEInterfaceAlgorithm <: DiffEqBase.AbstractODEAlgorithm end
immutable dopri5 <: ODEInterfaceAlgorithm end
immutable dop853 <: ODEInterfaceAlgorithm end
immutable odex <: ODEInterfaceAlgorithm end
immutable seulex <: ODEInterfaceAlgorithm end
immutable radau <: ODEInterfaceAlgorithm end
immutable radau5 <: ODEInterfaceAlgorithm end
immutable rodas <: ODEInterfaceAlgorithm end
immutable ddeabm <: ODEInterfaceAlgorithm end
immutable ddebdf <: ODEInterfaceAlgorithm end
struct dopri5 <: ODEInterfaceAlgorithm end
struct dop853 <: ODEInterfaceAlgorithm end
struct odex <: ODEInterfaceAlgorithm end
struct seulex <: ODEInterfaceAlgorithm end
struct radau <: ODEInterfaceAlgorithm end
struct radau5 <: ODEInterfaceAlgorithm end
struct rodas <: ODEInterfaceAlgorithm end
struct ddeabm <: ODEInterfaceAlgorithm end
struct ddebdf <: ODEInterfaceAlgorithm end
16 changes: 8 additions & 8 deletions src/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ end

@inline function determine_event_occurance(integrator,callback)
event_occurred = false
Θs = linspace(typeof(integrator.t)(0),typeof(integrator.t)(1),callback.interp_points)
Θs = range(typeof(integrator.t)(0),stop=typeof(integrator.t)(1),length=callback.interp_points)
interp_index = 0
dt = integrator.t - integrator.tprev
# Check if the event occured
if typeof(callback.idxs) <: Void
if typeof(callback.idxs) <: Nothing
previous_condition = callback.condition(integrator.uprev,integrator.tprev,integrator)
elseif typeof(callback.idxs) <: Number
previous_condition = callback.condition(integrator.uprev[callback.idxs],integrator.tprev,integrator)
Expand Down Expand Up @@ -69,14 +69,14 @@ end
end

prev_sign_index = 1
if typeof(callback.idxs) <: Void
if typeof(callback.idxs) <: Nothing
next_sign = sign(callback.condition(integrator.u,integrator.t,integrator))
elseif typeof(callback.idxs) <: Number
next_sign = sign(callback.condition(integrator.u[callback.idxs],integrator.t,integrator))
else
next_sign = sign(callback.condition(@view(integrator.u[callback.idxs]),integrator.t,integrator))
end
if ((prev_sign<0 && !(typeof(callback.affect!)<:Void)) || (prev_sign>0 && !(typeof(callback.affect_neg!)<:Void))) && prev_sign*next_sign<=0
if ((prev_sign<0 && !(typeof(callback.affect!)<:Nothing)) || (prev_sign>0 && !(typeof(callback.affect_neg!)<:Nothing))) && prev_sign*next_sign<=0
event_occurred = true
interp_index = callback.interp_points
elseif callback.interp_points!=0 # Use the interpolants for safety checking
Expand All @@ -92,7 +92,7 @@ end
prev_sign = sign(new_sign)
prev_sign_index = i
end
if ((prev_sign<0 && !(typeof(callback.affect!)<:Void)) || (prev_sign>0 && !(typeof(callback.affect_neg!)<:Void))) && prev_sign*new_sign<0
if ((prev_sign<0 && !(typeof(callback.affect!)<:Nothing)) || (prev_sign>0 && !(typeof(callback.affect_neg!)<:Nothing))) && prev_sign*new_sign<0
event_occurred = true
interp_index = i
break
Expand All @@ -106,7 +106,7 @@ function find_callback_time(integrator,callback)
event_occurred,interp_index,Θs,prev_sign,prev_sign_index = determine_event_occurance(integrator,callback)
dt = integrator.t - integrator.tprev
if event_occurred
if typeof(callback.condition) <: Void
if typeof(callback.condition) <: Nothing
new_t = zero(typeof(integrator.t))
else
if callback.interp_points!=0
Expand Down Expand Up @@ -170,13 +170,13 @@ function apply_callback!(integrator,callback::ContinuousCallback,cb_time,prev_si
integrator.u_modified = true

if prev_sign < 0
if typeof(callback.affect!) <: Void
if typeof(callback.affect!) <: Nothing
integrator.u_modified = false
else
callback.affect!(integrator)
end
elseif prev_sign > 0
if typeof(callback.affect_neg!) <: Void
if typeof(callback.affect_neg!) <: Nothing
integrator.u_modified = false
else
callback.affect_neg!(integrator)
Expand Down
11 changes: 6 additions & 5 deletions src/solve.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
function solve{uType,tuptType,isinplace,AlgType<:ODEInterfaceAlgorithm}(
function solve(
prob::DiffEqBase.AbstractODEProblem{uType,tuptType,isinplace},
alg::AlgType,
timeseries=[],ts=[],ks=[];
saveat = Float64[],
verbose=true,save_everystep = isempty(saveat),
save_start=true,
timeseries_errors=true,dense_errors=false,
callback=nothing,kwargs...)
callback=nothing,kwargs...) where
{uType,tuptType,isinplace,AlgType<:ODEInterfaceAlgorithm}

tType = eltype(tuptType)

Expand All @@ -15,7 +16,7 @@ function solve{uType,tuptType,isinplace,AlgType<:ODEInterfaceAlgorithm}(
warned = !isempty(kwargs) && check_keywords(alg, kwargs, warnlist)
if !(typeof(prob.f) <: DiffEqBase.AbstractParameterizedFunction) && isstiff
if DiffEqBase.has_tgrad(prob.f)
warn("Explicit t-gradient given to this stiff solver is ignored.")
@warn("Explicit t-gradient given to this stiff solver is ignored.")
warned = true
end
end
Expand Down Expand Up @@ -55,8 +56,8 @@ function solve{uType,tuptType,isinplace,AlgType<:ODEInterfaceAlgorithm}(
o[:RHS_CALLMODE] = ODEInterface.RHS_CALL_INSITU

if save_everystep
_timeseries = Vector{uType}(0)
ts = Vector{tType}(0)
_timeseries = Vector{uType}(undef,0)
ts = Vector{tType}(undef,0)
else
_timeseries = [copy(u0)]
ts = [tspan[1]]
Expand Down
3 changes: 3 additions & 0 deletions test/algorithm_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using ODEInterfaceDiffEq, DiffEqProblemLibrary, DiffEqBase, Test
using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems()
import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_linear,
prob_ode_2Dlinear, prob_ode_vanderpol

prob = prob_ode_linear
sol =solve(prob,dopri5(),dt=1//2^(4))
Expand Down
2 changes: 1 addition & 1 deletion test/callbacks.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ODEInterfaceDiffEq, Base.Test
using ODEInterfaceDiffEq, Test

callback_f = function (du,u,p,t)
du[1] = u[2]
Expand Down
2 changes: 1 addition & 1 deletion test/jac_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ODEInterfaceDiffEq, DiffEqProblemLibrary, DiffEqBase
using Base.Test
using Test

jac_called = false

Expand Down
5 changes: 4 additions & 1 deletion test/mass_matrix_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using ODEInterfaceDiffEq, DiffEqProblemLibrary, DiffEqBase
using Base.Test
using Test

using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems()
import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_mm_linear

prob = prob_ode_mm_linear

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ODEInterfaceDiffEq, DiffEqProblemLibrary, DiffEqBase
using Base.Test
using Test

@time @testset "Algorithms" begin include("algorithm_tests.jl") end
@time @testset "Saving" begin include("saving_tests.jl") end
Expand Down
5 changes: 4 additions & 1 deletion test/saving_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using ODEInterfaceDiffEq, DiffEqProblemLibrary, DiffEqBase
using Base.Test
using Test

using DiffEqProblemLibrary.ODEProblemLibrary: importodeproblems; importodeproblems()
import DiffEqProblemLibrary.ODEProblemLibrary: prob_ode_linear

prob = prob_ode_linear
sol =solve(prob,dopri5(),dt=1//2^(4))
Expand Down

0 comments on commit bf3a43e

Please sign in to comment.