Skip to content

Commit

Permalink
fix unbound args
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Mar 10, 2024
1 parent 79c2d49 commit 7dec550
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/Flowpipes/Flowpipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function (fp::Flowpipe)(dt::TimeInterval)
end

# concrete projection of a flowpipe along variables `vars`
function project(fp::Flowpipe, vars::NTuple{D,T}) where {D,T<:Integer}
function project(fp::Flowpipe, vars::NTuple{D,Int}) where {D}
Xk = array(fp)
πfp = map(X -> project(X, vars), Xk)
return Flowpipe(πfp, fp.ext)
Expand Down Expand Up @@ -243,7 +243,7 @@ Base.:⊆(F::Flowpipe, X::LazySet) = all(R ⊆ X for R in F)
Base.:(F::Flowpipe, Y::AbstractLazyReachSet) = all(R set(Y) for R in F)

# lazy projection of a flowpipe
function Projection(F::Flowpipe, vars::NTuple{D,T}) where {D,T<:Integer}
function Projection(F::Flowpipe, vars::NTuple{D,Int}) where {D}
Xk = array(F)
out = map(X -> Projection(X, vars), Xk)
return Flowpipe(out)
Expand Down
2 changes: 1 addition & 1 deletion src/Flowpipes/MappedFlowpipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The projection is lazy, and consists of mapping each set
`X` in the flowpipe to `MX`, where `M` is the projection matrix associated with
the given variables `vars`.
"""
function LazySets.Projection(fp::AbstractFlowpipe, vars::NTuple{D,T}) where {D,T<:Integer}
function LazySets.Projection(fp::AbstractFlowpipe, vars::NTuple{D,Int}) where {D}
# TODO: assert that vars belong to the variables of the flowpipe
M = projection_matrix(collect(vars), dim(F), Float64)
func = @map(x -> M * x)
Expand Down
4 changes: 2 additions & 2 deletions src/Flowpipes/ShiftedFlowpipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end
project(fp::ShiftedFlowpipe, vars::AbstractVector) = project(fp, Tuple(vars))
project(fp::ShiftedFlowpipe; vars) = project(fp, Tuple(vars))

function project(fp::ShiftedFlowpipe, vars::NTuple{D,T}) where {D,T<:Integer}
function project(fp::ShiftedFlowpipe, vars::NTuple{D,Int}) where {D}
Xk = array(fp)
# TODO: use projection of the reachsets
if 0 vars # projection includes "time"
Expand All @@ -60,7 +60,7 @@ end

# this method is analogue to project(::AbstractLazyReachSet, vars; check_vars=true)
# TODO add check_vars ?
function project(fp::ShiftedFlowpipe, i::Int, vars::NTuple{D,M}) where {D,M<:Integer}
function project(fp::ShiftedFlowpipe, i::Int, vars::NTuple{D,Int}) where {D}
t0 = time_shift(fp)
R = fp[i]
if 0 vars
Expand Down
27 changes: 11 additions & 16 deletions src/Flowpipes/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ end

# TODO use LazySets._plot_singleton_list_1D if the reach-sets are stored as a struct
# array. Otherwise, we could use pass the list through x -> set(x)
function _plot_singleton_list_1D(list::Union{Flowpipe{N},AbstractVector{RN}}) where {N,
RN<:AbstractReachSet{N}}
function _plot_singleton_list_1D(list::Union{Flowpipe{N},AbstractVector{<:AbstractReachSet{N}}}) where {N}
m = length(list)

x = Vector{N}(undef, m)
Expand All @@ -191,8 +190,7 @@ function _plot_singleton_list_1D(list::Union{Flowpipe{N},AbstractVector{RN}}) wh
return x, y
end

function _plot_singleton_list_2D(list::Union{Flowpipe{N},AbstractVector{RN}}) where {N,
RN<:AbstractReachSet{N}}
function _plot_singleton_list_2D(list::Union{Flowpipe{N},AbstractVector{<:AbstractReachSet{N}}}) where {N}
m = length(list)
x = Vector{N}(undef, m)
y = Vector{N}(undef, m)
Expand Down Expand Up @@ -256,10 +254,10 @@ end
# Flowpipe plot recipes
# ========================

@recipe function plot_list(list::Union{Flowpipe{N},AbstractVector{RN}};
@recipe function plot_list(list::Union{Flowpipe{N},AbstractVector{<:AbstractReachSet{N}}};
vars=nothing,
ε=N(PLOT_PRECISION),
=PLOT_POLAR_DIRECTIONS) where {N,RN<:AbstractReachSet{N}}
=PLOT_POLAR_DIRECTIONS) where {N}
_check_vars(vars)

label --> DEFAULT_LABEL
Expand All @@ -280,11 +278,10 @@ end
end

# composite flowpipes
@recipe function plot_list(fp::Union{HF,MF};
@recipe function plot_list(fp::Union{<:HybridFlowpipe{N},<:MixedFlowpipe{N}};
vars=nothing,
ε=Float64(PLOT_PRECISION),
=PLOT_POLAR_DIRECTIONS) where {N,HF<:HybridFlowpipe{N},
MF<:MixedFlowpipe{N}}
=PLOT_POLAR_DIRECTIONS) where {N}
_check_vars(vars)

label --> DEFAULT_LABEL
Expand Down Expand Up @@ -313,10 +310,10 @@ end
# Solution plot recipes
# ========================

@recipe function plot_list(sol::ReachSolution{FT};
@recipe function plot_list(sol::ReachSolution{<:Flowpipe{N}};
vars=nothing,
ε=Float64(PLOT_PRECISION),
=PLOT_POLAR_DIRECTIONS) where {N,FT<:Flowpipe{N}}
=PLOT_POLAR_DIRECTIONS) where {N}
_check_vars(vars)

label --> DEFAULT_LABEL
Expand All @@ -338,13 +335,11 @@ end
end

# compound solution flowpipes
@recipe function plot_list(sol::Union{SMF,SHF};
@recipe function plot_list(sol::Union{ReachSolution{<:MixedFlowpipe{N}},
ReachSolution{<:HybridFlowpipe{N}}};
vars=nothing,
ε=Float64(PLOT_PRECISION),
=PLOT_POLAR_DIRECTIONS) where {N,MF<:MixedFlowpipe{N},
HF<:HybridFlowpipe{N},
SMF<:ReachSolution{MF},
SHF<:ReachSolution{HF}}
=PLOT_POLAR_DIRECTIONS) where {N}
_check_vars(vars)

label --> DEFAULT_LABEL
Expand Down
8 changes: 4 additions & 4 deletions src/ReachSets/AbstractLazyReachSet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ associated with the given variables `vars`.
To project onto the time variable, use the index `0`. For instance, `(0, 1)` projects
onto the time variable and the first variable in `R`.
"""
function project(R::AbstractLazyReachSet, variables::NTuple{D,M};
check_vars::Bool=true) where {D,M<:Integer}
function project(R::AbstractLazyReachSet, variables::NTuple{D,Int};
check_vars::Bool=true) where {D}
vR = vars(R)
vRvec = collect(vR)

