Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Attention: The newest changes should be on top -->

### Added

- TST: Add branch coverage for fin_flutter_analysis and fix keyword argument bug [#904](https://github.com/RocketPy-Team/RocketPy/pull/815)
Comment thread
Gui-FernandesBR marked this conversation as resolved.
Outdated
- ENH: 3-dof lateral motion improvement [#883](https://github.com/RocketPy-Team/RocketPy/pull/883)
- ENH: Add multi-dimensional drag coefficient support (Cd as function of M, Re, α) [#875](https://github.com/RocketPy-Team/RocketPy/pull/875)
- ENH: Add save functionality to `_MonteCarloPlots.all` method [#848](https://github.com/RocketPy-Team/RocketPy/pull/848)
Expand All @@ -54,6 +55,7 @@ Attention: The newest changes should be on top -->

- BUG: Fix CSV column header spacing in FlightDataExporter [#864](https://github.com/RocketPy-Team/RocketPy/issues/864)
- BUG: Fix parallel Monte Carlo simulation showing incorrect iteration count [#806](https://github.com/RocketPy-Team/RocketPy/pull/806)
- BUG: Fixed keyword argument bug in `fin_flutter_analysis` where `filename` parameter was passed as positional argument to `_flutter_plots`, causing TypeError when saving plots [#904](https://github.com/RocketPy-Team/RocketPy/pull/904)
Comment thread
Gui-FernandesBR marked this conversation as resolved.
Outdated


## [v1.11.0] - 2025-11-01
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def fin_flutter_analysis(
flight,
)
if see_graphs:
_flutter_plots(flight, flutter_mach, safety_factor, filename)
_flutter_plots(flight, flutter_mach, safety_factor, filename=filename)
else:
return flutter_mach, safety_factor

Expand Down
70 changes: 70 additions & 0 deletions tests/unit/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,76 @@ def test_fin_flutter_analysis(flight_calisto_custom_wind):
assert np.isclose(safety_factor(np.inf), 61.669562809629035, atol=5e-3)


def test_fin_flutter_analysis_with_prints(flight_calisto_custom_wind):
"""Test fin_flutter_analysis with see_prints=True to cover print branch.

Parameters
----------
flight_calisto_custom_wind : Flight
A Flight object with a rocket with fins.
"""
flutter_mach, safety_factor = utilities.fin_flutter_analysis(
fin_thickness=2 / 1000,
shear_modulus=10e9,
flight=flight_calisto_custom_wind,
see_prints=True,
see_graphs=False, # False = returns tuple!
filename=None,
)

# Verify returns are valid
assert flutter_mach is not None
assert safety_factor is not None


@patch("matplotlib.pyplot.show")
def test_fin_flutter_analysis_with_graphs(mock_show, flight_calisto_custom_wind): # pylint: disable=unused-argument
"""Test fin_flutter_analysis with see_graphs=True to cover plotting branch.

Parameters
----------
mock_show : mock
Mock of matplotlib.pyplot.show function.
flight_calisto_custom_wind : Flight
A Flight object with a rocket with fins.
"""
result = utilities.fin_flutter_analysis(
fin_thickness=2 / 1000,
shear_modulus=10e9,
flight=flight_calisto_custom_wind,
see_prints=False,
see_graphs=True, # True = returns None!
filename=None,
)

assert result is None
mock_show.assert_called()


@patch("matplotlib.pyplot.show")
def test_fin_flutter_analysis_complete_output(mock_show, flight_calisto_custom_wind): # pylint: disable=unused-argument
"""Test fin_flutter_analysis with both prints and graphs enabled.

Parameters
----------
mock_show : mock
Mock of matplotlib.pyplot.show function.
flight_calisto_custom_wind : Flight
A Flight object with a rocket with fins.
"""
result = utilities.fin_flutter_analysis(
fin_thickness=2 / 1000,
shear_modulus=10e9,
flight=flight_calisto_custom_wind,
see_prints=True,
see_graphs=True, # True = returns None!
filename=None,
)

assert result is None
mock_show.assert_called()


def test_flutter_prints(flight_calisto_custom_wind):
"""Tests the _flutter_prints function.

Expand Down