Skip to content

Encapsulate utility functions into CloudRemoval class for better code organization#2

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-2c38fbf0-7d5e-4915-9ba3-21842e693edd
Draft

Encapsulate utility functions into CloudRemoval class for better code organization#2
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-2c38fbf0-7d5e-4915-9ba3-21842e693edd

Conversation

Copy link
Copy Markdown

Copilot AI commented Aug 20, 2025

This PR refactors the cloud_removal.py module to improve code organization by moving standalone utility functions into the CloudRemoval class as static methods.

Problem

The original code had three utility functions defined as standalone functions outside the class:

  • set_seed(seed=4096) - for setting random seeds for reproducibility
  • thres_21(L, tau, M, N, B) - for threshold computation in the optimization algorithm
  • deal_real_data_for_gdd(Noisy) - for preprocessing data for the GDD network

This created a mixed code structure where cloud removal functionality was split between the CloudRemoval class and global utility functions, making the codebase less organized and harder to maintain.

Solution

Moved all three utility functions into the CloudRemoval class as static methods:

class CloudRemoval():
    # ... existing methods ...
    
    @staticmethod
    def set_seed(seed=4096):
        # ... implementation unchanged ...
    
    @staticmethod
    def thres_21(L, tau, M, N, B):
        # ... implementation unchanged ...
    
    @staticmethod
    def deal_real_data_for_gdd(Noisy):
        # ... implementation unchanged ...

Updated all internal function calls to use the class methods:

  • set_seed()CloudRemoval.set_seed()
  • thres_21(L, tau, M, N, B)CloudRemoval.thres_21(L, tau, M, N, B)

Benefits

  1. Complete encapsulation - All cloud removal functionality is now self-contained within the CloudRemoval class
  2. Cleaner namespace - No global utility functions cluttering the module scope
  3. Better organization - Clear logical grouping of related functionality
  4. Improved maintainability - Easier to understand relationships between functions
  5. Backward compatibility - No breaking changes to the public API; main.py continues to work unchanged

Testing

  • ✅ Syntax verification confirms the code compiles correctly
  • ✅ AST analysis confirms proper class structure with all methods properly encapsulated
  • ✅ No standalone functions remain outside the class
  • ✅ All function calls have been correctly updated to use class methods

The refactoring achieves the goal of making the cloud removal logic clearer and more organized while maintaining full backward compatibility.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…nization

Co-authored-by: try-agaaain <52828870+try-agaaain@users.noreply.github.com>
Copilot AI changed the title [WIP] 这个项目中,我希望将cloud_removal.py的功能封装为类,以便逻辑更加清晰 Encapsulate utility functions into CloudRemoval class for better code organization Aug 20, 2025
Copilot AI requested a review from try-agaaain August 20, 2025 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants