Skip to content

Commit 0eeac0d

Browse files
committed
BUG: correct encoding for trapezoidal sweep length and angle.
1 parent 973398c commit 0eeac0d

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

rocketpy/rocket/aero_surface/fins/trapezoidal_fins.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from rocketpy.plots.aero_surface_plots import _TrapezoidalFinsPlots
44
from rocketpy.prints.aero_surface_prints import _TrapezoidalFinsPrints
55

6+
from typing import Iterable
67
from .fins import Fins
78

89

@@ -351,12 +352,12 @@ def all_info(self):
351352
def to_dict(self, **kwargs):
352353
data = super().to_dict(**kwargs)
353354
data["tip_chord"] = self.tip_chord
354-
355+
data["sweep_length"] = self.sweep_length,
356+
data["sweep_angle"] = self.sweep_angle,
357+
355358
if kwargs.get("include_outputs", False):
356359
data.update(
357360
{
358-
"sweep_length": self.sweep_length,
359-
"sweep_angle": self.sweep_angle,
360361
"shape_vec": self.shape_vec,
361362
"Af": self.Af,
362363
"AR": self.AR,
@@ -373,6 +374,19 @@ def to_dict(self, **kwargs):
373374

374375
@classmethod
375376
def from_dict(cls, data):
377+
sweep_angle = None
378+
sweep_length = None
379+
380+
if data.get("sweep_angle") is None and data.get("sweep_length") is not None:
381+
sweep_length = data.get("sweep_length")
382+
if isinstance(sweep_length, Iterable) and sweep_length:
383+
sweep_length = sweep_length[0]
384+
385+
if sweep_length is None and data.get("sweep_angle") is not None:
386+
sweep_angle = data.get("sweep_angle")
387+
if isinstance(sweep_angle, Iterable) and sweep_angle:
388+
sweep_angle = sweep_angle[0]
389+
376390
return cls(
377391
n=data["n"],
378392
root_chord=data["root_chord"],
@@ -382,4 +396,6 @@ def from_dict(cls, data):
382396
cant_angle=data["cant_angle"],
383397
airfoil=data["airfoil"],
384398
name=data["name"],
399+
sweep_length=sweep_length,
400+
sweep_angle=sweep_angle,
385401
)

0 commit comments

Comments
 (0)