Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change typeof(x) <: y to x isa y #432

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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
Loading