-
-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ENH: Implement Multivariate Rejection Sampling (MRS) #738
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #738 +/- ##
===========================================
+ Coverage 79.11% 79.18% +0.06%
===========================================
Files 96 97 +1
Lines 11575 11798 +223
===========================================
+ Hits 9158 9342 +184
- Misses 2417 2456 +39 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR is ready for a first "Design Review." I would like to get your opinion if this implementation provides what you think on how the user should use the MRS. Albeit a implementation as a function seems natural, I implemented as a class because:
It currently works as follows:
I provided a quick and dirty notebook, which will be removed, just to show how the class is being used at the moment. |
766bd58
to
c45fabf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have much time so I'll be short
- The class dies after you sample the data once, this makes it pointless to have a class
- Instead I'd remove the sample dictionary from arguments.
- First read the data during initialization. Then you use a function to set the variables you are going to allow be varied. This way u can already anticipate which variables may be varied.
- We want almost instant results for a MonteCarlo simulation after using MRS.
- Other thing is that the user must supply the original pdf. Could we possile estimate this from data? (imagine 70k)
- Finally, plotting is crucial for MRS, or even tables. We'd love to see more on that later.
c45fabf
to
d3ab5f2
Compare
3a3c9e6
to
8ae8826
Compare
2931c30
to
7864590
Compare
8ae8826
to
d5e65a8
Compare
d5e65a8
to
36ea7f1
Compare
This PR is ready for review again. Changes from last time:
For review, I recommend mostly checking the .rst documentation. Here are some previews of the comparisons if you do not have the time to compile the html: |
A second comment: I made the design choice to implement the comparison methods in the
One option is, of course, to create another class for that job, but it did not seem to be the best option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Great implementation, @Lucas-Prates !
I would kindly recommend adding unit tests to some of the methods you've develop, just to make sure we cover some of the new code lines.
Also, please update the CHANGELOG file! |
I have addressed the suggestions made by @Gui-FernandesBR, implemented unit and integration tests for the MRS, and updated the CHANGELOG. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Lucas-Prates good work. Please squash and merge at your earliest convinience |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really good overall! Great job
rocketpy/plots/monte_carlo_plots.py
Outdated
plt.scatter( | ||
original_apogee_x, | ||
original_apogee_y, | ||
s=5, | ||
marker="^", | ||
color="green", | ||
label="Original Apogee", | ||
) | ||
plt.scatter( | ||
original_impact_x, | ||
original_impact_y, | ||
s=5, | ||
marker="v", | ||
color="blue", | ||
label="Original Landing Point", | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve colors of the points/ellipses. Using oposite colors is probably best
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no such thing as "opposite colors", but matplotlib does offer a fair good guide to selecting colormaps: https://matplotlib.org/stable/users/explain/colors/colormaps.html
I suggest blue/orange or blue/red.
Ideally the user should be able to select their specific color... But I understand the current limitations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will use then a "tetradic" color combination I found in this site. Here is the pallete I got, just for reference:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is ready again for review. Since last time: 1 - addressed the points in Stano's review about documentation and color; The most important point is 3 since it might introduce a breaking change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looking good to me, great implementation.
I don't see the changes to flatten_dict
as a problem.
Nobody is using that function right now.
Waiting for @MateusStano 's final comments so we can proceed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 14 out of 21 changed files in this pull request and generated 1 comment.
Files not reviewed (7)
- .vscode/settings.json: Language not supported
- docs/notebooks/monte_carlo_analysis/monte_carlo_analysis_outputs/mrs.outputs.txt: Language not supported
- docs/reference/classes/MultivariateRejectionSampler.rst: Language not supported
- docs/reference/index.rst: Language not supported
- docs/user/index.rst: Language not supported
- docs/user/mrs.rst: Language not supported
- docs/user/sensitivity.rst: Language not supported
Comments suppressed due to low confidence (1)
rocketpy/tools.py:595
- [nitpick] Consider renaming 'flatted_dict' to 'flattened_dict' for clarity and consistency with common terminology.
flatted_dict = {}
other_impact_x = np.array([]) | ||
other_impact_y = np.array([]) | ||
|
||
if len(original_apogee_x) == 0 and len(original_impact_x) == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(original_apogee_x) == 0 and len(original_impact_x) == 0: | |
if len(original_apogee_x) == 0 and len(original_impact_x) == 0: # pragma no cover |
if image is not None: | ||
try: | ||
img = imageio.imread(image) | ||
except FileNotFoundError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except FileNotFoundError as e: | |
except FileNotFoundError as e: # pragma no cover |
Pull request type
Checklist
black rocketpy/ tests/
) has passed locallypytest tests -m slow --runslow
) have passed locallyCHANGELOG.md
has been updated (if relevant)New behavior
This PR implements the MRS requested in #162 and described in RocketPy paper.
Breaking change
Additional information