Skip to content

Commit

Permalink
Merge pull request #800 from JuliaReach/schillic/fixes
Browse files Browse the repository at this point in the history
Use `==` instead of `isequal` and `eachindex` instead of `1:length`
  • Loading branch information
schillic authored Mar 17, 2024
2 parents 4f510f3 + 82c0482 commit f1a90b6
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DocMeta.setdocmeta!(ReachabilityAnalysis, :DocTestSetup,
:(using ReachabilityAnalysis); recursive=true)

# pass --fast as an argument to skip rebuilding the examples and running doctests
const _FAST = findfirst(isequal("--fast"), ARGS) !== nothing
const _FAST = findfirst(==("--fast"), ARGS) !== nothing

# ========================
# Generate examples
Expand Down
6 changes: 3 additions & 3 deletions src/Algorithms/LGG09/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end

function _reach_homog_dir_LGG09!(ρℓ, Ω₀, Φᵀ, dirs, NSTEPS, cache, threaded::Val{true})
= _collect(dirs)
Threads.@threads for j in 1:length(ℓ)
Threads.@threads for j in eachindex(ℓ)
reach_homog_dir_LGG09!(ρℓ, j, Ω₀, Φᵀ, ℓ[j], NSTEPS, cache)
end
end
Expand Down Expand Up @@ -111,7 +111,7 @@ end

#=---- version using vector-of-vectors
# preallocate output sequence
ρℓ = [Vector{N}(undef, NSTEPS) for _ in 1:length(dirs)]
ρℓ = [Vector{N}(undef, NSTEPS) for _ in dirs]
# for each direction, compute NSTEPS iterations
@inbounds for (i, ℓ) in enumerate(dirs)
Expand All @@ -121,7 +121,7 @@ end
# fill template reach-set sequence
Δt = (zero(N) .. δ) + time_shift
@inbounds for k in 1:NSTEPS
sf = [ρℓ[i][k] for i in 1:length(dirs)]
sf = [ρℓ[i][k] for i in eachindex(dirs)]
F[k] = TemplateReachSet(dirs, sf, Δt)
Δt += δ
end
Expand Down
6 changes: 3 additions & 3 deletions src/Algorithms/LGG09/reach_inhomog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end

function _reach_inhomog_dir_LGG09!(ρℓ, Ω₀, Φᵀ, U, dirs, NSTEPS, cache, threaded::Val{true})
= _collect(dirs)
Threads.@threads for j in 1:length(ℓ)
Threads.@threads for j in eachindex(ℓ)
reach_inhomog_dir_LGG09!(ρℓ, j, Ω₀, Φᵀ, U, ℓ[j], NSTEPS, cache)
end
end
Expand Down Expand Up @@ -111,7 +111,7 @@ function reach_inhomog_dir_LGG09!(ρvec_ℓ::AbstractVector{N}, Ω₀, Φᵀ, U,
end

#= ---- version using vector-of-vectors
ρℓ = [Vector{N}(undef, NSTEPS) for _ in 1:length(dirs)]
ρℓ = [Vector{N}(undef, NSTEPS) for _ in dirs]
# for each direction, compute NSTEPS iterations
@inbounds for (i, ℓ) in enumerate(dirs)
Expand All @@ -121,7 +121,7 @@ end
# fill template reach-set sequence
Δt = (zero(N) .. δ) + time_shift
@inbounds for k in 1:NSTEPS
sf = [ρℓ[i][k] for i in 1:length(dirs)]
sf = [ρℓ[i][k] for i in eachindex(dirs)]
F[k] = TemplateReachSet(dirs, sf, Δt)
Δt += δ
end
Expand Down
2 changes: 1 addition & 1 deletion src/Continuous/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function _solve_distributed(cpost, S, X0, tspan, threading::Val{true}; kwargs...
FT = Flowpipe{numtype(cpost),rsetrep(cpost)} # TODO add third parameter
sol_tot = Vector{FT}(undef, nsets)

Threads.@threads for i in 1:length(X0)
Threads.@threads for i in eachindex(X0)
sol_i = ReachabilityAnalysis.post(cpost, IVP(S, X0[i]), tspan; kwargs...)
sol_tot[i] = sol_i
end
Expand Down
2 changes: 1 addition & 1 deletion src/Discretization/SecondOrderddtModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ end
function _bloat(P::LazySet, ε)
A, b = tosimplehrep(P)
= copy(b)
for i in 1:length(b)
for i in eachindex(b)
bε[i] += ε * opnorm(transpose(A[i, :]))
end
return HPolytope(A, bε)
Expand Down
2 changes: 1 addition & 1 deletion src/Flowpipes/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ end

x = Vector{N}()
y = Vector{N}()
for k in 1:length(sol)
for k in eachindex(sol)
x_new = X(k)
y_new = Y(k)
append!(x, x_new)
Expand Down
2 changes: 1 addition & 1 deletion src/Flowpipes/setops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ function _intersection(X::LazySet, Y::LazySet,

@inbounds for (i, d) in enumerate(dirs)
d = convert(VN, d)
b = minimum(ρ(d, X H[j]) for j in 1:length(H))
b = minimum(ρ(d, X H[j]) for j in eachindex(H))
out[i] = HalfSpace(d, b)
end
return HPolytope(out)
Expand Down
4 changes: 2 additions & 2 deletions test/continuous/symbolics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using StaticArrays: SVector, SMatrix, SA, StaticArray
Jexpr0 = [-2.5+2x * y x^2; 1.5-2x * y -x^2]

Jexpr = _jacobian_expression(f, var)
@test isequal(Jexpr, Jexpr0)
@test isequal(Jexpr0, Jexpr)
J = _jacobian_function(f, var)
v = [1.0, 2.0]
Jv = [1.5 1; -2.5 -1]
Expand Down Expand Up @@ -55,7 +55,7 @@ using StaticArrays: SVector, SMatrix, SA, StaticArray
aux = [1.0, 1.0] # can be any vector
@test J(aux) == A
Jexpr = _jacobian_expression(sys, var)
@test isequal(Jexpr, A)
@test Jexpr == A
end

# @testset "Symbolic-Numeric utils: Hessian" begin
Expand Down

0 comments on commit f1a90b6

Please sign in to comment.