Skip to content

Commit 1554551

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

File tree

3 files changed

+11
-138
lines changed

3 files changed

+11
-138
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 & 7 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,11 @@ 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

81-
82-
@validate_call
8382
def reduce_polygon_len(
8483
polygon: Polygon,
8584
length: int,
@@ -89,12 +88,15 @@ def reduce_polygon_len(
8988
case ReductionMethod.CHARSHAPE:
9089
return reduce_polygon_char(polygon, 0.0, length) # maximum length
9190
case ReductionMethod.RDP:
92-
raise NotImplementedError
91+
raise NotImplementedError("Fixed length is not implemented for RDP")
9392
case ReductionMethod.VW:
9493
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+
)
9598

9699

97-
@validate_call
98100
def reduce_polygon_auto(polygon: Polygon, method: ReductionMethod) -> Polygon:
99101
match method:
100102
case ReductionMethod.CHARSHAPE:

0 commit comments

Comments
 (0)