ENH: custom warning no motor or aerosurface#871
Conversation
Added a placeholder in the [Unreleased] section for the upcoming feature to add custom warnings when a rocket is missing motors and/or aero-surface. See RocketPy-Team#285.
This enhancement adds a warning when a Rocket object has no motors, parachutes, or AeroSurface components. It notifies the user so that they can add missing components before running simulations. See RocketPy-Team#285
Only warn if motor or aerodynamic surfaces are missing. Never raise a warning for no parachute. See RocketPy-Team#285
016acae to
1d75f80
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds unit tests for the new _check_missing_components() method in the Rocket class, which verifies whether a rocket has essential components (motor and aerodynamic surfaces) and issues warnings when components are missing.
- Adds
_check_missing_components()method to detect missing rocket components - Implements three unit tests covering all scenarios: all components missing, some missing, and none missing
- Updates CHANGELOG to document the enhancement
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| rocketpy/rocket/rocket.py | Adds _check_missing_components() method to warn users about missing motor or aerodynamic surfaces |
| tests/unit/rocket/test_rocket.py | Adds three unit tests to verify warning behavior for different component configurations |
| CHANGELOG.md | Documents the custom exception errors and messages enhancement |
|
@Bizo883 please address all the comments, fix tests and linters. You can let me know when the PR is ready for review again |
- Removed redundant len() check for aerodynamic_surfaces. - Added 'Returns: None' section to NumPy-style docstring. - Removed redundant '[WARNING]' prefix in warnings messages.
…r: exceptions must be derived from Warning, not <class 'NoneType'>
|
@Gui-FernandesBR The PR is ready for review again. Thank you! |
|
@Bizo883 can you please mark all the solved commets as 'resolved' please? |
Gui-FernandesBR
left a comment
There was a problem hiding this comment.
I will approve and merge this PR as soon as you fix linter issues
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #871 +/- ##
===========================================
+ Coverage 80.27% 80.29% +0.02%
===========================================
Files 104 104
Lines 12769 12777 +8
===========================================
+ Hits 10250 10259 +9
+ Misses 2519 2518 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
great implementation! It's time to merge it! |
Pull request type
Checklist
black rocketpy/ tests/) has passed locallypytest tests -m slow --runslow) have passed locallyCHANGELOG.mdhas been updated (if relevant)Current behavior
There is no test for the _check_missing_components().
New behavior
This PR adds unit tests to verify the warning behavior of the
_check_missing_components()method.Specifically, it includes three test cases:
These tests are defined in
tests/unit/test_rocket.py.Breaking change