Skip to content

Commit 8cc9f96

Browse files
author
Pepijn de Vos
committed
Change typeof(x) <: y to x isa y
1 parent f2dfed3 commit 8cc9f96

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/integrators/interface.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ end
4848
step_accept_controller!(integrator, getalg(integrator.alg))
4949
integrator.last_stepfail = false
5050
integrator.tprev = integrator.t
51-
if typeof(integrator.t) <: AbstractFloat && !isempty(integrator.opts.tstops)
51+
if integrator.t isa AbstractFloat && !isempty(integrator.opts.tstops)
5252
tstop = integrator.tdir * first(integrator.opts.tstops)
5353
@fastmath abs(ttmp - tstop) < 10eps(integrator.t) ? (integrator.t = tstop) :
5454
(integrator.t = ttmp)
@@ -60,7 +60,7 @@ end
6060
end
6161
else # Non adaptive
6262
integrator.tprev = integrator.t
63-
if typeof(integrator.t) <: AbstractFloat && !isempty(integrator.opts.tstops)
63+
if integrator.t isa AbstractFloat && !isempty(integrator.opts.tstops)
6464
tstop = integrator.tdir * first(integrator.opts.tstops)
6565
# For some reason 10eps(integrator.t) is slow here
6666
# TODO: Allow higher precision but profile
@@ -328,7 +328,7 @@ end
328328
save_val = val
329329
copyat_or_push!(integrator.sol.t, integrator.saveiter, curt)
330330
copyat_or_push!(integrator.sol.u, integrator.saveiter, save_val, Val{false})
331-
if typeof(integrator.alg) <: StochasticDiffEq.StochasticDiffEqCompositeAlgorithm
331+
if integrator.alg isa StochasticDiffEq.StochasticDiffEqCompositeAlgorithm
332332
copyat_or_push!(integrator.sol.alg_choice, integrator.saveiter,
333333
integrator.cache.current)
334334
end
@@ -341,7 +341,7 @@ end
341341
copyat_or_push!(integrator.sol.u, integrator.saveiter,
342342
integrator.u[integrator.opts.save_idxs], Val{false})
343343
end
344-
if typeof(integrator.alg) <:
344+
if integrator.alg isa
345345
Union{StochasticDiffEq.StochasticDiffEqCompositeAlgorithm,
346346
StochasticDiffEq.StochasticDiffEqRODECompositeAlgorithm}
347347
copyat_or_push!(integrator.sol.alg_choice, integrator.saveiter,
@@ -359,7 +359,7 @@ end
359359
integrator.u[integrator.opts.save_idxs], Val{false})
360360
end
361361
copyat_or_push!(integrator.sol.t, integrator.saveiter, integrator.t)
362-
if typeof(integrator.alg) <:
362+
if integrator.alg isa
363363
Union{StochasticDiffEq.StochasticDiffEqCompositeAlgorithm,
364364
StochasticDiffEq.StochasticDiffEqRODECompositeAlgorithm}
365365
copyat_or_push!(integrator.sol.alg_choice, integrator.saveiter,

src/integrators/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function handle_discontinuities!(integrator::SDDEIntegrator)
5151
# remove all discontinuities close to the current time point as well and
5252
# calculate minimal order of these discontinuities
5353
# integrator.EEst has unitless type of integrator.t
54-
if typeof(integrator.EEst) <: AbstractFloat
54+
if integrator.EEst isa AbstractFloat
5555
maxΔt = 10eps(integrator.t)
5656

5757
while !isempty(integrator.opts.d_discontinuities) &&

src/solve.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract
1818
Rational{Int}}[],
1919
save_idxs = nothing,
2020
save_everystep = isempty(saveat),
21-
save_noise = save_everystep && (typeof(prob.f) <: Tuple ?
21+
save_noise = save_everystep && (prob.f isa Tuple ?
2222
DiffEqBase.has_analytic(prob.f[1]) :
2323
DiffEqBase.has_analytic(prob.f)),
2424
save_on = true,
2525
save_start = save_everystep || isempty(saveat) ||
26-
typeof(saveat) <: Number ? true :
26+
saveat isa Number ? true :
2727
prob.tspan[1] in saveat,
2828
save_end = nothing,
2929
callback = nothing,
@@ -68,7 +68,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract
6868
discontinuity_reltol = 0, kwargs...) where {recompile_flag}
6969

7070
# alg = getalg(alg0);
71-
if typeof(prob.f) <: Tuple
71+
if prob.f isa Tuple
7272
if any(mm != I for mm in prob.f.mass_matrix)
7373
error("This solver is not able to use mass matrices.")
7474
end
@@ -80,7 +80,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract
8080
@warn("Dense output is incompatible with saveat. Please use the SavingCallback from the Callback Library to mix the two behaviors.")
8181
end
8282

