Commit a8ac12bb authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[refactor] remove accept_zero_scale_parameter in gev_params.py

parent 8cc64c5b
No related merge requests found
Showing with 3 additions and 31 deletions
+3 -31
...@@ -20,11 +20,9 @@ class GevParams(AbstractExtremeParams): ...@@ -20,11 +20,9 @@ class GevParams(AbstractExtremeParams):
SUMMARY_NAMES = PARAM_NAMES + AbstractParams.QUANTILE_NAMES SUMMARY_NAMES = PARAM_NAMES + AbstractParams.QUANTILE_NAMES
NB_SUMMARY_NAMES = len(SUMMARY_NAMES) NB_SUMMARY_NAMES = len(SUMMARY_NAMES)
def __init__(self, loc: float, scale: float, shape: float, block_size: int = None, accept_zero_scale_parameter=False): def __init__(self, loc: float, scale: float, shape: float, block_size: int = None):
super().__init__(loc, scale, shape) super().__init__(loc, scale, shape)
self.block_size = block_size self.block_size = block_size
if accept_zero_scale_parameter and scale == 0.0:
self.has_undefined_parameters = False
self.param_name_to_confidence_interval = None self.param_name_to_confidence_interval = None
@nan_if_undefined_wrapper @nan_if_undefined_wrapper
......
...@@ -163,17 +163,10 @@ class AbstractGevTrendTest(object): ...@@ -163,17 +163,10 @@ class AbstractGevTrendTest(object):
def same_sign(a, b): def same_sign(a, b):
return (a > 0 and b > 0) or (a < 0 and b < 0) return (a > 0 and b > 0) or (a < 0 and b < 0)
@property
def mean_difference_same_sign_as_slope_strenght(self) -> bool:
return False
@property @property
def variance_difference_same_sign_as_slope_strenght(self) -> bool: def variance_difference_same_sign_as_slope_strenght(self) -> bool:
return False return False
def mean_difference(self, zeta0: float, mu1: float = 0.0, sigma1: float = 0.0) -> float:
return GevParams(loc=mu1, scale=sigma1, shape=zeta0, accept_zero_scale_parameter=True).mean
@property @property
def test_trend_constant_quantile(self): def test_trend_constant_quantile(self):
return self.unconstrained_estimator_gev_params_last_year.quantile(p=self.quantile_level) return self.unconstrained_estimator_gev_params_last_year.quantile(p=self.quantile_level)
......
...@@ -76,12 +76,6 @@ class GevLocationTrendTest(GevTrendTestOneParameterAgainstStationary): ...@@ -76,12 +76,6 @@ class GevLocationTrendTest(GevTrendTestOneParameterAgainstStationary):
return self.unconstrained_estimator_gev_params_last_year.time_derivative_of_return_level(p=self.quantile_level, return self.unconstrained_estimator_gev_params_last_year.time_derivative_of_return_level(p=self.quantile_level,
mu1=self.non_stationary_linear_coef) mu1=self.non_stationary_linear_coef)
@property
def mean_difference_same_sign_as_slope_strenght(self) -> bool:
zeta0 = self.unconstrained_estimator_gev_params_last_year.shape
mean_difference = self.mean_difference(zeta0=zeta0, mu1=self.non_stationary_linear_coef)
return self.same_sign(mean_difference, self._slope_strength())
@property @property
def variance_difference_same_sign_as_slope_strenght(self) -> bool: def variance_difference_same_sign_as_slope_strenght(self) -> bool:
return False return False
...@@ -104,12 +98,6 @@ class GevScaleTrendTest(GevTrendTestOneParameterAgainstStationary): ...@@ -104,12 +98,6 @@ class GevScaleTrendTest(GevTrendTestOneParameterAgainstStationary):
p=self.quantile_level, p=self.quantile_level,
sigma1=self.non_stationary_linear_coef) sigma1=self.non_stationary_linear_coef)
@property
def mean_difference_same_sign_as_slope_strenght(self) -> bool:
zeta0 = self.unconstrained_estimator_gev_params_last_year.shape
mean_difference = self.mean_difference(zeta0=zeta0, sigma1=self.non_stationary_linear_coef)
return self.same_sign(mean_difference, self._slope_strength())
@property @property
def variance_difference_same_sign_as_slope_strenght(self) -> bool: def variance_difference_same_sign_as_slope_strenght(self) -> bool:
sigma1 = self.non_stationary_linear_coef sigma1 = self.non_stationary_linear_coef
......
...@@ -91,13 +91,6 @@ class GevLocationAndScaleTrendTest(GevTrendTestTwoParametersAgainstGev): ...@@ -91,13 +91,6 @@ class GevLocationAndScaleTrendTest(GevTrendTestTwoParametersAgainstGev):
return self.unconstrained_estimator_gev_params_last_year.time_derivative_of_return_level(p=self.quantile_level, return self.unconstrained_estimator_gev_params_last_year.time_derivative_of_return_level(p=self.quantile_level,
mu1=self.mu1, mu1=self.mu1,
sigma1=self.sigma1) sigma1=self.sigma1)
@property
def mean_difference_same_sign_as_slope_strenght(self) -> bool:
zeta0 = self.unconstrained_estimator_gev_params_last_year.shape
mean_difference = self.mean_difference(zeta0=zeta0, mu1=self.mu1, sigma1=self.sigma1)
return self.same_sign(mean_difference, self._slope_strength())
@property @property
def variance_difference_same_sign_as_slope_strenght(self) -> bool: def variance_difference_same_sign_as_slope_strenght(self) -> bool:
return self.same_sign(self.sigma1, self._slope_strength()) return self.same_sign(self.sigma1, self._slope_strength())
......
...@@ -27,9 +27,9 @@ class TestGevParams(unittest.TestCase): ...@@ -27,9 +27,9 @@ class TestGevParams(unittest.TestCase):
def test_time_derivative_return_level(self): def test_time_derivative_return_level(self):
p = 0.99 p = 0.99
for mu1 in [-1, 0, 1]: for mu1 in [-1, 0, 1]:
for sigma1 in [0, 1, 10]: for sigma1 in [1, 10]:
for shape in [-1, 0, 1]: for shape in [-1, 0, 1]:
params = GevParams(loc=mu1, scale=sigma1, shape=shape, accept_zero_scale_parameter=True) params = GevParams(loc=mu1, scale=sigma1, shape=shape)
quantile = params.quantile(p) quantile = params.quantile(p)
time_derivative = params.time_derivative_of_return_level(p, mu1, sigma1) time_derivative = params.time_derivative_of_return_level(p, mu1, sigma1)
self.assertEqual(quantile, time_derivative) self.assertEqual(quantile, time_derivative)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment