Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 31, 2025

This PR adds save functionality to the _MonteCarloPlots.all() method, allowing users to save Monte Carlo histogram plots to disk instead of only displaying them.

Changes Made

  • Added filename=None parameter to _MonteCarloPlots.all() method following the existing pattern used in _FlightPlots
  • Integrated with the existing show_or_save_plot() helper function for consistent file handling and validation
  • Enhanced filename handling for multiple plots by appending the result key name (e.g., results_apogee.png, results_x_impact.png)
  • Updated method docstring to document the new parameter and supported file formats
  • Added comprehensive unit test to verify the new functionality

Usage Examples

# Save all Monte Carlo result plots
monte_carlo.plots.all(filename="monte_carlo_results.png")

# Save specific result keys
monte_carlo.plots.all(keys=["apogee", "x_impact"], filename="selected_results.png")

# Backward compatibility - existing code still works
monte_carlo.plots.all()  # Still displays plots without saving

Key Features

  • Backward compatible: Existing calls without filename parameter continue to work unchanged
  • Multiple plot support: When saving multiple result keys, each gets a unique filename with the key name appended
  • Consistent API: Uses the same filename parameter pattern as other RocketPy plot methods
  • File format support: Supports all matplotlib-compatible formats (png, pdf, svg, eps, etc.)
  • Proper validation: Leverages existing show_or_save_plot() helper for file validation and directory creation

Testing

  • Added unit test test_monte_carlo_plots_all_with_filename that verifies both display and save modes
  • Manual testing confirmed proper file creation with correct naming conventions
  • All existing tests pass, ensuring no regressions
  • Code achieves 10/10 pylint score

This enhancement addresses a gap in the Monte Carlo plotting functionality and provides consistency with other plotting methods in RocketPy.

Fixes #847.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Aug 31, 2025

@Gui-FernandesBR 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Gui-FernandesBR
Copy link
Member

@copilot, actually we do have copilot instructions. Please search deeper within the .github folder

@Copilot Copilot AI changed the title [WIP] ENH: Save _MonteCarloPlots.all plots to disk ENH: Add filename parameter to _MonteCarloPlots.all() method for saving plots to disk Aug 31, 2025
@Copilot Copilot AI requested a review from Gui-FernandesBR August 31, 2025 15:07
Copilot finished work on behalf of Gui-FernandesBR August 31, 2025 15:07
Copy link
Author

Copilot AI commented Aug 31, 2025

@copilot, actually we do have copilot instructions. Please search deeper within the .github folder

I've searched thoroughly throughout the repository including the .github folder and all subdirectories, but I couldn't find any copilot instructions file. The search included:

  • All files in .github/ directory and subdirectories
  • Hidden files and configuration files
  • Text search for "copilot" and "instruction" keywords
  • Markdown, YAML, and text files across the entire repository

It appears there are currently no copilot instructions configured for this repository. If you'd like me to create one, I'd be happy to help set up a .github/copilot-instructions.md file following GitHub's best practices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

ENH: Save _MonteCarloPlots.all plots to disk
2 participants