Skip to content

Commit 26ec771

Browse files
authored
Merge pull request #23 from PySATL/feature/remove-criteria
Move criteria to separate package
2 parents 43a7e31 + 3614985 commit 26ec771

File tree

91 files changed

+88
-6798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+88
-6798
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Mironov Alexey
3+
Copyright (c) 2023 PySATL Team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

graph_norm_experiment.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import multiprocessing
22

33
from numpy import random as rd
4+
from pysatl.criterion.normal import (
5+
GraphEdgesNumberNormalityGofStatistic,
6+
GraphMaxDegreeNormalityGofStatistic,
7+
KolmogorovSmirnovNormalityGofStatistic,
8+
)
49

510
from stattest.experiment import Experiment
611
from stattest.experiment.configuration.configuration import (
@@ -20,10 +25,7 @@
2025
from stattest.experiment.listener.listeners import TimeEstimationListener
2126
from stattest.experiment.report.model import PdfPowerReportBuilder
2227
from stattest.experiment.test.worker import PowerCalculationWorker
23-
from stattest.persistence.db_store import CriticalValueDbStore, RvsDbStore
24-
from stattest.persistence.db_store.result_store import ResultDbStore
25-
from stattest.test import KSNormalityTest
26-
from stattest.test.normal import GraphEdgesNumberNormTest, GraphMaxDegreeNormTest
28+
from stattest.persistence.db_store import CriticalValueDbStore, ResultDbStore, RvsDbStore
2729

2830

2931
if __name__ == "__main__":
@@ -53,16 +55,16 @@
5355
LaplaceRVSGenerator(t=0, s=1),
5456
]
5557

56-
edges_two_tailed = GraphEdgesNumberNormTest()
58+
edges_two_tailed = GraphEdgesNumberNormalityGofStatistic()
5759
edges_two_tailed.two_tailed = True
5860

59-
max_degree_two_tailed = GraphMaxDegreeNormTest()
61+
max_degree_two_tailed = GraphMaxDegreeNormalityGofStatistic()
6062
max_degree_two_tailed.two_tailed = True
6163

6264
tests = [
6365
edges_two_tailed,
6466
max_degree_two_tailed,
65-
KSNormalityTest(),
67+
KolmogorovSmirnovNormalityGofStatistic(),
6668
]
6769

