Skip to content

Commit c6aacc3

Browse files
committed
refactor: replace pydantic validation
1 parent 458915a commit c6aacc3

File tree

3 files changed

+11
-137
lines changed

3 files changed

+11
-137
lines changed

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ authors = [
1616
{ name = "Jo Wayne Tan", email = "jo.tan17@imperial.ac.uk" },
1717
]
1818
dynamic = ["version"]
19-
dependencies = [
20-
"pydantic>=2.10.6",
21-
]
19+
dependencies = []
2220

2321
[dependency-groups]
2422
dev = [

python/polyshell/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from enum import Enum
22
from typing import Literal, overload
33

4-
from pydantic import validate_call
5-
64
from polyshell._polyshell import *
75

86
Polygon = list[tuple[float, float]]
@@ -66,7 +64,6 @@ def reduce_polygon(
6664
)
6765

6866

69-
@validate_call
7067
def reduce_polygon_eps(
7168
polygon: Polygon, epsilon: float, method: ReductionMethod
7269
) -> Polygon:
@@ -77,9 +74,12 @@ def reduce_polygon_eps(
7774
return reduce_polygon_rdp(polygon, epsilon)
7875
case ReductionMethod.VW:
7976
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+
)
8081

8182

82-
@validate_call
8383
def reduce_polygon_len(
8484
polygon: Polygon,
8585
length: int,
@@ -89,12 +89,15 @@ def reduce_polygon_len(
8989
case ReductionMethod.CHARSHAPE:
9090
return reduce_polygon_char(polygon, 0.0, length) # maximum length
9191
case ReductionMethod.RDP:
92-
raise NotImplementedError
92+
raise NotImplementedError("Fixed length is not implemented for RDP")
9393
case ReductionMethod.VW:
9494
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+
)
9599

96100

97-
@validate_call
98101
def reduce_polygon_auto(polygon: Polygon, method: ReductionMethod) -> Polygon:
99102
match method:
100103
case ReductionMethod.CHARSHAPE:

0 commit comments

Comments
 (0)