climpred icon indicating copy to clipboard operation
climpred copied to clipboard

Refactoring climpred to use classes under the hood

Open ahuang11 opened this issue 5 years ago • 6 comments

Many of the function signatures are the same; it might be good to use class inheritance to solve that.

Here's an outline:

Comparisons():
    __init__:
        forecasts
        references

Alignment(Comparisons):
    __init__:
        alignment

Scoring(Alignment):
    __init__:
        metrics
        comparisons
        dimensions

HindcastScoring(Scoring):
    function
        self.forecasts
        self.references
        self.alignment
        self.metrics
        self.comparisons
        self.dimensions

PersistenceScoring(Scoring):
    function
        self.forecasts
        self.references
        self.alignment
        self.metrics
        self.comparisons
        self.dimensions

UninitializedScoring(Scoring):
    function
        self.forecasts
        self.references
        self.alignment
        self.metrics
        self.comparisons
        self.dimensions

Bootstrap(Scoring):
    __init__:
        resample_dimemsion
        significance_level

PerfectModelBootstrap(Bootstrap):
    function
        self.forecasts
        self.references
        self.alignment
        self.metrics
        self.comparisons
        self.dimensions
        self.resample_dimension
        self.significance_level

HindcastBootstrap(Bootstrap):
    function
        self.forecasts
        self.references
        self.alignment
        self.metrics
        self.comparisons
        self.dimensions
        self.resample_dimension
        self.significance_level

Items under __init__ are the necessary keyword arguments to inherit from that class, items under function are inherited arguments. Feel free to question/comment/suggest!

ahuang11 avatar Mar 19 '20 03:03 ahuang11

I think it would helpful to talk about this over a video call. It looks really nice and organized but it'd help to hear you walk us through it! Are you free for something like that anytime soon?

bradyrx avatar Mar 19 '20 16:03 bradyrx

VerifyPerfectModel(Scoring)

VerifyHindcast(Scoring)

aaronspring avatar Mar 19 '20 16:03 aaronspring

I think these still go under HindcastEnsemble. Right @ahuang11? They would use these other classes from his outline.

VerifyPerfectModel(Scoring)

VerifyHindcast(Scoring)

bradyrx avatar Mar 19 '20 18:03 bradyrx

More here https://github.com/bradyrx/climpred_skeleton

aaronspring avatar Jun 09 '20 18:06 aaronspring

Still continuing on this front. We've prioritized getting the JOSS paper submitted with the current version. I'm also reviewing and patching ideas on xskillscore and climpred, which is pulling from my time on this problem. I'd say climpred_skeleton is about 2/3rds of the way there. Then the project of revamping this code is big. Will likely create a branch called e.g. classify_climpred and then do little edits to that as I build up the code base so it is easily reviewable.

bradyrx avatar Sep 05 '20 20:09 bradyrx

for discussion about API in with bootstrapping see #375

aaronspring avatar Sep 30 '20 15:09 aaronspring