-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Implement optional plot saving #597
ENH: Implement optional plot saving #597
Conversation
Hey, thank you so much for your draft PR @nalquas , it looks good already. I will take a look at it by the end of this week and see if I find any improvement opportunity. Nice job. |
61d241d
to
2840796
Compare
The PR is now ready for review. I did not modify the tests, though, and I am not sure about what needs to be done to get the docs updated. Looking forward to your feedback! |
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.
Absolutely amazing PR, we really appreciate your contribution. The fact all the tests are passing, including the slow tests, is already a good sign.
I have a few comments about it, we can discuss on top of them.
There are 2 other things I want/need to do before approving your PR: (1) build the documentation and verify it is working correctly, (2) test the getting started notebook one more time and verify the plots can be saved properly.
I understand your reason for not adding save options to the all_info
methods. Maybe we should wait until someone requests it as a new feature before we actually implement it.
I also would like to run code coverage on this PR, the workflow did not worked because the base branch is coming from a fork. I need to investigate it better. |
Btw @nalquas could you please run You could use this command: You can run |
7354f01
to
72b76d9
Compare
I have applied the suggestions, updated the docstrings, moved get_matplotlib_supported_file_endings into tools.py and run isort/black. I have also rebased the PR onto the current develop branch. Feel free to review again 🙂 |
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.
Great PR, @nalquas ! Overall, it is looking very good. The one issue that might be troublesome is saving the plots from the Function
class with non-default arguments. I believe it would require some non-trivial changes.
Co-authored-by: Gui-FernandesBR <[email protected]>
Co-authored-by: Lucas Prates <[email protected]>
…into nalquas-enh/save-graphs
Is there any remaining interest for this functionality from your side? There have been several hundred commits in your repo since then, so I would have to rebase and rewrite everything again. |
Actually @phmbressan has already rebased it but he mentioned he was not able to push to your branch since you are working on a fork. We had to move our development to other tasks. I guess if you could check if you can give him permission to ush to your branch, it would be really nice. We are totally interested in the feature, the problem is just that we prioritized other tasks in the past few months. |
Ah, that makes sense. I activated the "Allow edits by maintainers" checkbox now. |
b1f3f9f
to
e02c5a7
Compare
e02c5a7
to
dcde26a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #597 +/- ##
===========================================
+ Coverage 75.95% 76.08% +0.12%
===========================================
Files 99 95 -4
Lines 11237 10997 -240
===========================================
- Hits 8535 8367 -168
+ Misses 2702 2630 -72 ☔ View full report in Codecov by Sentry. |
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.
Partial review only. I'd like more time to test the feature during the weekend.
Nice job here, I think we are very close to merge this one.
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.
@phmbressan something I also missed is an example of usage. We could do something really simple, maybe by the end of the "first simulation" section.
Thanks for your comments @Gui-FernandesBR . I have added a |
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.
Really nice work, I believe rocketpy users will benefit a lot from this new feature!
Thank you, @nalquas @phmbressan !!
Pull request type
Checklist
black rocketpy/ tests/
) has passed locallypytest tests -m slow --runslow
) have passed locallyCHANGELOG.md
has been updated (if relevant)Current behavior
Currently, the draw functions responsible for most plots use matplotlib's
show
function. There is currently no (supported) way to automatically save the plots to disk. See #564New behavior
The functions generating plots now have a
filename
parameter, by defaultNone
. If the filename isNone
, the plot is shown as before using matplotlib'sshow
. If the filename is a file path string (e.g."/absolute/path/to/file.png"
or"relative/path/to/file.jpg"
), the plot is saved to the specified file. The file ending in the given filename decides which format the plot will be saved in, with matplotlib supporting: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.Breaking change
Additional information
I did not modify functions calling several plot-drawing functions, e.g. functions such as
all(...)
. The reason for this is that those are probably only used for manual testing/analysis, e.g. when using Jupyter Notebook. Users wanting automatic output probably prefer calling the individual plot functions directly as it allows for more fine-control. Additionally, this saves me from additional implementation effort 😅, and reduces complexity of this pull request. If this functionality is still wanted, this could be implemented in a future pull request.Also, I may have missed some plotting functions. If you spot anything obvious missing, feel free to notify me and I will look into it.
I look forward to any feedback during code review.
Fixes #564