diff --git a/src/integrators/interface.jl b/src/integrators/interface.jl index 6dcefdd..592d5be 100644 --- a/src/integrators/interface.jl +++ b/src/integrators/interface.jl @@ -48,7 +48,7 @@ end step_accept_controller!(integrator, getalg(integrator.alg)) integrator.last_stepfail = false integrator.tprev = integrator.t - if typeof(integrator.t) <: AbstractFloat && !isempty(integrator.opts.tstops) + if integrator.t isa AbstractFloat && !isempty(integrator.opts.tstops) tstop = integrator.tdir * first(integrator.opts.tstops) @fastmath abs(ttmp - tstop) < 10eps(integrator.t) ? (integrator.t = tstop) : (integrator.t = ttmp) @@ -60,7 +60,7 @@ end end else # Non adaptive integrator.tprev = integrator.t - if typeof(integrator.t) <: AbstractFloat && !isempty(integrator.opts.tstops) + if integrator.t isa AbstractFloat && !isempty(integrator.opts.tstops) tstop = integrator.tdir * first(integrator.opts.tstops) # For some reason 10eps(integrator.t) is slow here # TODO: Allow higher precision but profile @@ -328,7 +328,7 @@ end save_val = val copyat_or_push!(integrator.sol.t, integrator.saveiter, curt) copyat_or_push!(integrator.sol.u, integrator.saveiter, save_val, Val{false}) - if typeof(integrator.alg) <: StochasticDiffEq.StochasticDiffEqCompositeAlgorithm + if integrator.alg isa StochasticDiffEq.StochasticDiffEqCompositeAlgorithm copyat_or_push!(integrator.sol.alg_choice, integrator.saveiter, integrator.cache.current) end @@ -341,7 +341,7 @@ end copyat_or_push!(integrator.sol.u, integrator.saveiter, integrator.u[integrator.opts.save_idxs], Val{false}) end - if typeof(integrator.alg) <: + if integrator.alg isa Union{StochasticDiffEq.StochasticDiffEqCompositeAlgorithm, StochasticDiffEq.StochasticDiffEqRODECompositeAlgorithm} copyat_or_push!(integrator.sol.alg_choice, integrator.saveiter, @@ -359,7 +359,7 @@ end integrator.u[integrator.opts.save_idxs], Val{false}) end copyat_or_push!(integrator.sol.t, integrator.saveiter, integrator.t) - if typeof(integrator.alg) <: + if integrator.alg isa Union{StochasticDiffEq.StochasticDiffEqCompositeAlgorithm, StochasticDiffEq.StochasticDiffEqRODECompositeAlgorithm} copyat_or_push!(integrator.sol.alg_choice, integrator.saveiter, diff --git a/src/integrators/utils.jl b/src/integrators/utils.jl index be59c9d..45827ad 100644 --- a/src/integrators/utils.jl +++ b/src/integrators/utils.jl @@ -51,7 +51,7 @@ function handle_discontinuities!(integrator::SDDEIntegrator) # remove all discontinuities close to the current time point as well and # calculate minimal order of these discontinuities # integrator.EEst has unitless type of integrator.t - if typeof(integrator.EEst) <: AbstractFloat + if integrator.EEst isa AbstractFloat maxΔt = 10eps(integrator.t) while !isempty(integrator.opts.d_discontinuities) && diff --git a/src/solve.jl b/src/solve.jl index 269b8ce..dc3b8ef 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -18,12 +18,12 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract Rational{Int}}[], save_idxs = nothing, save_everystep = isempty(saveat), - save_noise = save_everystep && (typeof(prob.f) <: Tuple ? + save_noise = save_everystep && (prob.f isa Tuple ? DiffEqBase.has_analytic(prob.f[1]) : DiffEqBase.has_analytic(prob.f)), save_on = true, save_start = save_everystep || isempty(saveat) || - typeof(saveat) <: Number ? true : + saveat isa Number ? true : prob.tspan[1] in saveat, save_end = nothing, callback = nothing, @@ -68,7 +68,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract discontinuity_reltol = 0, kwargs...) where {recompile_flag} # alg = getalg(alg0); - if typeof(prob.f) <: Tuple + if prob.f isa Tuple if any(mm != I for mm in prob.f.mass_matrix) error("This solver is not able to use mass matrices.") end @@ -80,7 +80,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract @warn("Dense output is incompatible with saveat. Please use the SavingCallback from the Callback Library to mix the two behaviors.") end - if typeof(prob.noise) <: NoiseProcess && prob.noise.bridge === nothing && adaptive + if prob.noise isa NoiseProcess && prob.noise.bridge === nothing && adaptive error("Bridge function must be given for adaptivity. Either declare this function in noise process or set adaptive=false") end @@ -156,9 +156,9 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract reltol_internal = real.(reltol) end - if isinplace(prob) && typeof(u) <: AbstractArray && eltype(u) <: Number && + if isinplace(prob) && u isa AbstractArray && eltype(u) <: Number && uBottomEltypeNoUnits == uBottomEltype # Could this be more efficient for other arrays? - if !(typeof(u) <: ArrayPartition) + if !(u isa ArrayPartition) rate_prototype = recursivecopy(u) else rate_prototype = similar(u, @@ -185,7 +185,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract end #= TODO: Jump handling - if typeof(_prob) <: JumpProblem && _prob.regular_jump !== nothing + if _prob isa JumpProblem && _prob.regular_jump !== nothing if !isnothing(_prob.regular_jump.mark_dist) == nothing # https://github.com/JuliaDiffEq/DifferentialEquations.jl/issues/250 error("Mark distributions are currently not supported in SimpleTauLeaping") @@ -256,7 +256,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract else randElType = uBottomEltypeNoUnits # Strip units and type info if StochasticDiffEq.is_diagonal_noise(prob) - if typeof(u) <: SArray + if u isa SArray rand_prototype = zero(u) # TODO: Array{randElType} for units else rand_prototype = (u .- u) ./ sqrt(oneunit(t)) @@ -306,7 +306,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract reinit!(W, t) end # Reseed - if typeof(W) <: NoiseProcess && W.reseed + if W isa NoiseProcess && W.reseed Random.seed!(W.rng, _seed) end elseif W.t[end] != t @@ -489,7 +489,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract StochasticDiffEq.initialize_callbacks!(integrator, initialize_save) initialize!(integrator, integrator.cache) - save_start && typeof(alg) <: StochasticDiffEq.StochasticDiffEqCompositeAlgorithm && + save_start && alg isa StochasticDiffEq.StochasticDiffEqCompositeAlgorithm && copyat_or_push!(alg_choice, 1, integrator.cache.current) end @@ -527,7 +527,7 @@ function DiffEqBase.solve!(integrator::SDDEIntegrator) end postamble!(integrator) - f = typeof(integrator.sol.prob.f) <: Tuple ? integrator.sol.prob.f[1] : + f = integrator.sol.prob.f isa Tuple ? integrator.sol.prob.f[1] : integrator.sol.prob.f if DiffEqBase.has_analytic(f) @@ -589,7 +589,7 @@ function tstop_saveat_disc_handling(tstops, saveat, d_discontinuities, tspan, # saving time points saveat_internal = BinaryMinHeap{tType}() - if typeof(saveat) <: Number + if saveat isa Number if (t0:saveat:tf)[end] == tf for t in (t0 + saveat):saveat:tf push!(saveat_internal, tdir * t) diff --git a/src/utils.jl b/src/utils.jl index 94184f9..0398818 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -34,7 +34,7 @@ function has_dependent_lags(prob::SDDEProblem) end function u_uprev(u0; alias_u0 = false) - if typeof(u0) <: Tuple + if u0 isa Tuple u = ArrayPartition(prob.u0, Val{true}) else if alias_u0 @@ -247,10 +247,10 @@ end function unwrap_alg(integrator::SDDEIntegrator, is_stiff) alg = integrator.alg - iscomp = typeof(alg) <: StochasticDiffEq.StochasticCompositeAlgorithm + iscomp = alg isa StochasticDiffEq.StochasticCompositeAlgorithm if !iscomp return alg - elseif typeof(alg.choice_function) <: DiffEqBase.AutoSwitch + elseif alg.choice_function isa DiffEqBase.AutoSwitch num = is_stiff ? 2 : 1 return alg.algs[num] else