Skip to content

Commit

Permalink
MNT: Refactor code to use dictionary unpacking in stochastic_aero_sur…
Browse files Browse the repository at this point in the history
…faces.py and stochastic_parachute.py
  • Loading branch information
Gui-FernandesBR committed Mar 13, 2024
1 parent 7e30c76 commit d0b9711
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 54 deletions.
50 changes: 5 additions & 45 deletions rocketpy/stochastic/stochastic_aero_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,7 @@ def create_object(self):
NoseCone object with the randomly generated input arguments.
"""
generated_dict = next(self.dict_generator())
nosecone = NoseCone(
length=generated_dict["length"],
kind=generated_dict["kind"],
base_radius=generated_dict["base_radius"],
bluffness=generated_dict["bluffness"],
rocket_radius=generated_dict["rocket_radius"],
name=generated_dict["name"],
)
return nosecone
return NoseCone(**generated_dict)


class StochasticTrapezoidalFins(StochasticModel):
Expand Down Expand Up @@ -237,18 +229,7 @@ def create_object(self):
TrapezoidalFins object with the randomly generated input arguments.
"""
generated_dict = next(self.dict_generator())
fins = TrapezoidalFins(
n=generated_dict["n"],
root_chord=generated_dict["root_chord"],
tip_chord=generated_dict["tip_chord"],
span=generated_dict["span"],
rocket_radius=generated_dict["rocket_radius"],
cant_angle=generated_dict["cant_angle"],
sweep_length=generated_dict["sweep_length"],
airfoil=generated_dict["airfoil"],
name=generated_dict["name"],
)
return fins
return TrapezoidalFins(**generated_dict)


class StochasticEllipticalFins(StochasticModel):
Expand Down Expand Up @@ -347,16 +328,7 @@ def create_object(self):
EllipticalFins object with the randomly generated input arguments.
"""
generated_dict = next(self.dict_generator())
fins = EllipticalFins(
n=generated_dict["n"],
root_chord=generated_dict["root_chord"],
span=generated_dict["span"],
rocket_radius=generated_dict["rocket_radius"],
cant_angle=generated_dict["cant_angle"],
airfoil=generated_dict["airfoil"],
name=generated_dict["name"],
)
return fins
return EllipticalFins(**generated_dict)


class StochasticTail(StochasticModel):
Expand Down Expand Up @@ -439,14 +411,7 @@ def create_object(self):
Tail object with the randomly generated input arguments.
"""
generated_dict = next(self.dict_generator())
tail = Tail(
top_radius=generated_dict["top_radius"],
bottom_radius=generated_dict["bottom_radius"],
length=generated_dict["length"],
rocket_radius=generated_dict["rocket_radius"],
name=generated_dict["name"],
)
return tail
return Tail(**generated_dict)


class StochasticRailButtons(StochasticModel):
Expand Down Expand Up @@ -516,9 +481,4 @@ def create_object(self):
RailButtons object with the randomly generated input arguments.
"""
generated_dict = next(self.dict_generator())
rail_buttons = RailButtons(
buttons_distance=generated_dict["buttons_distance"],
angular_position=generated_dict["angular_position"],
name=generated_dict["name"],
)
return rail_buttons
return RailButtons(**generated_dict)
10 changes: 1 addition & 9 deletions rocketpy/stochastic/stochastic_parachute.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,4 @@ def create_object(self):
Parachute object with the randomly generated input arguments.
"""
generated_dict = next(self.dict_generator())
parachute = Parachute(
name=generated_dict["name"],
cd_s=generated_dict["cd_s"],
trigger=generated_dict["trigger"],
sampling_rate=generated_dict["sampling_rate"],
lag=generated_dict["lag"],
noise=generated_dict["noise"],
)
return parachute
return Parachute(**generated_dict)

0 comments on commit d0b9711

Please sign in to comment.