From f9f57a4d481b398824fcc81cc8e78777ca1b663d Mon Sep 17 00:00:00 2001 From: leogrosa Date: Tue, 18 Mar 2025 23:13:46 -0300 Subject: [PATCH 1/4] DOC: fixed a typo in funcify_method() description --- rocketpy/mathutils/function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/mathutils/function.py b/rocketpy/mathutils/function.py index 143912357..3e66d4f73 100644 --- a/rocketpy/mathutils/function.py +++ b/rocketpy/mathutils/function.py @@ -3492,7 +3492,7 @@ def funcify_method(*args, **kwargs): # pylint: disable=too-many-statements >>> example.f 'Function from R1 to R1 : (x) → (f(x))' - In order to reset the cache, just delete de attribute from the instance: + In order to reset the cache, just delete the attribute from the instance: >>> del example.f From 9b321817a1f1bb7137c22ad5855c15bf4759a2e6 Mon Sep 17 00:00:00 2001 From: leogrosa Date: Tue, 18 Mar 2025 23:28:34 -0300 Subject: [PATCH 2/4] TST: created test for get_instante_attributes() with flight without rail buttons --- tests/unit/test_utilities.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_utilities.py b/tests/unit/test_utilities.py index bbfebdf8f..91044624f 100644 --- a/tests/unit/test_utilities.py +++ b/tests/unit/test_utilities.py @@ -165,7 +165,7 @@ def test_flutter_plots(mock_show, flight_calisto_custom_wind): # pylint: disabl ), "An error occurred while running the utilities._flutter_plots function." -def test_get_instance_attributes(flight_calisto_robust): +def test_get_instance_attributes_with_robust_flight(flight_calisto_robust): """Tests if get_instance_attributes returns the expected results for a robust flight object.""" @@ -178,6 +178,19 @@ def test_get_instance_attributes(flight_calisto_robust): assert attr == value +def test_get_instance_attributes_with_flight_without_rail_buttons(flight_calisto): + """Tests if get_instance_attributes returns the expected results for a + flight object that contains a rocket object without rail buttons.""" + + attributes = utilities.get_instance_attributes(flight_calisto) + for key, value in attributes.items(): + attr = getattr(flight_calisto, key) + if isinstance(attr, np.ndarray): + assert np.allclose(attr, value) + else: + assert attr == value + + @pytest.mark.parametrize( "f, eps, expected", [ From cd56544d7d4446b43fa0e5b9a90177ce6f5555ef Mon Sep 17 00:00:00 2001 From: leogrosa Date: Tue, 18 Mar 2025 23:30:35 -0300 Subject: [PATCH 3/4] BUG: fixed __calculate_rail_button_forces() by assigning a Function(0) to null_force instead of an empty array --- rocketpy/simulation/flight.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 035323533..e2190bc40 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -2954,7 +2954,7 @@ def __calculate_rail_button_forces(self): # TODO: complex method. Rail Button 2 force in the 2 direction """ # First check for no rail phase or rail buttons - null_force = [] + null_force = Function(0) if self.out_of_rail_time_index == 0: # No rail phase, no rail button forces warnings.warn( "Trying to calculate rail button forces without a rail phase defined." From 228599ff0e50401bc17e337e57c221253b5eaf55 Mon Sep 17 00:00:00 2001 From: leogrosa Date: Fri, 21 Mar 2025 08:36:25 -0300 Subject: [PATCH 4/4] DEV: updates CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d8908c2..d218805c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Attention: The newest changes should be on top --> - BUG: do not allow drawing rockets with no aerodynamic surface [#774](https://github.com/RocketPy-Team/RocketPy/pull/774) - BUG: update flight simulation logic to include burn start time [#778](https://github.com/RocketPy-Team/RocketPy/pull/778) +- BUG: fixes get_instance_attributes for Flight objects containing a Rocket object without rail buttons [#786](https://github.com/RocketPy-Team/RocketPy/pull/786) ## [v1.8.0] - 2025-01-20