From d7dd0c851aba61426726fcb71081188242bda63f Mon Sep 17 00:00:00 2001
From: Le Roux Erwan <erwan.le-roux@irstea.fr>
Date: Thu, 19 Sep 2019 14:56:08 +0200
Subject: [PATCH] [TREND ANALYSIS] few refactoring of the code

---
 .../trend_analysis/univariate_test/abstract_trend_test.py | 7 +------
 .../univariate_test/abstract_univariate_test.py           | 8 +-------
 .../{ => univariate_test}/mann_kendall_test.py            | 0
 extreme_estimator/estimator/abstract_estimator.py         | 5 -----
 .../margin_estimator/abstract_margin_estimator.py         | 4 +++-
 5 files changed, 5 insertions(+), 19 deletions(-)
 rename experiment/trend_analysis/{ => univariate_test}/mann_kendall_test.py (100%)

diff --git a/experiment/trend_analysis/univariate_test/abstract_trend_test.py b/experiment/trend_analysis/univariate_test/abstract_trend_test.py
index 195d685f..9304b779 100644
--- a/experiment/trend_analysis/univariate_test/abstract_trend_test.py
+++ b/experiment/trend_analysis/univariate_test/abstract_trend_test.py
@@ -1,13 +1,8 @@
-import random
 import warnings
 
-import matplotlib.pyplot as plt
-from collections import OrderedDict
-
 import numpy as np
-from cached_property import cached_property
 
-from experiment.trend_analysis.mann_kendall_test import mann_kendall_test
+from experiment.trend_analysis.univariate_test.mann_kendall_test import mann_kendall_test
 from experiment.trend_analysis.abstract_score import MannKendall
 from experiment.trend_analysis.univariate_test.abstract_univariate_test import AbstractUnivariateTest
 
diff --git a/experiment/trend_analysis/univariate_test/abstract_univariate_test.py b/experiment/trend_analysis/univariate_test/abstract_univariate_test.py
index 1376adde..a039b9d9 100644
--- a/experiment/trend_analysis/univariate_test/abstract_univariate_test.py
+++ b/experiment/trend_analysis/univariate_test/abstract_univariate_test.py
@@ -1,16 +1,10 @@
 import random
-import warnings
-
-import matplotlib.pyplot as plt
 from collections import OrderedDict
 
-import numpy as np
+import matplotlib.pyplot as plt
 from cached_property import cached_property
 from matplotlib import colors
 
-from experiment.trend_analysis.mann_kendall_test import mann_kendall_test
-from experiment.trend_analysis.abstract_score import MannKendall
-
 
 class AbstractUnivariateTest(object):
     SIGNIFICATIVE = 'significative'
diff --git a/experiment/trend_analysis/mann_kendall_test.py b/experiment/trend_analysis/univariate_test/mann_kendall_test.py
similarity index 100%
rename from experiment/trend_analysis/mann_kendall_test.py
rename to experiment/trend_analysis/univariate_test/mann_kendall_test.py
diff --git a/extreme_estimator/estimator/abstract_estimator.py b/extreme_estimator/estimator/abstract_estimator.py
index 857fef72..73f453ea 100644
--- a/extreme_estimator/estimator/abstract_estimator.py
+++ b/extreme_estimator/estimator/abstract_estimator.py
@@ -58,11 +58,6 @@ class AbstractEstimator(object):
                                                    coef_dict=self.result_from_fit.margin_coef_dict,
                                                    starting_point=margin_model.starting_point)
 
-    # @property
-    # def max_stable_fitted(self) -> AbstractMarginFunction:
-    #     assert self._margin_function_fitted is not None, 'Error: estimator has not been fitted'
-    #     return self._margin_function_fitted
-
     @property
     def train_split(self):
         return self.dataset.train_split
diff --git a/extreme_estimator/estimator/margin_estimator/abstract_margin_estimator.py b/extreme_estimator/estimator/margin_estimator/abstract_margin_estimator.py
index 8a747fde..220d4b57 100644
--- a/extreme_estimator/estimator/margin_estimator/abstract_margin_estimator.py
+++ b/extreme_estimator/estimator/margin_estimator/abstract_margin_estimator.py
@@ -39,7 +39,9 @@ class LinearMarginEstimator(AbstractMarginEstimator):
 
     @property
     def margin_function_fitted(self) -> LinearMarginFunction:
-        return super().margin_function_fitted
+        margin_function_fitted = super().margin_function_fitted
+        assert isinstance(margin_function_fitted, LinearMarginFunction)
+        return margin_function_fitted
 
     def extract_function_fitted(self) -> LinearMarginFunction:
         return self.extract_function_fitted_from_the_model_shape(self.margin_model)
-- 
GitLab