1
1
from enum import Enum
2
2
from typing import Literal , overload
3
3
4
- from pydantic import validate_call
5
-
6
4
from polyshell ._polyshell import *
7
5
8
6
Polygon = list [tuple [float , float ]]
@@ -66,7 +64,6 @@ def reduce_polygon(
66
64
)
67
65
68
66
69
- @validate_call
70
67
def reduce_polygon_eps (
71
68
polygon : Polygon , epsilon : float , method : ReductionMethod
72
69
) -> Polygon :
@@ -77,9 +74,12 @@ def reduce_polygon_eps(
77
74
return reduce_polygon_rdp (polygon , epsilon )
78
75
case ReductionMethod .VW :
79
76
return reduce_polygon_vw (polygon , epsilon , 0 )
77
+ case _:
78
+ raise ValueError (
79
+ f"Unknown reduction method. Must be one of { [e .value for e in ReductionMethod ]} "
80
+ )
80
81
81
82
82
- @validate_call
83
83
def reduce_polygon_len (
84
84
polygon : Polygon ,
85
85
length : int ,
@@ -89,12 +89,15 @@ def reduce_polygon_len(
89
89
case ReductionMethod .CHARSHAPE :
90
90
return reduce_polygon_char (polygon , 0.0 , length ) # maximum length
91
91
case ReductionMethod .RDP :
92
- raise NotImplementedError
92
+ raise NotImplementedError ( "Fixed length is not implemented for RDP" )
93
93
case ReductionMethod .VW :
94
94
return reduce_polygon_vw (polygon , float ("inf" ), length ) # minimum length
95
+ case _:
96
+ raise ValueError (
97
+ f"Unknown reduction method. Must be one of { [e .value for e in ReductionMethod ]} "
98
+ )
95
99
96
100
97
- @validate_call
98
101
def reduce_polygon_auto (polygon : Polygon , method : ReductionMethod ) -> Polygon :
99
102
match method :
100
103
case ReductionMethod .CHARSHAPE :
0 commit comments