Skip to content

Commit

Permalink
ENH: small fixes to the TimeNode() class
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Apr 16, 2024
1 parent cadcf10 commit 77be755
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -3685,14 +3685,38 @@ def flush_after(self, index):
del self.list[index + 1 :]

class TimeNode:
"""TimeNode is a class that represents a time node in the time
nodes list. It stores the time, the parachutes and the controllers
that are active at that time. This class is supposed to work
exclusively within the TimeNodes class.
"""

def __init__(self, t, parachutes, controllers):
"""Create a TimeNode object.
Parameters
----------
t : float
Initial time of the time node.
parachutes : list[Parachute]
List containing all the parachutes that should be evaluated
at this time node.
controllers : list[_Controller]
List containing all the controllers that should be evaluated
at this time node.
"""
self.t = t
self.parachutes = parachutes
self.callbacks = []
self._controllers = controllers

def __repr__(self):
return (
f"<TimeNode("
f"t: {self.t}, "
f"parachutes: {len(self.parachutes)}, "
f"controllers: {len(self._controllers)})>"
)

def __lt__(self, other):
"""Allows the comparison of two TimeNode objects based on their
Expand Down

0 comments on commit 77be755

Please sign in to comment.