Skip to content

Audit and stabilise the mathematical core - #9

Merged
DiogoRibeiro7 merged 2 commits into
mainfrom
audit/mathematical-core
Aug 10, 2026
Merged

Audit and stabilise the mathematical core#9
DiogoRibeiro7 merged 2 commits into
mainfrom
audit/mathematical-core

Conversation

@DiogoRibeiro7

@DiogoRibeiro7 DiogoRibeiro7 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Audits every mathematical quantity the package exports before new features are layered on top.

Added

tests/test_mathematical_core.py — 41 hand-computable tests covering membership representation, the fuzzy operators, sufficiency, necessity, subset relations, calibration, truth-table classification and minimisation. Each assertion carries the arithmetic in a comment so it can be checked against the definition without running the code.

Boundary and degenerate behaviour is now pinned explicitly:

Situation Behaviour
Σ X = 0 consistency, coverage and PRI are 0, not NaN
Σ Y = 0 coverage and necessity consistency are 0
Σ (1 − min(X,Y)) = 0 RoN is 0
membership exactly 0 or 1 admissible; operators reduce to crisp logic
NaN or infinite ValueError — never imputed
outside [0, 1] ValueError — never clipped

docs/mathematical_validation.md — the audit table: object, equation, implementation, test, tolerance and validation status, plus full definitions for the calibration transformations and row coding.

Findings

  1. Unique coverage is not implemented. Raw coverage is; the per-term unique coverage other QCA software reports is absent. Recorded as a gap, not a divergence.
  2. Intermediate solutions are not the standard algorithm and stay marked experimental.
  3. No untested mathematical helper remains in the metric or minimisation layers.
  4. Returning 0 for an undefined ratio is documented as a deliberate convention — propagating NaN would silently poison downstream aggregation.

No behaviour changed; this is verification and documentation only. 177 tests pass at 100% coverage.


Summary by cubic

Audit the mathematical core of setqca with hand-computable tests and clear boundary conventions to stabilize metrics, operators, calibration, truth tables, and minimisation. No behavior changes.

  • New Features
    • Added tests/test_mathematical_core.py with 41 hand-computable tests covering membership, fuzzy operators, subset relations, sufficiency/necessity (consistency, coverage, PRI, RoN), calibration, truth-table coding, and minimisation.
    • Added docs/mathematical_validation.md with equations, implementation links, test references, tolerances, and validation status; linked in mkdocs.yml under Validation.
    • Pinned boundary behavior: empty cause/outcome return 0 (no NaNs), RoN=0 when denominator is 0, crisp 0/1 allowed, values outside [0,1] or NaN/∞ raise ValueError (no clipping or imputation).

Written for commit 77bb834. Summary will update on new commits.

Review in cubic

@DiogoRibeiro7
DiogoRibeiro7 merged commit b3057a6 into main Aug 10, 2026
15 checks passed
@DiogoRibeiro7
DiogoRibeiro7 deleted the audit/mathematical-core branch August 10, 2026 22:47
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant