From 85baef0b4957b69357227a47dae530599c10c1bf Mon Sep 17 00:00:00 2001 From: schillic Date: Fri, 20 Dec 2024 21:51:53 +0100 Subject: [PATCH] make 'tohrep' of 'VPolgyon' type stable --- src/Sets/VPolygon/VPolygonModule.jl | 5 +++-- src/Sets/VPolygon/tohrep.jl | 2 +- test/Sets/Polygon.jl | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Sets/VPolygon/VPolygonModule.jl b/src/Sets/VPolygon/VPolygonModule.jl index d31f48f3d7..6f5bb2d441 100644 --- a/src/Sets/VPolygon/VPolygonModule.jl +++ b/src/Sets/VPolygon/VPolygonModule.jl @@ -4,8 +4,9 @@ using Reexport, Requires using ..LazySets: AbstractPolygon, LazySet, AbstractHPolygon, halfspace_left, is_right_turn, _area_vlist, _extrema_vlist, _high_vlist, - _intersection_vrep_2d, _linear_map_vrep, _low_vlist, - _minkowski_sum_vrep_2d, _to_colVector + _infeasible_constraints_list, _intersection_vrep_2d, + _linear_map_vrep, _low_vlist, _minkowski_sum_vrep_2d, + _to_colVector using ..HPolygonModule: HPolygon using LinearAlgebra: dot using Random: AbstractRNG, GLOBAL_RNG, shuffle diff --git a/src/Sets/VPolygon/tohrep.jl b/src/Sets/VPolygon/tohrep.jl index 6125e6022c..9df5cd46af 100644 --- a/src/Sets/VPolygon/tohrep.jl +++ b/src/Sets/VPolygon/tohrep.jl @@ -24,7 +24,7 @@ function tohrep(P::VPolygon{N}, ::Type{HPOLYGON}=HPolygon) where {N,HPOLYGON<:Ab n = length(vl) if n == 0 # no vertex - return EmptySet{N}(2) + constraints_list = _infeasible_constraints_list(2; N=N) elseif n == 1 # only one vertex -> use function for singletons require(@__MODULE__, :LazySets; fun_name="convert") diff --git a/test/Sets/Polygon.jl b/test/Sets/Polygon.jl index 5997fdf302..82700b1dbd 100644 --- a/test/Sets/Polygon.jl +++ b/test/Sets/Polygon.jl @@ -460,7 +460,8 @@ for N in [Float64, Float32, Rational{Int}] end # empty VPolygon: conversion to hrep - @test tohrep(VPolygon{N}()) isa EmptySet{N} + P = tohrep(VPolygon{N}()) + @test P isa HPolygon{N} && isempty(P) # test VPolygon constructor given the matrix of vertices m = N[4 0; 6 2; 4 4]'