Skip to content

Commit

Permalink
Merge pull request #3727 from JuliaReach/schillic/interfaces
Browse files Browse the repository at this point in the history
Revise interface tests
  • Loading branch information
schillic authored Dec 30, 2024
2 parents 361690e + f13bd4e commit bb66e35
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
12 changes: 3 additions & 9 deletions src/Interfaces/AbstractCentrallySymmetricPolytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ Such a type combination is necessary as long as Julia does not support
### Notes
Every concrete `AbstractCentrallySymmetricPolytope` must define the following
methods:
- from `AbstractCentrallySymmetric`:
- `center(::AbstractCentrallySymmetricPolytope)` -- return the center point
- `center(::AbstractCentrallySymmetricPolytope, i::Int)` -- return the center
point at index `i`
- from `AbstractPolytope`:
- `vertices_list(::AbstractCentrallySymmetricPolytope)` -- return a list of
all vertices
method, in addition to the `AbstractPolytope` methods:
- `center(::AbstractCentrallySymmetricPolytope)` -- return the center point
The subtypes of `AbstractCentrallySymmetricPolytope` (including abstract
interfaces):
Expand Down
54 changes: 41 additions & 13 deletions test/Interfaces/interfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@

for T in (AbstractCentrallySymmetric, AbstractCentrallySymmetricPolytope)
# center
@test check_method_implementation(AbstractCentrallySymmetric, center,
@test check_method_implementation(T, center,
Function[S -> (S{Float64},)])
@test check_method_implementation(AbstractCentrallySymmetric, center,
Function[S -> (S{Float64}, Int64)])
end

# --- AbstractZonotope ---
Expand All @@ -44,22 +42,15 @@ end

# --- AbstractHyperrectangle ---

# radius_hyperrectangle (2x)
# radius_hyperrectangle
@test check_method_implementation(AbstractHyperrectangle, radius_hyperrectangle,
Function[S -> (S{Float64},)])
@test check_method_implementation(AbstractHyperrectangle, radius_hyperrectangle,
Function[S -> (S{Float64}, Int)])
# isflat
@test check_method_implementation(AbstractHyperrectangle, isflat,
Function[S -> (S{Float64},)])

# --- AbstractSingleton ---

# element (2x)
# element
@test check_method_implementation(AbstractSingleton, element,
Function[S -> (S{Float64},)])
@test check_method_implementation(AbstractSingleton, element,
Function[S -> (S{Float64}, Int)])

# --- AbstractPolygon ---

Expand All @@ -86,9 +77,46 @@ end
@test check_method_implementation(AbstractAffineMap, set,
Function[S -> (S{Float64},)])

# --- AbstractBallp ---

# ball_norm
@test check_method_implementation(AbstractBallp, LazySets.ball_norm,
Function[S -> (S{Float64},)])
# radius_ball
@test check_method_implementation(AbstractBallp, LazySets.radius_ball,
Function[S -> (S{Float64},)])

# --- AbstractArraySet ---

for T in Base.uniontypes(LazySets.AbstractArraySet)
# array
@test check_method_implementation(T, array,
Function[S -> (S{Float64},)])
end

# --- AbstractPolynomialZonotope ---

# center
@test check_method_implementation(AbstractPolynomialZonotope, center,
Function[S -> (S{Float64},)])
@test check_method_implementation(AbstractPolynomialZonotope, order,
# polynomial_order
@test check_method_implementation(AbstractPolynomialZonotope, polynomial_order,
Function[S -> (S{Float64},)])
# ngens_dep
@test check_method_implementation(AbstractPolynomialZonotope, ngens_dep,
Function[S -> (S{Float64},)])
# ngens_indep
@test check_method_implementation(AbstractPolynomialZonotope, ngens_indep,
Function[S -> (S{Float64},)])

# --- AbstractSparsePolynomialZonotope ---

# expmat
@test check_method_implementation(AbstractSparsePolynomialZonotope, expmat,
Function[S -> (S{Float64},)])
# genmat_dep
@test check_method_implementation(AbstractSparsePolynomialZonotope, genmat_dep,
Function[S -> (S{Float64},)])
# genmat_indep
@test check_method_implementation(AbstractSparsePolynomialZonotope, genmat_indep,
Function[S -> (S{Float64},)])

0 comments on commit bb66e35

Please sign in to comment.