From eace9ee9f611845855f10db7c7b302d2de589fa8 Mon Sep 17 00:00:00 2001 From: GabrielBarberini Date: Sat, 14 Sep 2024 21:13:18 -0300 Subject: [PATCH] sets tip_chord as optional attr for Fins model; raises ValueError on unsupported fin kind --- lib/models/aerosurfaces.py | 3 ++- lib/services/rocket.py | 11 +---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/models/aerosurfaces.py b/lib/models/aerosurfaces.py index 14f0406..0d76565 100644 --- a/lib/models/aerosurfaces.py +++ b/lib/models/aerosurfaces.py @@ -1,4 +1,5 @@ from enum import Enum +from typing import Optional from pydantic import BaseModel @@ -28,7 +29,7 @@ class Fins(BaseModel): name: str n: int root_chord: float - tip_chord: float + tip_chord: Optional[float] span: float position: float cant_angle: float diff --git a/lib/services/rocket.py b/lib/services/rocket.py index a9e38fa..2b5842f 100644 --- a/lib/services/rocket.py +++ b/lib/services/rocket.py @@ -176,16 +176,7 @@ def get_rocketpy_finset(fins: Fins, kind: str) -> RocketPyFins: airfoil=fins.airfoil, ) case _: - rocketpy_finset = RocketPyTrapezoidalFins( - n=fins.n, - name=fins.name, - tip_chord=fins.tip_chord, - root_chord=fins.root_chord, - span=fins.span, - cant_angle=fins.cant_angle, - rocket_radius=fins.radius, - airfoil=fins.airfoil, - ) + raise ValueError(f"Invalid fins kind: {kind}") rocketpy_finset.position = fins.position return rocketpy_finset