Expand Down Expand Up @@ -178,8 +178,8 @@ project(R::SubArray{<:AbstractLazyReachSet}; vars) = _project_vec(R, vars)
# Lazy projection of a reach-set
# -------------------------------

function Projection(R::AbstractLazyReachSet, variables::NTuple{D,M},
check_vars::Bool=true) where {D,M<:Integer}
function Projection(R::AbstractLazyReachSet, variables::NTuple{D,Int},
check_vars::Bool=true) where {D}
vR = vars(R)
vRvec = collect(vR)

Expand Down
6 changes: 3 additions & 3 deletions src/ReachSets/TaylorModelReachSet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ function reconstruct(R::TaylorModelReachSet, X)
end

# TODO remove but add comment in docs
function project(R::TaylorModelReachSet, vars::NTuple{D,M}) where {D,M<:Integer}
throw(ArgumentError("the concrete projection of Taylor model reach-set is not " *
"available; try first to overapproximate the Taylor model and the project"))
function project(::TaylorModelReachSet, ::NTuple{D,Int}) where {D}
throw(ArgumentError("the concrete projection of a Taylor model reach-set is not " *
"available; try to first overapproximate the Taylor model and then project"))
end

# constructor with a time point
Expand Down
2 changes: 0 additions & 2 deletions test/Aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import Aqua
@testset "Aqua tests" begin
# note that the check `persistent_tasks` may take several minutes
Aqua.test_all(ReachabilityAnalysis; ambiguities=false,
# the unbound args should be resolved in the future
unbound_args=(broken=true,),
# the piracies should be resolved in the future
piracies=(broken=true,))

Expand Down

0 comments on commit 7dec550

Please sign in to comment.