83-
if typeof(prob.noise) <: NoiseProcess && prob.noise.bridge === nothing && adaptive
83+
if prob.noise isa NoiseProcess && prob.noise.bridge === nothing && adaptive
8484
error("Bridge function must be given for adaptivity. Either declare this function in noise process or set adaptive=false")
8585
end
8686

@@ -156,9 +156,9 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract
156156
reltol_internal = real.(reltol)
157157
end
158158

159-
if isinplace(prob) && typeof(u) <: AbstractArray && eltype(u) <: Number &&
159+
if isinplace(prob) && u isa AbstractArray && eltype(u) <: Number &&
160160
uBottomEltypeNoUnits == uBottomEltype # Could this be more efficient for other arrays?
161-
if !(typeof(u) <: ArrayPartition)
161+
if !(u isa ArrayPartition)
162162
rate_prototype = recursivecopy(u)
163163
else
164164
rate_prototype = similar(u,
@@ -185,7 +185,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract
185185
end
186186

187187
#= TODO: Jump handling
188-
if typeof(_prob) <: JumpProblem && _prob.regular_jump !== nothing
188+
if _prob isa JumpProblem && _prob.regular_jump !== nothing
189189
190190
if !isnothing(_prob.regular_jump.mark_dist) == nothing # https://github.com/JuliaDiffEq/DifferentialEquations.jl/issues/250
191191
error("Mark distributions are currently not supported in SimpleTauLeaping")
@@ -256,7 +256,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract
256256
else
257257
randElType = uBottomEltypeNoUnits # Strip units and type info
258258
if StochasticDiffEq.is_diagonal_noise(prob)
259-
if typeof(u) <: SArray
259+
if u isa SArray
260260
rand_prototype = zero(u) # TODO: Array{randElType} for units
261261
else
262262
rand_prototype = (u .- u) ./ sqrt(oneunit(t))
@@ -306,7 +306,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract
306306
reinit!(W, t)
307307
end
308308
# Reseed
309-
if typeof(W) <: NoiseProcess && W.reseed
309+
if W isa NoiseProcess && W.reseed
310310
Random.seed!(W.rng, _seed)
311311
end
312312
elseif W.t[end] != t
@@ -489,7 +489,7 @@ function DiffEqBase.__init(prob::AbstractSDDEProblem,# TODO DiffEqBasee.Abstract
489489
StochasticDiffEq.initialize_callbacks!(integrator, initialize_save)
490490
initialize!(integrator, integrator.cache)
491491

492-
save_start && typeof(alg) <: StochasticDiffEq.StochasticDiffEqCompositeAlgorithm &&
492+
save_start && alg isa StochasticDiffEq.StochasticDiffEqCompositeAlgorithm &&
493493
copyat_or_push!(alg_choice, 1, integrator.cache.current)
494494
end
495495

@@ -527,7 +527,7 @@ function DiffEqBase.solve!(integrator::SDDEIntegrator)
527527
end
528528
postamble!(integrator)
529529

530-
f = typeof(integrator.sol.prob.f) <: Tuple ? integrator.sol.prob.f[1] :
530+
f = integrator.sol.prob.f isa Tuple ? integrator.sol.prob.f[1] :
531531
integrator.sol.prob.f
532532

533533
if DiffEqBase.has_analytic(f)
@@ -589,7 +589,7 @@ function tstop_saveat_disc_handling(tstops, saveat, d_discontinuities, tspan,
589589

590590
# saving time points
591591
saveat_internal = BinaryMinHeap{tType}()
592-
if typeof(saveat) <: Number
592+
if saveat isa Number
593593
if (t0:saveat:tf)[end] == tf
594594
for t in (t0 + saveat):saveat:tf
595595
push!(saveat_internal, tdir * t)

src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function has_dependent_lags(prob::SDDEProblem)
3434
end
3535

3636
function u_uprev(u0; alias_u0 = false)
37-
if typeof(u0) <: Tuple
37+
if u0 isa Tuple
3838
u = ArrayPartition(prob.u0, Val{true})
3939
else
4040
if alias_u0
@@ -247,10 +247,10 @@ end
247247

248248
function unwrap_alg(integrator::SDDEIntegrator, is_stiff)
249249
alg = integrator.alg
250-
iscomp = typeof(alg) <: StochasticDiffEq.StochasticCompositeAlgorithm
250+
iscomp = alg isa StochasticDiffEq.StochasticCompositeAlgorithm
251251
if !iscomp
252252
return alg
253-
elseif typeof(alg.choice_function) <: DiffEqBase.AutoSwitch
253+
elseif alg.choice_function isa DiffEqBase.AutoSwitch
254254
num = is_stiff ? 2 : 1
255255
return alg.algs[num]
256256
else

0 commit comments

Comments
 (0)