Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

- name: Check types
run: |
poetry run mypy .
poetry run mypy pysatl_experiment tests

- name: Tests with Coveralls
if: matrix.python-version == '3.12'
Expand Down
95 changes: 0 additions & 95 deletions graph_norm_experiment.py

This file was deleted.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ click = ">=8.2.1"
dacite = "==1.9.2"
line_profiler = "5.0.0"
pydantic = "^2.11.9"
psycopg2 = "2.9.11"
pysatl-criterion = {path = "./pysatl_criterion"}

[tool.poetry.group.dev.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion pysatl_criterion
Submodule pysatl_criterion updated 34 files
+11 −11 .github/workflows/ci.yaml
+2 −2 .github/workflows/deploy-docs.yml
+4 −2 pyproject.toml
+19 −34 pysatl_criterion/cv_calculator/cv_calculator/cv_calculator.py
+7 −0 pysatl_criterion/multiple_testing/__init__.py
+39 −0 pysatl_criterion/multiple_testing/abstract_multiple_testing.py
+0 −0 pysatl_criterion/multiple_testing/fdr.py
+99 −0 pysatl_criterion/multiple_testing/fwer.py
+0 −0 pysatl_criterion/multiple_testing/special_multiple_testing.py
+0 −0 pysatl_criterion/p_value_calculator/__init__.py
+61 −0 pysatl_criterion/p_value_calculator/p_value_calculator/p_value_calculator.py
+97 −0 pysatl_criterion/persistence/limit_distribution/datastorage/datastorage.py
+2 −2 pysatl_criterion/persistence/limit_distribution/sqlite/sqlite.py
+66 −0 pysatl_criterion/persistence/model/orm/orm.py
+392 −0 ...terion/persistence/parameter_estimation/maximum_likelihood_method/function_for_maximum_likelihood_method.py
+33 −0 pysatl_criterion/persistence/parameter_estimation/maximum_likelihood_method/maximum_likelihood_method.py
+42 −34 pysatl_criterion/statistics/exponent.py
+88 −16 pysatl_criterion/statistics/graph_goodness_of_fit.py
+34 −18 pysatl_criterion/statistics/models.py
+41 −27 pysatl_criterion/statistics/normal.py
+32 −18 pysatl_criterion/test/goodness_of_fit_test/goodness_of_fit_test.py
+79 −0 tests/calc/test_cv.py
+114 −0 tests/calc/test_goodness_of_fit_test.py
+115 −0 tests/calc/test_p_value.py
+0 −0 tests/multiple_testing/test_fdr.py
+98 −0 tests/multiple_testing/test_fwer.py
+0 −0 tests/multiple_testing/test_special_multiple_testing.py
+19 −0 tests/persistence/limit_distribution/datastorage/datastorage_test.py
+142 −0 tests/persistence/limit_distribution/limit_distribution_test.py
+62 −0 tests/persistence/limit_distribution/sqlite/sqlite_test.py
+53 −4 tests/statistics/test_exponent.py
+520 −0 tests/statistics/test_function_for_maximum_likelihood_method.py
+46 −0 tests/statistics/test_hypothesis_type.py
+49 −4 tests/statistics/test_normal.py
18 changes: 0 additions & 18 deletions pysatl_experiment/cli/commands/common/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ def create_result_path() -> Path:
return results_dir


def create_storage_path(storage_name: str) -> str:
"""
Create storage path.

:param storage_name: name of the storage.

:return: path to the storage.
"""

# pysatl-experiment/.storage
storage_dir = Path(__file__).resolve().parents[4] / ".storage"
storage_file_name = f"{storage_name}.sqlite"

storage_path = storage_dir / storage_file_name

return str(storage_path)


def save_experiment_data(experiment_name: str, experiment_data: dict) -> None:
"""
Save experiment data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from click import Context, argument, echo, pass_context

from pysatl_experiment.cli.commands.common.common import (
create_storage_path,
get_experiment_name_and_config,
save_experiment_config,
)
Expand All @@ -16,14 +15,13 @@ def storage_connection(ctx: Context, connection: str) -> None:
Configure storage connection.

:param ctx: context.
:param connection: storage connection.
:param connection: storage connection. Example: postgresql://postgres:postgres@localhost/pysatl
"""

experiment_name, experiment_config = get_experiment_name_and_config(ctx)

storage_path = create_storage_path(connection)
experiment_config["storage_connection"] = storage_path
experiment_config["storage_connection"] = connection

save_experiment_config(ctx, experiment_name, experiment_config)

echo(f"Storage connection of the experiment {experiment_name} is set to '{storage_path}'.")
echo(f"Storage connection of the experiment {experiment_name} is set to '{connection}'.")
20 changes: 2 additions & 18 deletions pysatl_experiment/experiment/test/critical_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,19 @@ def get_or_calculate_critical_value(
store: ICriticalValueStore,
count: int,
) -> float | tuple[float, float]:
critical_values_from_common_criterion = test.calculate_two_tailed_critical_values(size, alpha)
if critical_values_from_common_criterion is not None:
return critical_values_from_common_criterion

critical_value_from_common_criterion = test.calculate_critical_value(size, alpha)
if critical_value_from_common_criterion is not None:
return critical_value_from_common_criterion

critical_value = store.get_critical_value(test.code(), size, alpha)
if critical_value is not None:
return critical_value

distribution = store.get_distribution(test.code(), size)
if distribution is not None:
ecdf = scipy_stats.ecdf(distribution)
if test.two_tailed:
lower_critical = float(np.quantile(ecdf.cdf.quantiles, q=alpha / 2))
upper_critical = float(np.quantile(ecdf.cdf.quantiles, q=1 - alpha / 2))
critical_value = (lower_critical, upper_critical)
else:
critical_value = float(np.quantile(ecdf.cdf.quantiles, q=1 - alpha))
critical_value = float(np.quantile(ecdf.cdf.quantiles, q=1 - alpha))

store.insert_critical_value(test.code(), size, alpha, critical_value)
return critical_value

if test.two_tailed:
critical_value, distribution = calculate_two_tailed_critical_value(test, hypothesis, size, alpha, count)
else:
critical_value, distribution = calculate_critical_value(test, hypothesis, size, alpha, count)
critical_value, distribution = calculate_critical_value(test, hypothesis, size, alpha, count)

store.insert_critical_value(test.code(), size, alpha, critical_value)
store.insert_distribution(test.code(), size, distribution)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ILimitDistributionStorage,
LimitDistributionModel,
)
from pysatl_experiment.experiment_new.model.experiment_step.experiment_step import IExperimentStep
from pysatl_experiment.experiment_new.step.execution.common.execution_step_data.execution_step_data import (
ExecutionStepData,
)
Expand All @@ -24,7 +25,7 @@ class CriticalValueStepData(ExecutionStepData):
"""


class CriticalValueExecutionStep:
class CriticalValueExecutionStep(IExperimentStep):
"""
Standard critical value experiment execution step.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from line_profiler import profile

