Skip to content

Commit

Permalink
Change typeof(x) <: y to x isa y
Browse files Browse the repository at this point in the history
  • Loading branch information
Pepijn de Vos committed Nov 2, 2023
1 parent b01e0c3 commit 5ad93b8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions gen/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function wrap_sundials_api(expr::Expr)
if occursin(r"UserDataB?$", func_name)
# replace Ptr{Void} with Any to allow passing Julia objects through user data
for (i, arg_expr) in enumerate(expr.args[2].args[1].args)
if !(typeof(arg_expr) <: Symbol) &&
if !(arg_expr isa Symbol) &&
arg_expr.args[1] in values(ctor_return_type)
if arg_expr.args[2] == :(Ptr{Cvoid})
arg_expr.args[2] = Any
Expand All @@ -96,7 +96,7 @@ function wrap_sundials_api(expr::Expr)
end
end
end
if !(typeof(expr) <: Symbol) && length(expr.args) > 1 &&
if !(expr isa Symbol) && length(expr.args) > 1 &&
(expr.args[2].args[1].args[2].args[2] == :libsundials_sunlinsol ||
expr.args[2].args[1].args[2].args[2] == :libsundials_sunmatrix ||
expr.args[2].args[1].args[2].args[2] == :libsundials_sunnonlinsol)
Expand Down Expand Up @@ -124,7 +124,7 @@ function wrap_sundials_api(expr::Expr)
# 2) expr for local var definition, nothing if not required
# 3) expr for low-level wrapper call
# if 1)==3), then no wrapping is required
if typeof(expr) <: Symbol
if expr isa Symbol
arg_name_expr = expr
arg_type_expr = Any
else
Expand Down
2 changes: 1 addition & 1 deletion src/common_interface/function_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function massmat(t::Float64,
tmp1::N_Vector,
tmp2::N_Vector,
tmp3::N_Vector)
if typeof(mmf.mass_matrix) <: Array
if mmf.mass_matrix isa Array
M = convert(Matrix, _M)
M .= mmf.mass_matrix
else
Expand Down
4 changes: 2 additions & 2 deletions src/common_interface/integrator_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ DiffEqBase.postamble!(integrator::AbstractSundialsIntegrator) = nothing
tstop = first(integrator.opts.tstops)
set_stop_time(integrator, tstop)
integrator.tprev = integrator.t
if !(typeof(integrator.opts.callback.continuous_callbacks) <: Tuple{})
if !(integrator.opts.callback.continuous_callbacks isa Tuple{})

Check warning on line 223 in src/common_interface/integrator_types.jl

View check run for this annotation

Codecov / codecov/patch

src/common_interface/integrator_types.jl#L223

Added line #L223 was not covered by tests
integrator.uprev .= integrator.u
end
solver_step(integrator, tstop)
Expand All @@ -231,7 +231,7 @@ DiffEqBase.postamble!(integrator::AbstractSundialsIntegrator) = nothing
end
else
integrator.tprev = integrator.t
if !(typeof(integrator.opts.callback.continuous_callbacks) <: Tuple{})
if !(integrator.opts.callback.continuous_callbacks isa Tuple{})
integrator.uprev .= integrator.u
end
if !isempty(integrator.opts.tstops)
Expand Down
4 changes: 2 additions & 2 deletions src/common_interface/integrator_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function handle_callbacks!(integrator)
continuous_modified = false
discrete_modified = false
saved_in_cb = false
if !(typeof(continuous_callbacks) <: Tuple{})
if !(continuous_callbacks isa Tuple{})
time, upcrossing, event_occured, event_idx, idx, counter = DiffEqBase.find_first_continuous_callback(integrator,
continuous_callbacks...)
if event_occured
Expand All @@ -22,7 +22,7 @@ function handle_callbacks!(integrator)
integrator.vector_event_last_time = 1
end
end
if !(typeof(discrete_callbacks) <: Tuple{})
if !(discrete_callbacks isa Tuple{})
discrete_modified, saved_in_cb = DiffEqBase.apply_discrete_callback!(integrator,
discrete_callbacks...)
end
Expand Down

0 comments on commit 5ad93b8

Please sign in to comment.