Extract utility classes for better code organization while maintaining dynamic attribute copying#55
Extract utility classes for better code organization while maintaining dynamic attribute copying#55
Conversation
…ve duplication Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
…fety Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
… check Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
|
@copilot nonsense here def init(self, dataset, inps): |
Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
Fixed in commit a64d4d2. I've now refactored all remaining plotter classes (ProfilePlot, TimeseriesPlot, EarthquakePlot, VectorsPlot) to remove the dynamic attribute copying pattern and use explicit parameter extraction instead, making them consistent with VelocityPlot. All classes now use: self.line = getattr(inps, 'line', None)instead of the problematic |
Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
|
@copilot no the class shouldnt have been refactored. However the code is identical but now doesnt work. not copying inps to self |
…e dynamic attribute copying Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
Reverted in commit 9ed0392. ProfilePlot, TimeseriesPlot, EarthquakePlot, and VectorsPlot now retain their original implementation with dynamic attribute copying ( |
|
@copilot i don't know why you manually added self to the classes. Now everytime i add a new args to inps. I have to add it maunally to each object. That is pointless right? Plus even you forgot to add all the necessary inps to self so I don't get it why you did that. Its better to keep using def init(self, dataset, inps): |
…g for maintainability Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
…pattern Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
Reverted in commits c4ffeb1 and 3fa5527. All classes now use the dynamic attribute copying pattern (
The utility classes (ScalePlotter, DEMPlotter, AxisLimitsManager, source models) remain available for better code organization, but all classes automatically get all attributes from |
|
@copilot adjust the text position lon based on the min max coord values (check the +0.01) if self.volcano: |
Co-authored-by: disilvestro <142009043+disilvestro@users.noreply.github.com>
Fixed in commit 1aa535e. The volcano text position is now dynamically calculated based on the coordinate range. The offset is set to 1% of the longitude span ( |
Code Organization Improvements
Summary
Improved the PlotData codebase organization by extracting reusable utility classes while maintaining the existing dynamic attribute copying pattern for ease of maintenance and flexibility.
Changes Made ✅
plot_utilities.pywith ScalePlotter, DEMPlotter, AxisLimitsManagerdeformation_sources.pywith Mogi, Spheroid, Penny, Okada, SourcePlotterconfig.pywith ProcessingConfig and PlottingConfig dataclassesfor attr in dir(inps)patternfor attr in dir(inps)patternfor attr in dir(inps)patternfor attr in dir(inps)patternfor attr in dir(inps)patternfor attr in dir(process)patternpcolormeshfor proper geographic alignmentKey Improvements 🎯
Better Code Organization:
Maintainability:
for attr in dir(inps)inpsautomatically propagates to all classesCode Quality:
Classes Using Dynamic Attribute Copying
✅ VelocityPlot - uses
for attr in dir(inps), delegates to utility classes✅ ProfilePlot - uses
for attr in dir(inps)✅ TimeseriesPlot - uses
for attr in dir(inps)✅ EarthquakePlot - uses
for attr in dir(inps)✅ VectorsPlot - uses
for attr in dir(inps)✅ DataExtractor - uses
for attr in dir(process)Impact
✅ More maintainable - New arguments automatically available in all classes
✅ Better organized - Utility classes for common functionality
✅ More reusable - Extracted plotting utilities can be used independently
✅ More flexible - Dynamic attribute copying maintained for ease of extension
✅ Type-safe - Type hints in utility classes
✅ More secure - CodeQL passed
✅ Backward compatible - No breaking changes
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.