from pysatl_experiment.experiment_new.model.experiment_step.experiment_step import IExperimentStep
from pysatl_experiment.experiment_new.step.execution.common.execution_step_data.execution_step_data import ( # noqa: E501
ExecutionStepData,
)
Expand All @@ -24,7 +25,7 @@ class TimeComplexityStepData(ExecutionStepData):
"""


class TimeComplexityExecutionStep:
class TimeComplexityExecutionStep(IExperimentStep):
"""
Standard time complexity experiment execution step.
"""
Expand Down
2 changes: 0 additions & 2 deletions pysatl_experiment/factory/critical_value/critical_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class CriticalValueExperimentFactory(
Critical value experiment factory.
"""

pass

def __init__(self, experiment_data: CriticalValueExperimentData):
super().__init__(experiment_data)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod
from typing import Any, Generic, TypeVar, cast

from pysatl_criterion.persistence.limit_distribution.sqlite.sqlite import SQLiteLimitDistributionStorage
from pysatl_criterion.persistence.limit_distribution.datastorage.datastorage import SQLAlchemyLimitDistributionStorage
from pysatl_criterion.persistence.model.common.data_storage.data_storage import IDataStorage
from pysatl_criterion.persistence.model.limit_distribution.limit_distribution import LimitDistributionQuery
from pysatl_criterion.statistics import (
Expand All @@ -23,9 +23,9 @@
from pysatl_experiment.persistence.model.power.power import PowerQuery
from pysatl_experiment.persistence.model.random_values.random_values import IRandomValuesStorage, RandomValuesAllQuery
from pysatl_experiment.persistence.model.time_complexity.time_complexity import TimeComplexityQuery
from pysatl_experiment.persistence.power.sqlite.sqlite import SQLitePowerStorage
from pysatl_experiment.persistence.random_values.sqlite.sqlite import SQLiteRandomValuesStorage
from pysatl_experiment.persistence.time_complexity.sqlite.sqlite import SQLiteTimeComplexityStorage
from pysatl_experiment.persistence.power.alchemy.alchemy import AlchemyPowerStorage
from pysatl_experiment.persistence.random_values.alchemy import AlchemyRandomValuesStorage
from pysatl_experiment.persistence.time_complexity.alchemy.alchemy import AlchemyTimeComplexityStorage


D = TypeVar("D", contravariant=True, bound=ExperimentData)
Expand Down Expand Up @@ -434,7 +434,7 @@ def _init_data_storage(self) -> IRandomValuesStorage:
"""

storage_connection = self.experiment_data.config.storage_connection
data_storage = SQLiteRandomValuesStorage(storage_connection)
data_storage = AlchemyRandomValuesStorage(storage_connection)
data_storage.init()

return data_storage
Expand Down Expand Up @@ -462,15 +462,15 @@ def _init_result_storage(self) -> RS:
experiment_type = self.experiment_data.config.experiment_type
storage_connection = self.experiment_data.config.storage_connection
if experiment_type == ExperimentType.CRITICAL_VALUE:
limit_distribution_storage = SQLiteLimitDistributionStorage(storage_connection)
limit_distribution_storage = SQLAlchemyLimitDistributionStorage(storage_connection)
limit_distribution_storage.init()
return cast(RS, limit_distribution_storage)
elif experiment_type == ExperimentType.POWER:
power_storage = SQLitePowerStorage(storage_connection)
power_storage = AlchemyPowerStorage(storage_connection)
power_storage.init()
return cast(RS, power_storage)
elif experiment_type == ExperimentType.TIME_COMPLEXITY:
time_complexity_storage = SQLiteTimeComplexityStorage(storage_connection)
time_complexity_storage = AlchemyTimeComplexityStorage(storage_connection)
time_complexity_storage.init()
return cast(RS, time_complexity_storage)
else:
Expand Down
Loading