Enhance Plotting with Advanced Filtering and Customization#14
Open
appraneethreddy wants to merge 1 commit into
Open
Enhance Plotting with Advanced Filtering and Customization#14appraneethreddy wants to merge 1 commit into
appraneethreddy wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request significantly enhances the plot_profiling_stats function in the visualizer module, introducing advanced filtering, customization options, and key bug fixes to improve usability and flexibility. The example scripts and unit tests have been updated to reflect these new capabilities.
Key Changes:
1. Enhanced plot_profiling_stats Functionality (smartprofiler/visualizer.py )
Advanced Filtering & Customization:
Metric Threshold: A new metric_threshold parameter allows filtering out metrics below a specified value (e.g., {'execution_time': 0.1}).
Zero-Value Exclusion: The exclude_zero parameter can now be toggled to hide or show zero-value metrics, helping to de-clutter plots.
Logarithmic Scale: Added a use_log_scale option to switch the y-axis to a logarithmic scale, which is ideal for datasets with a wide range of values.
Custom Colors: Users can now pass a list of bar_colors to customize the plot's appearance.
Updated Example Script:
The script has been updated to demonstrate all new features, including filtering, logarithmic scale, and custom colors.
It now includes an example of aggregating statistics before plotting to handle functions with many calls (like recursive_fibonacci ), preventing overcrowded and unreadable charts.
Comprehensive Unit Tests ( tests/test_visualizer.py )
A full suite of unit tests has been added to validate all new functionality.
Tests cover default behavior, filtering, zero-exclusion, log scale, custom colors, and plot saving.
Mocking is used extensively to ensure tests run quickly and without requiring a GUI, making them suitable for CI/CD environments.