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

Fix broken unit tests #680

Merged
merged 17 commits into from
Oct 1, 2018
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
2 changes: 1 addition & 1 deletion docs/src/lib/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Every `LazySet` type must define a function `σ` to compute the support vector.

```@docs
support_vector
ρ(::AbstractVector{Real}, ::LazySet{Real})
ρ(::AbstractVector{N}, ::LazySet{N}) where {N<:Real}
support_function
```

Expand Down
1 change: 1 addition & 0 deletions docs/src/lib/methods_fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ vertices_list
+
<=
σ
ρ
```
2 changes: 1 addition & 1 deletion src/AbstractPolytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract type AbstractPolytope{N<:Real} <: LazySet{N} end
"""
singleton_list(P::AbstractPolytope{N})::Vector{Singleton{N}} where {N<:Real}

Return the vertices of a polytopic as a list of singletons.
Return the vertices of a polytopic set as a list of singletons.

### Input

Expand Down
3 changes: 1 addition & 2 deletions src/VPolytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ in vertex representation.
"""
function tohrep(P::VPolytope{N};
backend=default_polyhedra_backend(N)) where {N}
P = polyhedron(P, backend)
return HPolytope(P)
return HPolytope(polyhedron(P, backend))
end

"""
Expand Down
2 changes: 1 addition & 1 deletion test/REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ IntervalArithmetic 0.14
MathProgBase 0.7
RecipesBase 0.3
Requires 0.4
Optim 0.14.1
Optim 0.14.1
9 changes: 6 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import LazySets.ispermutation

global test_suite_basic = true
global test_suite_doctests = VERSION >= v"0.7-" # only run doctests with new Julia version
global test_suite_polyhedra = false
global test_suite_plotting = false
global test_suite_polyhedra = VERSION < v"0.7-" # only run doctests with old Julia version (for now)
global test_suite_plotting = VERSION < v"0.7-" # only run doctests with old Julia version (for now)

if (length(ARGS) == 0) || (ARGS[1] == "--default")
# default test suite including doctests
Expand All @@ -35,7 +35,10 @@ else
error("unknown parameter 1: $(ARGS[1])")
end

if test_suite_polyhedra
if test_suite_polyhedra || test_suite_plotting
if VERSION < v"0.7-"
Pkg.add("Polyhedra"); Pkg.add("CDDLib"); Pkg.add("Optim"); Pkg.add("Plots")
end
using Polyhedra

# fix namespace conflicts with Polyhedra
Expand Down
23 changes: 12 additions & 11 deletions test/unit_Polytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ for N in [Float64, Rational{Int}, Float32]
# dim
@test dim(p) == 2

# support vector (only available with Polyhedra library)
d = N[1, 0]
@test_throws ErrorException σ(d, p, algorithm="xyz")
if test_suite_polyhedra
@test σ(d, p) == N[1.0, 0.0]
else
@test_throws AssertionError σ(d, p)
end

# vertices_list function
@test vertices_list(p) == p.vertices

Expand All @@ -105,7 +96,6 @@ if test_suite_polyhedra
# check isempty function of the AbstractPolytope interface
@test isempty(empty_H_polytope)
@test isempty(empty_V_polytope)
is_intersection_empty(empty_H_polytope, empty_V_polytope)
end

# Polyhedra tests that only work with Float64
Expand Down Expand Up @@ -143,7 +133,7 @@ if test_suite_polyhedra
b = N[1, 0]
p = HPolytope(A, b)
vl = vertices_list(p)
@test ispermutation(vl, N[0, 1])
@test ispermutation(vl, [N[0], N[1]])

# tovrep from HPolytope
A = [N(0) N(-1); N(-1) N(0); N(1) N(1)]
Expand All @@ -156,6 +146,17 @@ if test_suite_polyhedra
# V-rep
# -----

# support vector (only available with Polyhedra library)
polygon = VPolygon([N[0, 0], N[1, 0], N[0, 1]])
p = VPolytope(polygon)
d = N[1, 0]
@test_throws ErrorException σ(d, p, algorithm="xyz")
if test_suite_polyhedra
@test σ(d, p) == N[1, 0]
else
@test_throws AssertionError σ(d, p)
end

# intersection
p1 = VPolytope(vertices_list(BallInf(N[0, 0], N(1))))
p2 = VPolytope(vertices_list(BallInf(N[2, 2], N(1))))
Expand Down
2 changes: 1 addition & 1 deletion test/unit_plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ for N in [Float64, Rational{Int}, Float32]
plot(hpgo, ε)
plot(hpt, ε)
plot(vpg, ε)
@test_throws AssertionError plot(vpt, ε) # TODO see #574
plot(vpt, ε)
@test_throws AssertionError plot(es, ε) # TODO see #577
@test_throws ErrorException plot(hs, ε) # TODO see #576/#578
@test_throws ErrorException plot(hp, ε) # TODO see #576/#578
Expand Down