6870
alternatives_configuration = AlternativeConfiguration(

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ dependencies = [
1818
"sqlalchemy>=2.0.36",
1919
"python-rapidjson==1.20",
2020
"jsonschema==4.23.0",
21-
"rich==13.9.4"
21+
"rich==13.9.4",
22+
"pysatl-criterion==0.0.1a0"
2223
]
2324

2425
[build-system]

stattest/experiment/configuration/configuration.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from collections.abc import Sequence
22

3+
from pysatl.criterion import AbstractStatistic
4+
35
from stattest.experiment.generator import AbstractRVSGenerator
46
from stattest.persistence import IRvsStore
57
from stattest.persistence.models import IResultStore
6-
from stattest.test import AbstractTestStatistic
78

89

910
class TestWorkerResult:
@@ -31,13 +32,11 @@ def init(self):
3132
pass
3233

3334
def execute(
34-
self, test: AbstractTestStatistic, data: list[list[float]], code, size: int
35+
self, test: AbstractStatistic, data: list[list[float]], code, size: int
3536
) -> TestWorkerResult:
3637
raise NotImplementedError("Method is not implemented")
3738

38-
def build_id(
39-
self, test: AbstractTestStatistic, data: list[list[float]], code, size: int
40-
) -> str:
39+
def build_id(self, test: AbstractStatistic, data: list[list[float]], code, size: int) -> str:
4140
raise NotImplementedError("Method is not implemented")
4241

4342

@@ -87,7 +86,7 @@ class TestConfiguration:
8786

8887
def __init__(
8988
self,
90-
tests: Sequence[AbstractTestStatistic],
89+
tests: Sequence[AbstractStatistic],
9190
worker: TestWorker,
9291
threads=4,
9392
listeners: Sequence[StepListener] | None = None,

stattest/experiment/test/critical_value.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import numpy as np
22
import scipy.stats as scipy_stats
3+
from pysatl.criterion import AbstractStatistic
34

45
from stattest.experiment.hypothesis import AbstractHypothesis
56
from stattest.persistence.models import ICriticalValueStore
6-
from stattest.test import AbstractTestStatistic
77

88

99
def calculate_critical_value(
10-
test: AbstractTestStatistic,
10+
test: AbstractStatistic,
1111
hypothesis: AbstractHypothesis,
1212
size: int,
1313
alpha: float,
@@ -28,7 +28,7 @@ def calculate_critical_value(
2828

2929

3030
def calculate_two_tailed_critical_value(
31-
test: AbstractTestStatistic,
31+
test: AbstractStatistic,
3232
hypothesis: AbstractHypothesis,
3333
size: int,
3434
alpha: float,
@@ -50,7 +50,7 @@ def calculate_two_tailed_critical_value(
5050

5151

5252
def get_or_calculate_critical_value(
53-
test: AbstractTestStatistic,
53+
test: AbstractStatistic,
5454
hypothesis: AbstractHypothesis,
5555
size: int,
5656
alpha: float,

stattest/experiment/test/power_calculation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from pysatl.criterion import AbstractStatistic
2+
13
from stattest.experiment.hypothesis import AbstractHypothesis
24
from stattest.experiment.test.critical_value import get_or_calculate_critical_value
35
from stattest.persistence.models import ICriticalValueStore
4-
from stattest.test import AbstractTestStatistic
56

67

78
def execute_test(
8-
test: AbstractTestStatistic,
9+
test: AbstractStatistic,
910
hypothesis: AbstractHypothesis,
1011
rvs: list[float],
1112
alpha: float,
@@ -26,7 +27,7 @@ def execute_test(
2627

2728

2829
def calculate_test_power(
29-
test: AbstractTestStatistic,
30+
test: AbstractStatistic,
3031
data: list[list[float]],
3132
hypothesis: AbstractHypothesis,
3233
alpha: float,

stattest/experiment/test/test_step.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
from multiprocessing import Queue
44
from multiprocessing.synchronize import Event as EventClass
55

6+
from pysatl.criterion import AbstractStatistic
67
from tqdm import tqdm
78

89
from stattest.experiment.configuration.configuration import TestConfiguration, TestWorker
910
from stattest.experiment.pipeline import start_pipeline
1011
from stattest.persistence import IRvsStore
1112
from stattest.persistence.models import IResultStore
12-
from stattest.test import AbstractTestStatistic
1313

1414

1515
logger = logging.getLogger(__name__)
1616

1717

1818
def execute_tests(
1919
worker: TestWorker,
20-
tests: list[AbstractTestStatistic],
20+
tests: list[AbstractStatistic],
2121
rvs_store: IRvsStore,
2222
result_store: IResultStore,
2323
thread_count: int = 0,
@@ -67,7 +67,7 @@ def process_entries(
6767

6868

6969
def fill_queue(queue, generate_shutdown_event, kwargs):
70-
tests: list[AbstractTestStatistic] = kwargs["tests"]
70+
tests: list[AbstractStatistic] = kwargs["tests"]
7171
store: IRvsStore = kwargs["store"]
7272

7373
store.init()
@@ -83,7 +83,7 @@ def fill_queue(queue, generate_shutdown_event, kwargs):
8383
return len(stat) * len(tests)
8484

8585

86-
def get_total_count(tests: Sequence[AbstractTestStatistic], store: IRvsStore):
86+
def get_total_count(tests: Sequence[AbstractStatistic], store: IRvsStore):
8787
store.init()
8888
stat = store.get_rvs_stat()
8989
return len(stat) * len(tests)

stattest/experiment/test/worker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
from pysatl.criterion import AbstractStatistic
12
from typing_extensions import override
23

34
from stattest.experiment.configuration.configuration import TestWorker, TestWorkerResult
45
from stattest.experiment.hypothesis import AbstractHypothesis
56
from stattest.experiment.test.power_calculation import calculate_test_power
67
from stattest.persistence.models import ICriticalValueStore
7-
from stattest.test import AbstractTestStatistic
88

99

1010
class PowerWorkerResult(TestWorkerResult):
@@ -41,13 +41,13 @@ def init(self):
4141
self.cv_store.init()
4242

4343
def build_id(
44-
self, test: AbstractTestStatistic, data: list[list[float]], code: str, size: int
44+
self, test: AbstractStatistic, data: list[list[float]], code: str, size: int
4545
) -> str:
4646
return "_".join([str(self.alpha), str(size), test.code(), code])
4747

4848
@override
4949
def execute(
50-
self, test: AbstractTestStatistic, data: list[list[float]], code: str, size: int
50+
self, test: AbstractStatistic, data: list[list[float]], code: str, size: int
5151
) -> PowerWorkerResult:
5252
power = calculate_test_power(
5353
test, data, self.hypothesis, self.alpha, self.cv_store, self.monte_carlo_count

0 commit comments

Comments
 (0)