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,11 @@ 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
- @validate_call
83
82
def reduce_polygon_len (
84
83
polygon : Polygon ,
85
84
length : int ,
@@ -89,12 +88,15 @@ def reduce_polygon_len(
89
88
case ReductionMethod .CHARSHAPE :
90
89
return reduce_polygon_char (polygon , 0.0 , length ) # maximum length
91
90
case ReductionMethod .RDP :
92
- raise NotImplementedError
91
+ raise NotImplementedError ( "Fixed length is not implemented for RDP" )
93
92
case ReductionMethod .VW :
94
93
return reduce_polygon_vw (polygon , float ("inf" ), length ) # minimum length
94
+ case _:
95
+ raise ValueError (
96
+ f"Unknown reduction method. Must be one of { [e .value for e in ReductionMethod ]} "
97
+ )
95
98
96
99
97
- @validate_call
98
100
def reduce_polygon_auto (polygon : Polygon , method : ReductionMethod ) -> Polygon :
99
101
match method :
100
102
case ReductionMethod .CHARSHAPE :
0 commit comments