enhance resource anagement in Plotting Functions #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses resource consumption issues in the
plot_RTFsandplot_results_LCsfunctions by adding input data size restrictions and ensuring proper closure of Matplotlib figures to prevent memory leaks.Changes Made
Input Data Size Restriction:
plot_RTFsto limit the size ofP_allandP_freqsarrays to 10,000,000 elements.plot_results_LCsto limit the size offreqs,P_DEISM_LC, andP_DEISM_LC_matrixarrays to 10,000,000 elements.ValueErrorif arrays exceed the limit, preventing excessive memory usage.Optimized Plot Closure:
plot_RTFs, movedplt.close("all")outside theIF_SAVE_PLOTconditional blocks for both magnitude and phase plots to ensure figures are always closed.plot_results_LCs, addedplt.close("all")afterplt.show()for both magnitude and phase plots to prevent memory leaks.Motivation
These changes improve the robustness of the plotting functions by:
Additional Notes
Please review and provide feedback. Let me know if additional tests or changes are needed!