Skip to content

Feature/refactor - #160

Merged
alex98247 merged 31 commits into
mainfrom
feature/refactor
Nov 23, 2026
Merged

alex98247 merged 31 commits into
mainfrom
feature/refactor

Conversation

@alex98247

@alex98247 alex98247 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refactor the statistical testing library around explicit distribution parameters, reusable goodness-of-fit algorithms, and independent persistence contracts, while expanding statistical methods and validation coverage.

Quick changelog

  • Introduce validated parameter schemas and explicit support for known and unknown distribution parameters.
  • Consolidate shared EDF and frequency statistics and expand distribution-specific goodness-of-fit tests.
  • Add configurable binning, fitted-Beta bootstrap calibration, and exponential Monte Carlo testing.
  • Replace the previous multiple-testing implementation with dedicated adjustment and resampling procedures.
  • Separate persistence contracts from SQLAlchemy implementations and add transactional distribution and critical-value storage.
  • Expand numerical, regression, and integration tests, documentation, and CI validation.

What's new?

Distribution parameters now have stable identities, explicit parameterizations, and immutable validated values. Hypotheses distinguish unknown parameters from defaults, and statistics declare which parameter configurations they support. Distribution evaluation is exposed through a shared interface backed by SciPy.

Goodness-of-fit implementations reuse common empirical distribution function (EDF) and frequency algorithms through validated factories. The criterion catalog is expanded and revised across distribution families, with configurable binning strategies, parameter estimation updates, and dedicated calibration workflows for supported fitted-Beta and exponential tests.

Multiple testing moves into a dedicated package with validated inputs and structured results. It includes FWER and FDR adjustments such as Holm, Hochberg, Hommel, Benjamini–Hochberg, and two-stage procedures, alongside Simes global testing and Westfall–Young resampling methods.

Persistence now uses abstract stores, query models, and a unit of work, with SQLAlchemy handling database operations. Distribution updates and derived critical-value invalidation share a transaction, while loaders support transferring calibration data between stores.

The PR also adds independent numerical references, mathematical validation cases, persistence regressions, and statistical simulation checks. CI gains scheduled statistical validation and PostgreSQL/MySQL integration checks. Development tooling uses locked Poetry dependency groups, Ruff, and mypy.

Existing callers should review the updated parameter construction and multiple-testing APIs when migrating.

# Conflicts:
#	docs/criteria/goodness-of-fit/normality/anderson_darling_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/bhs_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/bonett_seier_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/bontemps_meddahi1_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/bontemps_meddahi2_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/cabana_cabana1_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/cabana_cabana2_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/chen_shapiro_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/coin_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/cvm_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/dagostino_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/dagostino_pearson_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/desgagne_lafaye_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/doornik_hansen_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/epps_pulley_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/filliben_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/glen_leemis_barr_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/gmg_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/graph_average_degree_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/graph_clique_number_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/graph_connected_components_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/graph_edges_number_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/graph_independence_number_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/graph_max_degree_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/hosking1_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/hosking2_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/hosking3_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/hosking4_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/jarque_bera_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/kolmogorov_smirnov_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/kurtosis_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/lilliefors_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/looney_gulledge_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/martinez_iglewicz_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/robust_jarque_bera_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/ryan_joiner_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/sf_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/shapiro_wilk_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/skew_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/spiegelhalter_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/swrg_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/zhang_q_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/zhang_q_star_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/zhang_wu_a_normality_criterion.md
#	docs/criteria/goodness-of-fit/normality/zhang_wu_c_normality_criterion.md
#	src/pysatl_criterion/hypothesis_testing/critical_values/loader/remote_loader.py
#	src/pysatl_criterion/persistence/models/base.py
#	src/pysatl_criterion/persistence/models/limit_distribution.py
#	src/pysatl_criterion/persistence/sqlalchemy/datastorage.py
#	tests/persistence/test_limit_distribution.py
@alex98247
alex98247 requested review from faux66 and quepum November 1, 2026 15:38
@alex98247 alex98247 self-assigned this Nov 1, 2026
Comment on lines +26 to +27
def __init__(self, parameters: dict[str, float] | ParameterValues | None):
self.parameter_values = parameters if isinstance(parameters, ParameterValues) else None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут небольшое расхождение с докстрингом: он обещает, что можно передать обычный dict, но parameter_values заполняется только для ParameterValues. Из-за этого get_hypothesis_generator и supports_hypothesis потом такую гипотезу не принимают

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GoodnessOfFitHypothesis теперь принимает только один аргумент

@f1i3g3 f1i3g3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По остальному напишу отдельно

Comment thread .github/workflows/ci.yaml

- name: Run tests
run: poetry run pytest --random-order
if: matrix.python-version != '3.12'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Comment thread .github/workflows/ci.yaml
Comment on lines +69 to +75
if: always()
uses: actions/upload-artifact@v7
with:
name: test-reports-python-${{ matrix.python-version }}
path: |
${{ runner.temp }}/pytest-results.xml
coverage.xml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Бенчи в отдельную ветку?

Comment on lines +26 to +32
| Criteria | Hypothesis | Estimation |
|------------------------------------|-----------------------------------------------|-----------------------------------------------------------------------------|
| 13 EDF, 5 frequency, Neyman smooth | Both shapes fixed independently of the sample | None |
| Ebner–Liebenberg | Both shapes unknown; support fixed | Beta MLE on each call |
| Raschke | Both shapes unknown; support fixed | Beta MLE, normal quantile transform, normal location/scale MLE on each call |
| Riad–Abd El Mabood; Vasicek–KL | Both shapes unknown; support fixed | Beta MLE; same weight/window in each bootstrap replicate |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оно автоматически обновляется?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Автообновление

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавить тест на custom loader?

Comment thread docs/load/examples.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^:)

@f1i3g3 f1i3g3 mentioned this pull request Nov 23, 2026
@f1i3g3 f1i3g3 added documentation Improvements or additions to documentation enhancement New feature or request python Pull requests that update python code distribution architecture Pull requests that update project architecture 1.1.0 testing Pull requests that update tests code labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.1.0 architecture Pull requests that update project architecture distribution documentation Improvements or additions to documentation enhancement New feature or request python Pull requests that update python code testing Pull requests that update tests code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants