diff --git a/.codespell-ignore-words b/.codespell-ignore-words new file mode 100644 index 0000000..be48e98 --- /dev/null +++ b/.codespell-ignore-words @@ -0,0 +1 @@ +MOR diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 19303d5..49ef14d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -86,6 +86,7 @@ jobs: python-version: "3.12" - uses: pre-commit/action@v3.0.1 + build: name: "Build" needs: [ build-linux, pre-commit ] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c135076..0d001a9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,5 +60,6 @@ repos: rev: v2.3.0 hooks: - id: codespell + args: [ "--ignore-words=.codespell-ignore-words" ] additional_dependencies: - tomli diff --git a/pysatl_criterion/statistics/exponent.py b/pysatl_criterion/statistics/exponent.py index 4d91de3..d62b8f7 100644 --- a/pysatl_criterion/statistics/exponent.py +++ b/pysatl_criterion/statistics/exponent.py @@ -30,10 +30,16 @@ def code(): class EppsPulleyExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "EP" + @staticmethod @override def code(): - return f"EP_{AbstractExponentialityGofStatistic.code()}" + short_code = EppsPulleyExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -64,10 +70,16 @@ def __init__(self, alternative="two-sided", lam=1): self.alternative = alternative self.lam = lam + @staticmethod + @override + def short_code(): + return "KS" + @staticmethod @override def code(): - return f"KS_{AbstractExponentialityGofStatistic.code()}" + short_code = KolmogorovSmirnovExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -91,10 +103,16 @@ def execute_statistic(self, rvs, **kwargs): class AhsanullahExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "AHS" + @staticmethod @override def code(): - return f"AHS_{AbstractExponentialityGofStatistic.code()}" + short_code = AhsanullahExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -129,10 +147,16 @@ def execute_statistic(self, rvs, **kwargs): class AtkinsonExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "ATK" + @staticmethod @override def code(): - return f"ATK_{AbstractExponentialityGofStatistic.code()}" + short_code = AtkinsonExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, p=0.99): @@ -162,10 +186,16 @@ def execute_statistic(self, rvs, p=0.99): class CoxOakesExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "CO" + @staticmethod @override def code(): - return f"CO_{AbstractExponentialityGofStatistic.code()}" + short_code = CoxOakesExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -193,10 +223,16 @@ def execute_statistic(self, rvs, **kwargs): class CramerVonMisesExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "CVM" + @staticmethod @override def code(): - return f"CVM_{AbstractExponentialityGofStatistic.code()}" + short_code = CramerVonMisesExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -225,10 +261,16 @@ def execute_statistic(self, rvs, **kwargs): class DeshpandeExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "DSP" + @staticmethod @override def code(): - return f"DSP_{AbstractExponentialityGofStatistic.code()}" + short_code = DeshpandeExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, b=0.44): @@ -260,10 +302,16 @@ def execute_statistic(self, rvs, b=0.44): class EpsteinExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "EPS" + @staticmethod @override def code(): - return f"EPS_{AbstractExponentialityGofStatistic.code()}" + short_code = EpsteinExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -291,10 +339,16 @@ def execute_statistic(self, rvs, **kwargs): class FroziniExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "FZ" + @staticmethod @override def code(): - return f"FZ_{AbstractExponentialityGofStatistic.code()}" + short_code = FroziniExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -324,10 +378,16 @@ def execute_statistic(self, rvs, **kwargs): class GiniExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "GINI" + @staticmethod @override def code(): - return f"GINI_{AbstractExponentialityGofStatistic.code()}" + short_code = GiniExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -357,10 +417,16 @@ def execute_statistic(self, rvs, **kwargs): class GnedenkoExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "GD" + @staticmethod @override def code(): - return f"GD_{AbstractExponentialityGofStatistic.code()}" + short_code = GnedenkoExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, r=None): @@ -391,10 +457,16 @@ def execute_statistic(self, rvs, r=None): class HarrisExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "HM" + @staticmethod @override def code(): - return f"HM_{AbstractExponentialityGofStatistic.code()}" + short_code = HarrisExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, r=None): @@ -425,10 +497,16 @@ def execute_statistic(self, rvs, r=None): class HegazyGreen1ExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "HG1" + @staticmethod @override def code(): - return f"HG1_{AbstractExponentialityGofStatistic.code()}" + short_code = HegazyGreen1ExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -455,10 +533,16 @@ def execute_statistic(self, rvs, **kwargs): class HollanderProshanExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "HP" + @staticmethod @override def code(): - return f"HP_{AbstractExponentialityGofStatistic.code()}" + short_code = HollanderProshanExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -489,10 +573,16 @@ def execute_statistic(self, rvs, **kwargs): class KimberMichaelExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "KM" + @staticmethod @override def code(): - return f"KM_{AbstractExponentialityGofStatistic.code()}" + short_code = KimberMichaelExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -521,10 +611,16 @@ def execute_statistic(self, rvs, **kwargs): class KocharExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "KC" + @staticmethod @override def code(): - return f"KC_{AbstractExponentialityGofStatistic.code()}" + short_code = KocharExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -552,10 +648,16 @@ def execute_statistic(self, rvs, **kwargs): class LorenzExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "LZ" + @staticmethod @override def code(): - return f"LZ_{AbstractExponentialityGofStatistic.code()}" + short_code = LorenzExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, p=0.5): @@ -583,10 +685,16 @@ def execute_statistic(self, rvs, p=0.5): class MoranExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "MN" + @staticmethod @override def code(): - return f"MN_{AbstractExponentialityGofStatistic.code()}" + short_code = MoranExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -612,10 +720,16 @@ def execute_statistic(self, rvs, **kwargs): class PietraExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "PT" + @staticmethod @override def code(): - return f"PT_{AbstractExponentialityGofStatistic.code()}" + short_code = PietraExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -641,10 +755,16 @@ def execute_statistic(self, rvs, **kwargs): class ShapiroWilkExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "SW" + @staticmethod @override def code(): - return f"SW_{AbstractExponentialityGofStatistic.code()}" + short_code = ShapiroWilkExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -671,10 +791,16 @@ def execute_statistic(self, rvs, **kwargs): class RossbergExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "RS" + @staticmethod @override def code(): - return f"RS_{AbstractExponentialityGofStatistic.code()}" + short_code = RossbergExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -726,10 +852,16 @@ def execute_statistic(self, rvs, **kwargs): class WeExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "WE" + @staticmethod @override def code(): - return f"WE_{AbstractExponentialityGofStatistic.code()}" + short_code = WeExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -756,10 +888,16 @@ def execute_statistic(self, rvs, **kwargs): class WongWongExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "WW" + @staticmethod @override def code(): - return f"WW_{AbstractExponentialityGofStatistic.code()}" + short_code = WongWongExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -784,10 +922,16 @@ def execute_statistic(self, rvs, **kwargs): class HegazyGreen2ExponentialityGofStatistic(AbstractExponentialityGofStatistic): + @staticmethod + @override + def short_code(): + return "HG2" + @staticmethod @override def code(): - return f"HG2_{AbstractExponentialityGofStatistic.code()}" + short_code = HegazyGreen2ExponentialityGofStatistic.short_code() + return f"{short_code}_{AbstractExponentialityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -837,7 +981,8 @@ class GraphEdgesNumberExponentialityGofStatistic( @override def code(): parent_code = AbstractGraphExponentialityGofStatistic.code() - return f"{GraphEdgesNumberExponentialityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphEdgesNumberExponentialityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphMaxDegreeExponentialityGofStatistic( @@ -847,7 +992,8 @@ class GraphMaxDegreeExponentialityGofStatistic( @override def code(): parent_code = AbstractGraphExponentialityGofStatistic.code() - return f"{GraphMaxDegreeExponentialityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphMaxDegreeExponentialityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphAverageDegreeExponentialityGofStatistic( @@ -857,7 +1003,8 @@ class GraphAverageDegreeExponentialityGofStatistic( @override def code(): parent_code = AbstractGraphExponentialityGofStatistic.code() - return f"{GraphAverageDegreeExponentialityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphAverageDegreeExponentialityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphConnectedComponentsExponentialityGofStatistic( @@ -867,7 +1014,8 @@ class GraphConnectedComponentsExponentialityGofStatistic( @override def code(): parent_code = AbstractGraphExponentialityGofStatistic.code() - return f"{GraphConnectedComponentsExponentialityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphConnectedComponentsExponentialityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphCliqueNumberExponentialityGofStatistic( @@ -877,7 +1025,8 @@ class GraphCliqueNumberExponentialityGofStatistic( @override def code(): parent_code = AbstractGraphExponentialityGofStatistic.code() - return f"{GraphCliqueNumberExponentialityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphCliqueNumberExponentialityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphIndependenceNumberExponentialityGofStatistic( @@ -887,4 +1036,5 @@ class GraphIndependenceNumberExponentialityGofStatistic( @override def code(): parent_code = AbstractGraphExponentialityGofStatistic.code() - return f"{GraphIndependenceNumberExponentialityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphIndependenceNumberExponentialityGofStatistic.short_code() + return f"{short_code}_{parent_code}" diff --git a/pysatl_criterion/statistics/gamma.py b/pysatl_criterion/statistics/gamma.py index b481019..7e06047 100644 --- a/pysatl_criterion/statistics/gamma.py +++ b/pysatl_criterion/statistics/gamma.py @@ -67,10 +67,16 @@ def __init__( AbstractGammaGofStatistic.__init__(self, shape=shape, scale=scale) KSStatistic.__init__(self, alternative=alternative, mode=mode) + @staticmethod + @override + def short_code(): + return "KS" + @staticmethod @override def code(): - return f"KS_{AbstractGammaGofStatistic.code()}" + short_code = KolmogorovSmirnovGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -101,10 +107,16 @@ class LillieforsGammaGofStatistic(AbstractGammaGofStatistic, LillieforsTest): Statistical Association*, 62(318), 399–402. """ + @staticmethod + @override + def short_code(): + return "LILLIE" + @staticmethod @override def code(): - return f"LILLIE_{AbstractGammaGofStatistic.code()}" + short_code = LillieforsGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -150,10 +162,16 @@ class AndersonDarlingGammaGofStatistic(AbstractGammaGofStatistic, ADStatistic): *Annals of Mathematical Statistics*, 23(2), 193–212. """ + @staticmethod + @override + def short_code(): + return "AD" + @staticmethod @override def code(): - return f"AD_{AbstractGammaGofStatistic.code()}" + short_code = AndersonDarlingGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -186,10 +204,16 @@ class CramerVonMisesGammaGofStatistic(AbstractGammaGofStatistic, CrammerVonMises statistics and theoretical physics". Leipzig: F. Deuticke. """ + @staticmethod + @override + def short_code(): + return "CVM" + @staticmethod @override def code(): - return f"CVM_{AbstractGammaGofStatistic.code()}" + short_code = CramerVonMisesGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -219,10 +243,16 @@ class WatsonGammaGofStatistic(AbstractGammaGofStatistic): *Biometrika*, 48(1/2), 109–114. """ + @staticmethod + @override + def short_code(): + return "WAT" + @staticmethod @override def code(): - return f"WAT_{AbstractGammaGofStatistic.code()}" + short_code = WatsonGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -263,10 +293,16 @@ class KuiperGammaGofStatistic(AbstractGammaGofStatistic): Series A*, 63, 38–47. """ + @staticmethod + @override + def short_code(): + return "KUI" + @staticmethod @override def code(): - return f"KUI_{AbstractGammaGofStatistic.code()}" + short_code = KuiperGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -307,10 +343,16 @@ class GreenwoodGammaGofStatistic(AbstractGammaGofStatistic): *Journal of the Royal Statistical Society. Series A*, 109(1), 85–110. """ + @staticmethod + @override + def short_code(): + return "GRW" + @staticmethod @override def code(): - return f"GRW_{AbstractGammaGofStatistic.code()}" + short_code = GreenwoodGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -344,10 +386,16 @@ class MoranGammaGofStatistic(AbstractGammaGofStatistic): *Biometrika*, 37(1/2), 178–181. """ + @staticmethod + @override + def short_code(): + return "MOR" + @staticmethod @override def code(): - return f"MOR_{AbstractGammaGofStatistic.code()}" + short_code = MoranGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -387,10 +435,16 @@ class MinToshiyukiGammaGofStatistic(AbstractGammaGofStatistic, MinToshiyukiStati Computation*, 44(7), 1731–1749. """ + @staticmethod + @override + def short_code(): + return "MT" + @staticmethod @override def code(): - return f"MT_{AbstractGammaGofStatistic.code()}" + short_code = MinToshiyukiGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -459,10 +513,16 @@ class Chi2PearsonGammaGofStatistic(AbstractBinnedGammaGofStatistic): lambda_value = 1.0 + @staticmethod + @override + def short_code(): + return "CHI2_PEARSON" + @staticmethod @override def code(): - return f"CHI2_PEARSON_{AbstractGammaGofStatistic.code()}" + short_code = Chi2PearsonGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -487,10 +547,16 @@ class LikelihoodRatioGammaGofStatistic(AbstractBinnedGammaGofStatistic): lambda_value = 0.0 + @staticmethod + @override + def short_code(): + return "G_TEST" + @staticmethod @override def code(): - return f"G_TEST_{AbstractGammaGofStatistic.code()}" + short_code = LikelihoodRatioGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -523,10 +589,16 @@ def __init__( self.lambda_value = power super().__init__(bins=bins, shape=shape, scale=scale) + @staticmethod + @override + def short_code(): + return "CRESSIE_READ" + @staticmethod @override def code(): - return f"CRESSIE_READ_{AbstractGammaGofStatistic.code()}" + short_code = CressieReadGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -549,10 +621,16 @@ class ProbabilityPlotCorrelationGammaGofStatistic(AbstractGammaGofStatistic): coefficient test for normality". *Technometrics*, 17(1), 111–117. """ + @staticmethod + @override + def short_code(): + return "PPCC" + @staticmethod @override def code(): - return f"PPCC_{AbstractGammaGofStatistic.code()}" + short_code = ProbabilityPlotCorrelationGammaGofStatistic.short_code() + return f"{short_code}_{AbstractGammaGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -629,8 +707,8 @@ class GraphEdgesNumberGammaGofStatistic( @override def code(): parent_code = AbstractGraphGammaGofStatistic.code() - stat_name = GraphEdgesNumberGammaGofStatistic.get_stat_name() - return f"{stat_name}_{parent_code}" + short_code = GraphEdgesNumberGammaGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphMaxDegreeGammaGofStatistic(AbstractGraphGammaGofStatistic, GraphMaxDegreeTestStatistic): @@ -640,8 +718,8 @@ class GraphMaxDegreeGammaGofStatistic(AbstractGraphGammaGofStatistic, GraphMaxDe @override def code(): parent_code = AbstractGraphGammaGofStatistic.code() - stat_name = GraphMaxDegreeGammaGofStatistic.get_stat_name() - return f"{stat_name}_{parent_code}" + short_code = GraphMaxDegreeGammaGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphAverageDegreeGammaGofStatistic( @@ -653,8 +731,8 @@ class GraphAverageDegreeGammaGofStatistic( @override def code(): parent_code = AbstractGraphGammaGofStatistic.code() - stat_name = GraphAverageDegreeGammaGofStatistic.get_stat_name() - return f"{stat_name}_{parent_code}" + short_code = GraphAverageDegreeGammaGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphConnectedComponentsGammaGofStatistic( @@ -666,8 +744,8 @@ class GraphConnectedComponentsGammaGofStatistic( @override def code(): parent_code = AbstractGraphGammaGofStatistic.code() - stat_name = GraphConnectedComponentsGammaGofStatistic.get_stat_name() - return f"{stat_name}_{parent_code}" + short_code = GraphConnectedComponentsGammaGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphCliqueNumberGammaGofStatistic( @@ -679,8 +757,8 @@ class GraphCliqueNumberGammaGofStatistic( @override def code(): parent_code = AbstractGraphGammaGofStatistic.code() - stat_name = GraphCliqueNumberGammaGofStatistic.get_stat_name() - return f"{stat_name}_{parent_code}" + short_code = GraphCliqueNumberGammaGofStatistic.short_code() + return f"{short_code}_{parent_code}" def _evaluate_graph_statistic(self, transformed_sample, **kwargs): return GraphCliqueNumberTestStatistic.execute_statistic(self, transformed_sample, **kwargs) @@ -695,8 +773,8 @@ class GraphIndependenceNumberGammaGofStatistic( @override def code(): parent_code = AbstractGraphGammaGofStatistic.code() - stat_name = GraphIndependenceNumberGammaGofStatistic.get_stat_name() - return f"{stat_name}_{parent_code}" + short_code = GraphIndependenceNumberGammaGofStatistic.short_code() + return f"{short_code}_{parent_code}" def _evaluate_graph_statistic(self, transformed_sample, **kwargs): return GraphIndependenceNumberTestStatistic.execute_statistic( diff --git a/pysatl_criterion/statistics/graph_goodness_of_fit.py b/pysatl_criterion/statistics/graph_goodness_of_fit.py index c90c18b..ee2c3c3 100644 --- a/pysatl_criterion/statistics/graph_goodness_of_fit.py +++ b/pysatl_criterion/statistics/graph_goodness_of_fit.py @@ -16,10 +16,6 @@ def execute_statistic(self, rvs, **kwargs) -> float | float64: statistic = self.get_graph_stat(adjacency_list) return statistic - @staticmethod - def get_stat_name() -> str: - raise NotImplementedError("Method is not implemented") - @staticmethod def get_graph_stat(graph: list[list[int]]) -> float: raise NotImplementedError("Method is not implemented") @@ -50,7 +46,7 @@ def get_graph_stat(graph: list[list[int]]) -> float: @staticmethod @override - def get_stat_name() -> str: + def short_code() -> str: return "EDGESNUMBER" @@ -62,7 +58,7 @@ def get_graph_stat(graph: list[list[int]]) -> float: @staticmethod @override - def get_stat_name() -> str: + def short_code() -> str: return "MAXDEGREE" @@ -75,7 +71,7 @@ def get_graph_stat(graph: list[list[int]]) -> float: @staticmethod @override - def get_stat_name() -> str: + def short_code() -> str: return "AVGDEGREE" @@ -102,7 +98,7 @@ def dfs(node): @staticmethod @override - def get_stat_name() -> str: + def short_code() -> str: return "CONNECTEDCOMPONENTS" @@ -125,7 +121,7 @@ def execute_statistic(self, rvs, **kwargs) -> float | float64: @staticmethod @override - def get_stat_name() -> str: + def short_code() -> str: return "CLIQUENUMBER" @@ -151,5 +147,5 @@ def execute_statistic(self, rvs, **kwargs) -> float | float64: @staticmethod @override - def get_stat_name() -> str: + def short_code() -> str: return "INDEPENDENCENUMBER" diff --git a/pysatl_criterion/statistics/models.py b/pysatl_criterion/statistics/models.py index b61828d..180afad 100644 --- a/pysatl_criterion/statistics/models.py +++ b/pysatl_criterion/statistics/models.py @@ -46,6 +46,14 @@ def code() -> str: """ raise NotImplementedError("Method is not implemented") + @staticmethod + @abstractmethod + def short_code(): + """ + Generate non-unique short code for test statistic. + """ + raise NotImplementedError("Method is not implemented") + @abstractmethod def execute_statistic(self, rvs, **kwargs) -> float | float64: """ diff --git a/pysatl_criterion/statistics/normal.py b/pysatl_criterion/statistics/normal.py index 4cd7d7f..e21f6c8 100644 --- a/pysatl_criterion/statistics/normal.py +++ b/pysatl_criterion/statistics/normal.py @@ -40,10 +40,16 @@ def __init__(self, alternative="two-sided", mode="auto", mean=0, var=1): self.mean = mean self.var = var + @staticmethod + @override + def short_code(): + return "KS" + @staticmethod @override def code(): - return f"KS_{AbstractNormalityGofStatistic.code()}" + short_code = KolmogorovSmirnovNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -75,10 +81,16 @@ def execute_statistic(self, rvs, **kwargs): class AndersonDarlingNormalityGofStatistic(AbstractNormalityGofStatistic, ADStatistic): + @staticmethod + @override + def short_code(): + return "AD" + @staticmethod @override def code(): - return f"AD_{AbstractNormalityGofStatistic.code()}" + short_code = AndersonDarlingNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -100,10 +112,16 @@ def calculate_critical_value(self, rvs_size, sl, count=500_000): # TODO: check class ShapiroWilkNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "SW" + @staticmethod @override def code(): - return f"SW_{AbstractNormalityGofStatistic.code()}" + short_code = ShapiroWilkNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -157,12 +175,17 @@ def ordered_statistic(n): class CramerVonMiseNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "CVM" + @staticmethod @override def code(): - return ( - "CVM" + "_" + super(AbstractNormalityGofStatistic, AbstractNormalityGofStatistic).code() - ) + short_code = CramerVonMiseNormalityGofStatistic.short_code() + base_code = super(AbstractNormalityGofStatistic, AbstractNormalityGofStatistic).code() + return f"{short_code}_{base_code}" @override def execute_statistic(self, rvs, **kwargs): @@ -178,10 +201,16 @@ def execute_statistic(self, rvs, **kwargs): class LillieforsNormalityGofStatistic(AbstractNormalityGofStatistic, LillieforsTest): + @staticmethod + @override + def short_code(): + return "LILLIE" + @staticmethod @override def code(): - return f"LILLIE_{AbstractNormalityGofStatistic.code()}" + short_code = LillieforsNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -217,10 +246,16 @@ def execute_statistic(self, rvs, **kwargs): class JBNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "JB" + @staticmethod @override def code(): - return f"JB_{AbstractNormalityGofStatistic.code()}" + short_code = JBNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -241,10 +276,16 @@ def execute_statistic(self, rvs, **kwargs): class SkewNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "SKEW" + @staticmethod @override def code(): - return f"SKEW_{AbstractNormalityGofStatistic.code()}" + short_code = SkewNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -279,10 +320,16 @@ def skew_test(a): class KurtosisNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "KURTOSIS" + @staticmethod @override def code(): - return f"KURTOSIS_{AbstractNormalityGofStatistic.code()}" + short_code = KurtosisNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -334,10 +381,16 @@ def kurtosis_test(a): class DAPNormalityGofStatistic(SkewNormalityGofStatistic, KurtosisNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "DAP" + @staticmethod @override def code(): - return f"DAP_{AbstractNormalityGofStatistic.code()}" + short_code = DAPNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -352,10 +405,16 @@ def execute_statistic(self, rvs, **kwargs): # https://github.com/puzzle-in-a-mug/normtest class FilliNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "FILLI" + @staticmethod @override def code(): - return f"FILLI_{AbstractNormalityGofStatistic.code()}" + short_code = FilliNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -387,10 +446,16 @@ def _statistic(x_data, zi): # https://github.com/puzzle-in-a-mug/normtest class LooneyGulledgeNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "LG" + @staticmethod @override def code(): - return f"LG_{AbstractNormalityGofStatistic.code()}" + short_code = LooneyGulledgeNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -448,10 +513,16 @@ def __init__(self, weighted=False, cte_alpha="3/8"): self.weighted = weighted self.cte_alpha = cte_alpha + @staticmethod + @override + def short_code(): + return "RJ" + @staticmethod @override def code(): - return f"RJ_{AbstractNormalityGofStatistic.code()}" + short_code = RyanJoinerNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -509,10 +580,16 @@ def _order_statistic(sample_size, cte_alpha="3/8"): class SFNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "SF" + @staticmethod @override def code(): - return f"SF_{AbstractNormalityGofStatistic.code()}" + short_code = SFNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -530,10 +607,16 @@ def execute_statistic(self, rvs, **kwargs): # https://habr.com/ru/articles/685582/ class EppsPulleyNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "EP" + @staticmethod @override def code(): - return f"EP_{AbstractNormalityGofStatistic.code()}" + short_code = EppsPulleyNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -552,10 +635,16 @@ def execute_statistic(self, rvs, **kwargs): class Hosking2NormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "HOSKING2" + @staticmethod @override def code(): - return f"HOSKING2_{AbstractNormalityGofStatistic.code()}" + short_code = Hosking2NormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -605,10 +694,16 @@ def pstarmod1(r, n, i): class Hosking1NormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "HOSKING1" + @staticmethod @override def code(): - return f"HOSKING1_{AbstractNormalityGofStatistic.code()}" + short_code = Hosking1NormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -656,10 +751,16 @@ def stat10(x): class Hosking3NormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "HOSKING3" + @staticmethod @override def code(): - return f"HOSKING3_{AbstractNormalityGofStatistic.code()}" + short_code = Hosking3NormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -714,10 +815,16 @@ def pstarmod2(r, n, i): class Hosking4NormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "HOSKING4" + @staticmethod @override def code(): - return f"HOSKING4_{AbstractNormalityGofStatistic.code()}" + short_code = Hosking4NormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -772,10 +879,16 @@ def pstarmod3(r, n, i): class ZhangWuCNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "ZWC" + @staticmethod @override def code(): - return f"ZWC_{AbstractNormalityGofStatistic.code()}" + short_code = ZhangWuCNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -796,10 +909,16 @@ def execute_statistic(self, rvs, **kwargs): class ZhangWuANormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "ZWA" + @staticmethod @override def code(): - return f"ZWA_{AbstractNormalityGofStatistic.code()}" + short_code = ZhangWuANormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -824,10 +943,16 @@ def execute_statistic(self, rvs, **kwargs): class GlenLeemisBarrNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "GLB" + @staticmethod @override def code(): - return f"GLB_{AbstractNormalityGofStatistic.code()}" + short_code = GlenLeemisBarrNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -853,10 +978,16 @@ def execute_statistic(self, rvs, **kwargs): class DoornikHansenNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "DH" + @staticmethod @override def code(): - return f"DH_{AbstractNormalityGofStatistic.code()}" + short_code = DoornikHansenNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -907,10 +1038,16 @@ def kurtosis_to_z2(skew, kurt, n): class RobustJarqueBeraNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "RJB" + @staticmethod @override def code(): - return f"RJB_{AbstractNormalityGofStatistic.code()}" + short_code = RobustJarqueBeraNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -926,10 +1063,16 @@ def execute_statistic(self, rvs, **kwargs): class BontempsMeddahi1NormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "BM1" + @staticmethod @override def code(): - return f"BM1_{AbstractNormalityGofStatistic.code()}" + short_code = BontempsMeddahi1NormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -963,10 +1106,16 @@ def execute_statistic(self, rvs, **kwargs): class BontempsMeddahi2NormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "BM2" + @staticmethod @override def code(): - return f"BM2_{AbstractNormalityGofStatistic.code()}" + short_code = BontempsMeddahi2NormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -992,10 +1141,16 @@ def stat15(x): class BonettSeierNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "BS" + @staticmethod @override def code(): - return f"BS_{AbstractNormalityGofStatistic.code()}" + short_code = BonettSeierNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1027,10 +1182,16 @@ def stat17(x): class MartinezIglewiczNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "MI" + @staticmethod @override def code(): - return f"MI_{AbstractNormalityGofStatistic.code()}" + short_code = MartinezIglewiczNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1068,10 +1229,16 @@ def stat32(x): class CabanaCabana1NormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "CC1" + @staticmethod @override def code(): - return f"CC1_{AbstractNormalityGofStatistic.code()}" + short_code = CabanaCabana1NormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1114,10 +1281,16 @@ def stat19(x): class CabanaCabana2NormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "CC2" + @staticmethod @override def code(): - return f"CC2_{AbstractNormalityGofStatistic.code()}" + short_code = CabanaCabana2NormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1213,10 +1386,16 @@ def stat20(x): class ChenShapiroNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "CS" + @staticmethod @override def code(): - return f"CS_{AbstractNormalityGofStatistic.code()}" + short_code = ChenShapiroNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1237,10 +1416,16 @@ def stat26(x): class ZhangQNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "ZQ" + @staticmethod @override def code(): - return f"ZQ_{AbstractNormalityGofStatistic.code()}" + short_code = ZhangQNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1277,10 +1462,16 @@ def stat27(x): class CoinNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "COIN" + @staticmethod @override def code(): - return f"COIN_{AbstractNormalityGofStatistic.code()}" + short_code = CoinNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1406,10 +1597,16 @@ def nscor2(self, s, n, n2): class DagostinoNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "D" + @staticmethod @override def code(): - return f"D_{AbstractNormalityGofStatistic.code()}" + short_code = DagostinoNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1426,10 +1623,16 @@ def execute_statistic(self, rvs, **kwargs): class ZhangQStarNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "ZQS" + @staticmethod @override def code(): - return f"ZQS_{AbstractNormalityGofStatistic.code()}" + short_code = ZhangQStarNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1513,10 +1716,16 @@ def stat34(x): class SWRGNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "SWRG" + @staticmethod @override def code(): - return f"SWRG_{AbstractNormalityGofStatistic.code()}" + short_code = SWRGNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1543,10 +1752,16 @@ def execute_statistic(self, rvs, **kwargs): class GMGNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "GMG" + @staticmethod @override def code(): - return f"GMG_{AbstractNormalityGofStatistic.code()}" + short_code = GMGNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1604,10 +1819,16 @@ def stat33(x): class BHSNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "BHS" + @staticmethod @override def code(): - return f"BHS_{AbstractNormalityGofStatistic.code()}" + short_code = BHSNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1629,9 +1850,7 @@ def stat16(self, x): eps = [2.220446e-16, 2.225074e-308] iter_ = [1000, 0] - print("ssss") w1 = self.mc_c_d(x, eps, iter_) - print("ssss1") w2 = self.mc_c_d(x1, eps, iter_) w3 = self.mc_c_d(x2, eps, iter_) @@ -1939,10 +2158,16 @@ def whi_med_i(a, w, n, a_cand, a_srt, w_cand): class SpiegelhalterNormalityGofStatistic(AbstractNormalityGofStatistic): + @staticmethod + @override + def short_code(): + return "SH" + @staticmethod @override def code(): - return f"SH_{AbstractNormalityGofStatistic.code()}" + short_code = SpiegelhalterNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1988,8 +2213,15 @@ def stat41(x): class DesgagneLafayeNormalityGofStatistic(AbstractNormalityGofStatistic): @staticmethod + @override + def short_code(): + return "DLDMZEPD" + + @staticmethod + @override def code(): - return f"DLDMZEPD_{AbstractNormalityGofStatistic.code()}" + short_code = DesgagneLafayeNormalityGofStatistic.short_code() + return f"{short_code}_{AbstractNormalityGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -2034,7 +2266,9 @@ def stat35(x): return rn # Here is the test statistic value -class AbstractGraphNormalityGofStatistic(AbstractNormalityGofStatistic, AbstractGraphTestStatistic): +class AbstractGraphNormalityGofStatistic( + AbstractNormalityGofStatistic, AbstractGraphTestStatistic, ABC +): @staticmethod @override def code(): @@ -2056,7 +2290,8 @@ class GraphEdgesNumberNormalityGofStatistic( @override def code(): parent_code = AbstractGraphNormalityGofStatistic.code() - return f"{GraphEdgesNumberNormalityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphEdgesNumberNormalityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphMaxDegreeNormalityGofStatistic( @@ -2066,7 +2301,8 @@ class GraphMaxDegreeNormalityGofStatistic( @override def code(): parent_code = AbstractGraphNormalityGofStatistic.code() - return f"{GraphMaxDegreeNormalityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphMaxDegreeNormalityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphAverageDegreeNormalityGofStatistic( @@ -2076,7 +2312,8 @@ class GraphAverageDegreeNormalityGofStatistic( @override def code(): parent_code = AbstractGraphNormalityGofStatistic.code() - return f"{GraphAverageDegreeNormalityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphAverageDegreeNormalityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphConnectedComponentsNormalityGofStatistic( @@ -2086,7 +2323,8 @@ class GraphConnectedComponentsNormalityGofStatistic( @override def code(): parent_code = AbstractGraphNormalityGofStatistic.code() - return f"{GraphConnectedComponentsNormalityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphConnectedComponentsNormalityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphCliqueNumberNormalityGofStatistic( @@ -2096,7 +2334,8 @@ class GraphCliqueNumberNormalityGofStatistic( @override def code(): parent_code = AbstractGraphNormalityGofStatistic.code() - return f"{GraphCliqueNumberNormalityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphCliqueNumberNormalityGofStatistic.short_code() + return f"{short_code}_{parent_code}" class GraphIndependenceNumberNormalityGofStatistic( @@ -2106,4 +2345,5 @@ class GraphIndependenceNumberNormalityGofStatistic( @override def code(): parent_code = AbstractGraphNormalityGofStatistic.code() - return f"{GraphIndependenceNumberNormalityGofStatistic.get_stat_name()}_{parent_code}" + short_code = GraphIndependenceNumberNormalityGofStatistic.short_code() + return f"{short_code}_{parent_code}" diff --git a/pysatl_criterion/statistics/student.py b/pysatl_criterion/statistics/student.py index 6a23c46..1d29c81 100644 --- a/pysatl_criterion/statistics/student.py +++ b/pysatl_criterion/statistics/student.py @@ -186,6 +186,11 @@ def __init__( AbstractStudentGofStatistic.__init__(self, df, loc, scale) KSStatistic.__init__(self, alternative) + @staticmethod + @override + def short_code(): + return "KS" + @staticmethod @override def code(): @@ -197,7 +202,8 @@ def code(): str The code string "KS_STUDENT_GOODNESS_OF_FIT". """ - return f"KS_{AbstractStudentGofStatistic.code()}" + short_code = KolmogorovSmirnovStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -266,6 +272,11 @@ class AndersonDarlingStudentGofStatistic(AbstractStudentGofStatistic, ADStatisti Techniques (pp. 97-193). Marcel Dekker. """ + @staticmethod + @override + def short_code(): + return "AD" + @staticmethod @override def code(): @@ -277,7 +288,8 @@ def code(): str The code string "AD_STUDENT_GOODNESS_OF_FIT". """ - return f"AD_{AbstractStudentGofStatistic.code()}" + short_code = AndersonDarlingStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -346,6 +358,11 @@ class CramerVonMisesStudentGofStatistic(AbstractStudentGofStatistic, CrammerVonM der Statistik und theoretischen Physik. Deuticke. """ + @staticmethod + @override + def short_code(): + return "CVM" + @staticmethod @override def code(): @@ -357,7 +374,8 @@ def code(): str The code string "CVM_STUDENT_GOODNESS_OF_FIT". """ - return f"CVM_{AbstractStudentGofStatistic.code()}" + short_code = CramerVonMisesStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -426,6 +444,11 @@ class KuiperStudentGofStatistic(AbstractStudentGofStatistic): Series A, 63, 38-47. """ + @staticmethod + @override + def short_code(): + return "KUIPER" + @staticmethod @override def code(): @@ -437,7 +460,8 @@ def code(): str The code string "KUIPER_STUDENT_GOODNESS_OF_FIT". """ - return f"KUIPER_{AbstractStudentGofStatistic.code()}" + short_code = KuiperStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -511,6 +535,11 @@ class WatsonStudentGofStatistic(AbstractStudentGofStatistic): Biometrika, 48(1/2), 109-114. """ + @staticmethod + @override + def short_code(): + return "WATSON" + @staticmethod @override def code(): @@ -522,7 +551,8 @@ def code(): str The code string "WATSON_STUDENT_GOODNESS_OF_FIT". """ - return f"WATSON_{AbstractStudentGofStatistic.code()}" + short_code = WatsonStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -598,6 +628,11 @@ class ZhangZcStudentGofStatistic(AbstractStudentGofStatistic): Journal of the Royal Statistical Society: Series B, 64(2), 281-294. """ + @staticmethod + @override + def short_code(): + return "ZHANG_ZC" + @staticmethod @override def code(): @@ -609,7 +644,8 @@ def code(): str The code string "ZHANG_ZC_STUDENT_GOODNESS_OF_FIT". """ - return f"ZHANG_ZC_{AbstractStudentGofStatistic.code()}" + short_code = ZhangZcStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -684,6 +720,11 @@ class ZhangZaStudentGofStatistic(AbstractStudentGofStatistic): Journal of the Royal Statistical Society: Series B, 64(2), 281-294. """ + @staticmethod + @override + def short_code(): + return "ZHANG_ZA" + @staticmethod @override def code(): @@ -695,7 +736,8 @@ def code(): str The code string "ZHANG_ZA_STUDENT_GOODNESS_OF_FIT". """ - return f"ZHANG_ZA_{AbstractStudentGofStatistic.code()}" + short_code = ZhangZaStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -774,6 +816,11 @@ def __init__(self, df: float = 1): AbstractStudentGofStatistic.__init__(self, df, 0, 1) KSStatistic.__init__(self, "two-sided") + @staticmethod + @override + def short_code(): + return "LILLIE" + @staticmethod @override def code(): @@ -785,7 +832,8 @@ def code(): str The code string "LILLIE_STUDENT_GOODNESS_OF_FIT". """ - return f"LILLIE_{AbstractStudentGofStatistic.code()}" + short_code = LillieforsStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -892,6 +940,11 @@ def __init__( super().__init__(df, loc, scale) self.n_bins = n_bins + @staticmethod + @override + def short_code(): + return "CHI2" + @staticmethod @override def code(): @@ -903,7 +956,8 @@ def code(): str The code string "CHI2_STUDENT_GOODNESS_OF_FIT". """ - return f"CHI2_{AbstractStudentGofStatistic.code()}" + short_code = ChiSquareStudentGofStatistic.short_code() + return f"{short_code}_{AbstractStudentGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): diff --git a/pysatl_criterion/statistics/uniform.py b/pysatl_criterion/statistics/uniform.py index bebe10d..11dfa69 100644 --- a/pysatl_criterion/statistics/uniform.py +++ b/pysatl_criterion/statistics/uniform.py @@ -95,10 +95,16 @@ def __init__(self, a=0, b=1, alternative="two-sided", mode="auto"): AbstractUniformGofStatistic.__init__(self, a, b) KSStatistic.__init__(self, alternative, mode) + @staticmethod + @override + def short_code(): + return "KS" + @staticmethod @override def code(): - return f"KS_{AbstractUniformGofStatistic.code()}" + short_code = KolmogorovSmirnovUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -148,10 +154,16 @@ class AndersonDarlingUniformGofStatistic(AbstractUniformGofStatistic, ADStatisti The Annals of Mathematical Statistics, 23(2), 193-212. """ + @staticmethod + @override + def short_code(): + return "AD" + @staticmethod @override def code(): - return f"AD_{AbstractUniformGofStatistic.code()}" + short_code = AndersonDarlingUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -204,10 +216,16 @@ class CrammerVonMisesUniformGofStatistic(AbstractUniformGofStatistic, CrammerVon Julius Springer. """ + @staticmethod + @override + def short_code(): + return "CVM" + @staticmethod @override def code(): - return f"CVM_{AbstractUniformGofStatistic.code()}" + short_code = CrammerVonMisesUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -257,10 +275,16 @@ class LillieforsTestUniformGofStatistic(AbstractUniformGofStatistic, LillieforsT Association, 62(318), 399-402. """ + @staticmethod + @override + def short_code(): + return "LILLIE" + @staticmethod @override def code(): - return f"LILLIE_{AbstractUniformGofStatistic.code()}" + short_code = LillieforsTestUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -323,10 +347,16 @@ def __init__(self, a=0, b=1, lambda_=1, bins="sturges"): self.lambda_ = lambda_ self.bins = bins + @staticmethod + @override + def short_code(): + return "CHI2_PEARSON" + @staticmethod @override def code(): - return f"CHI2_PEARSON_{AbstractUniformGofStatistic.code()}" + short_code = Chi2PearsonUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -394,10 +424,16 @@ class WatsonUniformGofStatistic(AbstractUniformGofStatistic): def __init__(self, a=0, b=1): AbstractUniformGofStatistic.__init__(self, a, b) + @staticmethod + @override + def short_code(): + return "WATSON" + @staticmethod @override def code(): - return f"WATSON_{AbstractUniformGofStatistic.code()}" + short_code = WatsonUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -456,10 +492,16 @@ class KuiperUniformGofStatistic(AbstractUniformGofStatistic): def __init__(self, a=0, b=1): AbstractUniformGofStatistic.__init__(self, a, b) + @staticmethod + @override + def short_code(): + return "KUIPER" + @staticmethod @override def code(): - return f"KUIPER_{AbstractUniformGofStatistic.code()}" + short_code = KuiperUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -519,10 +561,16 @@ class GreenwoodTestUniformGofStatistic(AbstractUniformGofStatistic): Journal of the Royal Statistical Society, 109(2), 85-110. """ + @staticmethod + @override + def short_code(): + return "GREENWOOD" + @staticmethod @override def code(): - return f"GREENWOOD_{AbstractUniformGofStatistic.code()}" + short_code = GreenwoodTestUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -564,10 +612,16 @@ def __init__(self, a=0, b=1, bandwidth="auto"): AbstractUniformGofStatistic.__init__(self, a, b) self.bandwidth = bandwidth + @staticmethod + @override + def short_code(): + return "BICKEL_ROSENBLATT" + @staticmethod @override def code(): - return f"BICKEL_ROSENBLATT_{AbstractUniformGofStatistic.code()}" + short_code = BickelRosenblattUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -623,10 +677,16 @@ def __init__(self, a=0, b=1, test_type="A"): if self.test_type not in ["A", "C", "K"]: raise ValueError("test_type must be 'A', 'C', or 'K'") + @staticmethod + @override + def short_code(): + return "ZHANG" + @staticmethod @override def code(): - return f"ZHANG_{AbstractUniformGofStatistic.code()}" + short_code = ZhangTestsUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -688,10 +748,16 @@ class SteinUniformGofStatistic(AbstractUniformGofStatistic): def __init__(self, a=0, b=1): AbstractUniformGofStatistic.__init__(self, a, b) + @staticmethod + @override + def short_code(): + return "STEIN_U" + @staticmethod @override def code(): - return f"STEIN_U_{AbstractUniformGofStatistic.code()}" + short_code = SteinUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -768,10 +834,16 @@ class CensoredSteinUniformGofStatistic(AbstractUniformGofStatistic): def __init__(self, a=0, b=1): AbstractUniformGofStatistic.__init__(self, a, b) + @staticmethod + @override + def short_code(): + return "CENSORED_STEIN_U" + @staticmethod @override def code(): - return f"CENSORED_STEIN_U_{AbstractUniformGofStatistic.code()}" + short_code = CensoredSteinUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, censoring_indices=None, **kwargs): @@ -921,10 +993,16 @@ def __init__(self, a=0, b=1, k=4): AbstractUniformGofStatistic.__init__(self, a, b) self.k = k + @staticmethod + @override + def short_code(): + return "NEYMAN" + @staticmethod @override def code(): - return f"NEYMAN_{AbstractUniformGofStatistic.code()}" + short_code = NeymanSmoothTestUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -968,10 +1046,16 @@ class ShermanUniformGofStatistic(AbstractUniformGofStatistic): The Annals of Mathematical Statistics, 21, 339-361. """ + @staticmethod + @override + def short_code(): + return "SHERMAN" + @staticmethod @override def code(): - return f"SHERMAN_{AbstractUniformGofStatistic.code()}" + short_code = ShermanUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -1001,10 +1085,16 @@ class QuesenberryMillerUniformGofStatistic(AbstractUniformGofStatistic): Journal of Statistical Computation and Simulation, 5, 169-191. """ + @staticmethod + @override + def short_code(): + return "QUESENBERRY_MILLER" + @staticmethod @override def code(): - return f"QUESENBERRY_MILLER_{AbstractUniformGofStatistic.code()}" + short_code = QuesenberryMillerUniformGofStatistic.short_code() + return f"{short_code}_{AbstractUniformGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): diff --git a/pysatl_criterion/statistics/weibull.py b/pysatl_criterion/statistics/weibull.py index 07ed7b5..3bcd811 100644 --- a/pysatl_criterion/statistics/weibull.py +++ b/pysatl_criterion/statistics/weibull.py @@ -32,10 +32,16 @@ def code(): # TODO: Check is it real test class MinToshiyukiWeibullGofStatistic(AbstractWeibullGofStatistic, MinToshiyukiStatistic): + @staticmethod + @override + def short_code(): + return "MT" + @staticmethod @override def code(): - return f"MT_{AbstractWeibullGofStatistic.code()}" + short_code = MinToshiyukiWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs): @@ -45,10 +51,16 @@ def execute_statistic(self, rvs): class Chi2PearsonWeibullGofStatistic(AbstractWeibullGofStatistic, Chi2Statistic): + @staticmethod + @override + def short_code(): + return "CHI2_PEARSON" + @staticmethod @override def code(): - return f"CHI2_PEARSON_{AbstractWeibullGofStatistic.code()}" + short_code = Chi2PearsonWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -62,10 +74,16 @@ def execute_statistic(self, rvs, **kwargs): class LillieforsWeibullGofStatistic(AbstractWeibullGofStatistic, LillieforsTest): + @staticmethod + @override + def short_code(): + return "LILLIE" + @staticmethod @override def code(): - return f"LILLIE_{AbstractWeibullGofStatistic.code()}" + short_code = LillieforsWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -75,10 +93,16 @@ def execute_statistic(self, rvs, **kwargs): class CrammerVonMisesWeibullGofStatistic(AbstractWeibullGofStatistic, CrammerVonMisesStatistic): + @staticmethod + @override + def short_code(): + return "CVM" + @staticmethod @override def code(): - return f"CVM_{AbstractWeibullGofStatistic.code()}" + short_code = CrammerVonMisesWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" def execute_statistic(self, rvs): rvs_sorted = np.sort(rvs) @@ -87,10 +111,16 @@ def execute_statistic(self, rvs): class AndersonDarlingWeibullGofStatistic(AbstractWeibullGofStatistic, ADStatistic): + @staticmethod + @override + def short_code(): + return "AD" + @staticmethod @override def code(): - return f"AD_{AbstractWeibullGofStatistic.code()}" + short_code = AndersonDarlingWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -113,10 +143,16 @@ def __init__(self, alternative="two-sided", mode="auto", a=1, k=5): self.a = a self.k = k + @staticmethod + @override + def short_code(): + return "KS" + @staticmethod @override def code(): - return f"KS_{AbstractWeibullGofStatistic.code()}" + short_code = KolmogorovSmirnovWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs, **kwargs): @@ -126,10 +162,16 @@ def execute_statistic(self, rvs, **kwargs): class SbWeibullGofStatistic(AbstractWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "SB" + @staticmethod @override def code(): - return f"SB_{AbstractWeibullGofStatistic.code()}" + short_code = SbWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Test statistic of Shapiro Wilk @override @@ -154,10 +196,16 @@ def execute_statistic(self, rvs, **kwargs): class ST2WeibullGofStatistic(AbstractWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "ST2" + @staticmethod @override def code(): - return f"ST2_{AbstractWeibullGofStatistic.code()}" + short_code = ST2WeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Smooth test statistic based on the kurtosis @override @@ -177,10 +225,16 @@ def execute_statistic(self, rvs, **kwargs): class ST1WeibullGofStatistic(AbstractWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "ST1" + @staticmethod @override def code(): - return f"ST1_{AbstractWeibullGofStatistic.code()}" + short_code = ST1WeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Smooth test statistic based on the skewness @override @@ -199,10 +253,16 @@ def execute_statistic(self, rvs, *kwargs): class RSBWeibullGofStatistic(AbstractWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "RSB" + @staticmethod @override def code(): - return f"RSB_{AbstractWeibullGofStatistic.code()}" + short_code = RSBWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Test statistic of Smith and Bain based on probability plot @override @@ -290,10 +350,16 @@ def execute_statistic(self, rvs, type_): class TikuSinghWeibullGofStatistic(NormalizeSpaceWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "TS" + @staticmethod @override def code(): - return f"TS_{AbstractWeibullGofStatistic.code()}" + short_code = TikuSinghWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Tiku-Singh test statistic @@ -314,10 +380,16 @@ def execute_statistic(self, rvs, **kwargs): class LOSWeibullGofStatistic(NormalizeSpaceWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "LOS" + @staticmethod @override def code(): - return f"LOS_{AbstractWeibullGofStatistic.code()}" + short_code = LOSWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Lockhart-O'Reilly-Stephens test statistic @override @@ -339,10 +411,16 @@ def execute_statistic(self, rvs, **kwargs): class MSFWeibullGofStatistic(NormalizeSpaceWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "MSF" + @staticmethod @override def code(): - return f"MSF_{AbstractWeibullGofStatistic.code()}" + short_code = MSFWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Lockhart-O'Reilly-Stephens test statistic @override @@ -467,10 +545,16 @@ def execute_statistic(x, type_): class OKWeibullGofStatistic(WPPWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "OK" + @staticmethod @override def code(): - return f"OK_{AbstractWeibullGofStatistic.code()}" + short_code = OKWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Test statistic of Ozturk and Korukoglu @override @@ -489,10 +573,16 @@ def execute_statistic(self, rvs): class SBWeibullGofStatistic(WPPWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "SB" + @staticmethod @override def code(): - return f"SB_{WPPWeibullGofStatistic.code()}" + short_code = SBWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Test statistic of Shapiro Wilk @override @@ -501,10 +591,16 @@ def execute_statistic(self, rvs): class REJGWeibullGofStatistic(WPPWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "REJG" + @staticmethod @override def code(): - return f"REJG_{WPPWeibullGofStatistic.code()}" + short_code = REJGWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Test statistic of Evans, Johnson and Green based on probability plot @override @@ -513,10 +609,16 @@ def execute_statistic(self, rvs): class SPPWeibullGofStatistic(WPPWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "SPP" + @staticmethod @override def code(): - return f"SPP_{WPPWeibullGofStatistic.code()}" + short_code = SPPWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" # Test statistic based on stabilized probability plot @override @@ -534,10 +636,16 @@ class MahdiDoostparastWeibullGofStatistic(AbstractWeibullGofStatistic): Department of Statistics, School of Mathematical Sciences,Ferdowsi University of Mashhad P. O. Box 91775-1159, Mashhad, Iran""" + @staticmethod + @override + def short_code(): + return "MD" + @staticmethod @override def code(): - return f"MD_{AbstractWeibullGofStatistic.code()}" + short_code = MahdiDoostparastWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs): @@ -562,10 +670,16 @@ class WatsonWeibullGofStatistic(CrammerVonMisesWeibullGofStatistic): """Modified Cramer Statitstic https://ru.wikipedia.org/wiki/Критерий_согласия_Ватсона""" + @staticmethod + @override + def short_code(): + return "W" + @staticmethod @override def code(): - return f"W_{CrammerVonMisesWeibullGofStatistic.code()}" + short_code = WatsonWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs): @@ -589,10 +703,16 @@ class LiaoShimokawaWeibullGofStatistic(AbstractWeibullGofStatistic): A-new-goodness-of-fit-test-for-Type-I-extreme-value-and -2-parameter-Weibull-distributions-with-estimated-parameters.pdf""" + @staticmethod + @override + def short_code(): + return "LS" + @staticmethod @override def code(): - return f"LS_{AbstractWeibullGofStatistic.code()}" + short_code = LiaoShimokawaWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs): @@ -614,10 +734,16 @@ def execute_statistic(self, rvs): class KullbackLeiblerWeibullGofStatistic(AbstractWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "KL" + @staticmethod @override def code(): - return f"KL_{AbstractWeibullGofStatistic.code()}" + short_code = KullbackLeiblerWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" @override def execute_statistic(self, rvs, m=None): @@ -677,20 +803,32 @@ def execute_statistic(self, rvs, m=100, a=-5, _type="LT3_WEIBULL"): class LaplaceTransform2WeibullGofStatistic(LaplaceTransformWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "LT2" + @staticmethod @override def code(): - return f"LT2_{LaplaceTransformWeibullGofStatistic.code()}" + short_code = LaplaceTransform2WeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" def execute_statistic(self, rvs, m=100, a=-5): return super().execute_statistic(rvs, m, a, self.code()) class LaplaceTransform3WeibullGofStatistic(LaplaceTransformWeibullGofStatistic): + @staticmethod + @override + def short_code(): + return "LT3" + @staticmethod @override def code(): - return f"LT3_{LaplaceTransformWeibullGofStatistic.code()}" + short_code = LaplaceTransform3WeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" def execute_statistic(self, rvs, m=100, a=-5): return super().execute_statistic(rvs, m, a, self.code()) @@ -698,12 +836,18 @@ def execute_statistic(self, rvs, m=100, a=-5): # TODO: Check it. Throws exception on weibull test class CabanaQuirozWeibullGofStatistic(AbstractWeibullGofStatistic): - # Test statistic of Cabana and Quiroz + @staticmethod + @override + def short_code(): + return "CQ*" @staticmethod @override def code(): - return f"CQ*_{AbstractWeibullGofStatistic.code()}" + short_code = CabanaQuirozWeibullGofStatistic.short_code() + return f"{short_code}_{AbstractWeibullGofStatistic.code()}" + + # Test statistic of Cabana and Quiroz def execute_statistic(self, rvs): s1 = -0.1 diff --git a/pysatl_criterion/util/__init__.py b/pysatl_criterion/util/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pysatl_criterion/util/distribution.py b/pysatl_criterion/util/distribution.py new file mode 100644 index 0000000..197dd86 --- /dev/null +++ b/pysatl_criterion/util/distribution.py @@ -0,0 +1,42 @@ +from enum import Enum + +from pysatl_criterion.statistics import ( + AbstractExponentialityGofStatistic, + AbstractGammaGofStatistic, + AbstractNormalityGofStatistic, + AbstractStudentGofStatistic, + AbstractWeibullGofStatistic, +) +from pysatl_criterion.statistics.goodness_of_fit import AbstractGoodnessOfFitStatistic +from pysatl_criterion.statistics.uniform import AbstractUniformGofStatistic + + +class DistributionType(Enum): + """ + Distribution type. + """ + + base_class: type[AbstractGoodnessOfFitStatistic] + + NORMAL = ("normal", AbstractNormalityGofStatistic) + EXPONENTIAL = ("exponential", AbstractExponentialityGofStatistic) + WEIBULL = ("weibull", AbstractWeibullGofStatistic) + UNIFORM = ("uniform", AbstractUniformGofStatistic) + STUDENT = ("student", AbstractStudentGofStatistic) + GAMMA = ("gamma", AbstractGammaGofStatistic) + + def __new__(cls, value: str, base_class: type[AbstractGoodnessOfFitStatistic]): + obj = object.__new__(cls) + # The first item in the tuple becomes the canonical .value + obj._value_ = value + obj.base_class = base_class + return obj + + @classmethod + def list(cls): + """ + Collect all enum values. + + @return: enum values + """ + return [member.value for member in cls] diff --git a/pysatl_criterion/util/statistic.py b/pysatl_criterion/util/statistic.py new file mode 100644 index 0000000..009d5d2 --- /dev/null +++ b/pysatl_criterion/util/statistic.py @@ -0,0 +1,32 @@ +import inspect + +from pysatl_criterion.util.distribution import DistributionType + + +def get_available_criteria(distribution: DistributionType): + """ + Return a list of short codes for all non-abstract statistical criteria + available for the given distribution. + + This function inspects all direct subclasses of the distribution's + `base_class` and filters out abstract classes (i.e., those still containing + unimplemented abstract methods). For each concrete subclass, its + `short_code()` method is invoked to obtain a unique short identifier. + + Parameters + ---------- + distribution : DistributionType + The distribution descriptor whose `base_class` defines the root class + for available statistical criteria. + + Returns + ------- + List[str] + A list of short codes corresponding to all non-abstract subclasses + of `distribution.base_class`. + """ + return [ + cls.short_code() + for cls in distribution.base_class.__subclasses__() + if not inspect.isabstract(cls) + ] diff --git a/tests/util/statistic.py b/tests/util/statistic.py new file mode 100644 index 0000000..18e3741 --- /dev/null +++ b/tests/util/statistic.py @@ -0,0 +1,130 @@ +import pytest + +from pysatl_criterion.util.distribution import DistributionType +from pysatl_criterion.util.statistic import get_available_criteria + + +@pytest.mark.parametrize( + ("distribution", "result"), + [ + ( + "normal", + [ + "KS", + "AD", + "SW", + "CVM", + "LILLIE", + "JB", + "SKEW", + "KURTOSIS", + "FILLI", + "LG", + "RJ", + "SF", + "EP", + "HOSKING2", + "HOSKING1", + "HOSKING3", + "HOSKING4", + "ZWC", + "ZWA", + "GLB", + "DH", + "RJB", + "BM1", + "BM2", + "BS", + "MI", + "CC1", + "CC2", + "CS", + "ZQ", + "COIN", + "D", + "ZQS", + "SWRG", + "GMG", + "BHS", + "SH", + "DLDMZEPD", + ], + ), + ( + "exponential", + [ + "EP", + "KS", + "AHS", + "ATK", + "CO", + "CVM", + "DSP", + "EPS", + "FZ", + "GINI", + "GD", + "HM", + "HG1", + "HP", + "KM", + "KC", + "LZ", + "MN", + "PT", + "SW", + "RS", + "WE", + "WW", + "HG2", + ], + ), + ( + "weibull", + [ + "MT", + "CHI2_PEARSON", + "LILLIE", + "CVM", + "AD", + "KS", + "SB", + "ST2", + "ST1", + "RSB", + "MD", + "LS", + "KL", + "CQ*", + ], + ), + ( + "uniform", + [ + "KS", + "AD", + "CVM", + "LILLIE", + "CHI2_PEARSON", + "WATSON", + "KUIPER", + "GREENWOOD", + "BICKEL_ROSENBLATT", + "ZHANG", + "STEIN_U", + "CENSORED_STEIN_U", + "NEYMAN", + "SHERMAN", + "QUESENBERRY_MILLER", + ], + ), + ( + "student", + ["KS", "AD", "CVM", "KUIPER", "WATSON", "ZHANG_ZC", "ZHANG_ZA", "LILLIE", "CHI2"], + ), + ("gamma", ["KS", "LILLIE", "AD", "CVM", "WAT", "KUI", "GRW", "MOR", "MT", "PPCC"]), + ], +) +def test_get_available_criteria_all_criteria(distribution, result): + criteria = get_available_criteria(DistributionType(distribution)) + assert result == criteria