From ac6f3b32d65887e77dedeeb57dc56b412195e548 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Tue, 28 Nov 2023 00:57:55 -0300 Subject: [PATCH 1/5] ENH: lowercase trigger comparison in parachute.py --- rocketpy/rocket/parachute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/rocket/parachute.py b/rocketpy/rocket/parachute.py index 07c44e158..18a90c83d 100644 --- a/rocketpy/rocket/parachute.py +++ b/rocketpy/rocket/parachute.py @@ -184,7 +184,7 @@ def triggerfunc(p, h, y): self.triggerfunc = triggerfunc - elif trigger == "apogee": + elif trigger.lower() == "apogee": # trigger for apogee def triggerfunc(p, h, y): # p = pressure considering parachute noise signal From 990df21752473a8dc45955dfeea4a9139478fc21 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Tue, 28 Nov 2023 01:07:03 -0300 Subject: [PATCH 2/5] MNT: Refactor Parachute trigger function handling --- rocketpy/rocket/parachute.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/rocketpy/rocket/parachute.py b/rocketpy/rocket/parachute.py index 18a90c83d..d50de92c4 100644 --- a/rocketpy/rocket/parachute.py +++ b/rocketpy/rocket/parachute.py @@ -171,11 +171,17 @@ def __init__( self.prints = _ParachutePrints(self) - # evaluate the trigger + self.__evaluate_trigger_function(trigger) + + def __evaluate_trigger_function(self, trigger): + """This is used to set the triggerfunc attribute that will be used to + interact with the Flight class. + """ if callable(trigger): self.triggerfunc = trigger + elif isinstance(trigger, (int, float)): - # trigger is interpreted as the absolute height at which the parachute will be ejected + # The parachute is deployed at a given height def triggerfunc(p, h, y): # p = pressure considering parachute noise signal # h = height above ground level considering parachute noise signal @@ -185,7 +191,7 @@ def triggerfunc(p, h, y): self.triggerfunc = triggerfunc elif trigger.lower() == "apogee": - # trigger for apogee + # The parachute is deployed at apogee def triggerfunc(p, h, y): # p = pressure considering parachute noise signal # h = height above ground level considering parachute noise signal @@ -194,7 +200,12 @@ def triggerfunc(p, h, y): self.triggerfunc = triggerfunc - return None + else: + raise ValueError( + f"Unable to set the trigger function for parachute '{self.name}'. " + + "Trigger must be a callable, a float value or the string 'apogee'. " + + "See the Parachute class documentation for mor information." + ) def __str__(self): """Returns a string representation of the Parachute class. From 83bcd02bca1790e4d4f9ca15ab938028d5e2df51 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Tue, 28 Nov 2023 01:09:30 -0300 Subject: [PATCH 3/5] MNT: update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 311189757..9bcb06322 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ straightforward as possible. ### Fixed -- +- ENH: Parachute trigger doesn't work if "Apogee" is used instead of "apogee" [#489](https://github.com/RocketPy-Team/RocketPy/pull/489) ## [v1.1.2] - 2023-11-25 From c1e43ece65f31c1811e37f48e52a6c353036d53d Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Tue, 28 Nov 2023 01:14:57 -0300 Subject: [PATCH 4/5] MNT: Fix typo in parachute trigger error message --- rocketpy/rocket/parachute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/rocket/parachute.py b/rocketpy/rocket/parachute.py index d50de92c4..0bfd9f9b9 100644 --- a/rocketpy/rocket/parachute.py +++ b/rocketpy/rocket/parachute.py @@ -204,7 +204,7 @@ def triggerfunc(p, h, y): raise ValueError( f"Unable to set the trigger function for parachute '{self.name}'. " + "Trigger must be a callable, a float value or the string 'apogee'. " - + "See the Parachute class documentation for mor information." + + "See the Parachute class documentation for more information." ) def __str__(self): From a6dfea37e51e52d846e2a84d6d0502641041d80a Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Thu, 30 Nov 2023 02:22:45 -0300 Subject: [PATCH 5/5] MNT: Fix typo in parachute trigger string --- rocketpy/rocket/parachute.py | 4 ++-- rocketpy/rocket/rocket.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rocketpy/rocket/parachute.py b/rocketpy/rocket/parachute.py index 0bfd9f9b9..3abd66ac2 100644 --- a/rocketpy/rocket/parachute.py +++ b/rocketpy/rocket/parachute.py @@ -38,7 +38,7 @@ class Parachute: case, the parachute will be ejected when the rocket reaches this height above ground level. - - The string "apogee," which triggers the parachute at apogee, i.e., + - The string "apogee" which triggers the parachute at apogee, i.e., when the rocket reaches its highest point and starts descending. Note: The function will be called according to the sampling rate @@ -126,7 +126,7 @@ def __init__( case, the parachute will be ejected when the rocket reaches this height above ground level. - - The string "apogee," which triggers the parachute at apogee, i.e., + - The string "apogee" which triggers the parachute at apogee, i.e., when the rocket reaches its highest point and starts descending. Note: The function will be called according to the sampling rate diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index 947c82acd..62f61d99b 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -1092,7 +1092,7 @@ def add_parachute( case, the parachute will be ejected when the rocket reaches this height above ground level. - - The string "apogee," which triggers the parachute at apogee, i.e., + - The string "apogee" which triggers the parachute at apogee, i.e., when the rocket reaches its highest point and starts descending. Note: The function will be called according to the sampling rate