capstat-core 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. capstat_core-0.2.0/.gitignore +38 -0
  2. capstat_core-0.2.0/PKG-INFO +37 -0
  3. capstat_core-0.2.0/README.md +15 -0
  4. capstat_core-0.2.0/pyproject.toml +34 -0
  5. capstat_core-0.2.0/src/capstat_core/__init__.py +206 -0
  6. capstat_core-0.2.0/src/capstat_core/_validation.py +38 -0
  7. capstat_core-0.2.0/src/capstat_core/acceptance_sampling.py +665 -0
  8. capstat_core-0.2.0/src/capstat_core/bias.py +155 -0
  9. capstat_core-0.2.0/src/capstat_core/capability.py +382 -0
  10. capstat_core-0.2.0/src/capstat_core/constants.py +316 -0
  11. capstat_core-0.2.0/src/capstat_core/control_charts.py +360 -0
  12. capstat_core-0.2.0/src/capstat_core/descriptive.py +228 -0
  13. capstat_core-0.2.0/src/capstat_core/gage_rr.py +482 -0
  14. capstat_core-0.2.0/src/capstat_core/linearity.py +203 -0
  15. capstat_core-0.2.0/src/capstat_core/nonnormal.py +620 -0
  16. capstat_core-0.2.0/src/capstat_core/normality.py +342 -0
  17. capstat_core-0.2.0/src/capstat_core/py.typed +0 -0
  18. capstat_core-0.2.0/src/capstat_core/robust.py +139 -0
  19. capstat_core-0.2.0/src/capstat_core/rules.py +332 -0
  20. capstat_core-0.2.0/src/capstat_core/sampling_scheme.py +347 -0
  21. capstat_core-0.2.0/src/capstat_core/stability.py +92 -0
  22. capstat_core-0.2.0/src/capstat_core/time_weighted.py +316 -0
  23. capstat_core-0.2.0/tests/conftest.py +89 -0
  24. capstat_core-0.2.0/tests/references/acceptance_sampling.yaml +383 -0
  25. capstat_core-0.2.0/tests/references/bias.yaml +68 -0
  26. capstat_core-0.2.0/tests/references/capability.yaml +135 -0
  27. capstat_core-0.2.0/tests/references/control_charts.yaml +97 -0
  28. capstat_core-0.2.0/tests/references/data/nist_strd/Lew.dat +260 -0
  29. capstat_core-0.2.0/tests/references/data/nist_strd/Lottery.dat +278 -0
  30. capstat_core-0.2.0/tests/references/data/nist_strd/Mavro.dat +110 -0
  31. capstat_core-0.2.0/tests/references/data/nist_strd/Michelso.dat +160 -0
  32. capstat_core-0.2.0/tests/references/data/nist_strd/NumAcc1.dat +63 -0
  33. capstat_core-0.2.0/tests/references/data/nist_strd/NumAcc2.dat +1061 -0
  34. capstat_core-0.2.0/tests/references/data/nist_strd/NumAcc3.dat +1061 -0
  35. capstat_core-0.2.0/tests/references/data/nist_strd/NumAcc4.dat +1061 -0
  36. capstat_core-0.2.0/tests/references/data/nist_strd/PiDigits.dat +5060 -0
  37. capstat_core-0.2.0/tests/references/gage_rr.yaml +130 -0
  38. capstat_core-0.2.0/tests/references/linearity.yaml +47 -0
  39. capstat_core-0.2.0/tests/references/nist_strd_univariate.yaml +160 -0
  40. capstat_core-0.2.0/tests/references/nonnormal.yaml +133 -0
  41. capstat_core-0.2.0/tests/references/normality.yaml +120 -0
  42. capstat_core-0.2.0/tests/references/rules.yaml +94 -0
  43. capstat_core-0.2.0/tests/references/sampling_scheme.yaml +102 -0
  44. capstat_core-0.2.0/tests/references/time_weighted.yaml +101 -0
  45. capstat_core-0.2.0/tests/test_acceptance_sampling.py +762 -0
  46. capstat_core-0.2.0/tests/test_bias.py +143 -0
  47. capstat_core-0.2.0/tests/test_capability.py +441 -0
  48. capstat_core-0.2.0/tests/test_control_charts.py +425 -0
  49. capstat_core-0.2.0/tests/test_descriptive.py +184 -0
  50. capstat_core-0.2.0/tests/test_gage_rr.py +392 -0
  51. capstat_core-0.2.0/tests/test_linearity.py +159 -0
  52. capstat_core-0.2.0/tests/test_nist_strd_univariate.py +137 -0
  53. capstat_core-0.2.0/tests/test_nonnormal.py +587 -0
  54. capstat_core-0.2.0/tests/test_normality.py +352 -0
  55. capstat_core-0.2.0/tests/test_robust.py +150 -0
  56. capstat_core-0.2.0/tests/test_rules.py +336 -0
  57. capstat_core-0.2.0/tests/test_sampling_scheme.py +335 -0
  58. capstat_core-0.2.0/tests/test_smoke.py +14 -0
  59. capstat_core-0.2.0/tests/test_stability.py +64 -0
  60. capstat_core-0.2.0/tests/test_time_weighted.py +461 -0
@@ -0,0 +1,38 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ .venv/
9
+ venv/
10
+
11
+ # uv
12
+ .uv/
13
+
14
+ # Tooling caches
15
+ .mypy_cache/
16
+ .ruff_cache/
17
+ .pytest_cache/
18
+ .coverage
19
+ .coverage.*
20
+ coverage.xml
21
+ htmlcov/
22
+
23
+ # Node / TypeScript (apps/web)
24
+ node_modules/
25
+ .next/
26
+ out/
27
+ dist/
28
+ *.tsbuildinfo
29
+ next-env.d.ts
30
+
31
+ # Docs build
32
+ site/
33
+
34
+ # OS / editor
35
+ .DS_Store
36
+ *.swp
37
+ .idea/
38
+ .vscode/
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.5
2
+ Name: capstat-core
3
+ Version: 0.2.0
4
+ Summary: Reference-validated SPC, process capability, and MSA statistics.
5
+ Project-URL: Homepage, https://github.com/Xindaan/capstat
6
+ Project-URL: Repository, https://github.com/Xindaan/capstat
7
+ Author: André Leopold
8
+ License-Expression: MIT
9
+ Keywords: gage-rr,msa,process-capability,quality,spc,statistics
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: numpy>=1.26
20
+ Requires-Dist: scipy>=1.11
21
+ Description-Content-Type: text/markdown
22
+
23
+ # capstat-core
24
+
25
+ Reference-validated statistics for statistical process control (SPC),
26
+ process capability, and measurement system analysis (MSA).
27
+
28
+ `capstat-core` is a pure Python library (numpy + scipy only) with **zero web
29
+ dependencies**; it is independently publishable on PyPI. Every statistical
30
+ result is validated against published reference values.
31
+
32
+ Part of the [capstat](https://github.com/Xindaan/capstat) project. See the
33
+ repository root for documentation and the full toolkit (API + web app).
34
+
35
+ ## License
36
+
37
+ MIT © André Leopold
@@ -0,0 +1,15 @@
1
+ # capstat-core
2
+
3
+ Reference-validated statistics for statistical process control (SPC),
4
+ process capability, and measurement system analysis (MSA).
5
+
6
+ `capstat-core` is a pure Python library (numpy + scipy only) with **zero web
7
+ dependencies**; it is independently publishable on PyPI. Every statistical
8
+ result is validated against published reference values.
9
+
10
+ Part of the [capstat](https://github.com/Xindaan/capstat) project. See the
11
+ repository root for documentation and the full toolkit (API + web app).
12
+
13
+ ## License
14
+
15
+ MIT © André Leopold
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "capstat-core"
3
+ version = "0.2.0" # x-release-please-version
4
+ description = "Reference-validated SPC, process capability, and MSA statistics."
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ authors = [{ name = "André Leopold" }]
9
+ keywords = ["spc", "process-capability", "msa", "gage-rr", "statistics", "quality"]
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Intended Audience :: Science/Research",
13
+ "License :: OSI Approved :: MIT License",
14
+ "Programming Language :: Python :: 3.11",
15
+ "Programming Language :: Python :: 3.12",
16
+ "Programming Language :: Python :: 3.13",
17
+ "Topic :: Scientific/Engineering :: Mathematics",
18
+ "Typing :: Typed",
19
+ ]
20
+ dependencies = [
21
+ "numpy>=1.26",
22
+ "scipy>=1.11",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/Xindaan/capstat"
27
+ Repository = "https://github.com/Xindaan/capstat"
28
+
29
+ [build-system]
30
+ requires = ["hatchling"]
31
+ build-backend = "hatchling.build"
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["src/capstat_core"]
@@ -0,0 +1,206 @@
1
+ """capstat-core: reference-validated SPC, capability, and MSA statistics.
2
+
3
+ Every statistic exposed here is validated against published reference values;
4
+ see ``tests/references/`` for the sources and the certified numbers.
5
+
6
+ The public API is populated milestone by milestone (see TASK.md). Available
7
+ today: descriptive summary statistics, robust location/scale estimators, and
8
+ normality testing.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from capstat_core.acceptance_sampling import (
14
+ AOQLimit,
15
+ LotDecision,
16
+ OCCurve,
17
+ SamplingPlan,
18
+ SamplingPlanReport,
19
+ aoq_limit,
20
+ average_outgoing_quality,
21
+ average_total_inspection,
22
+ design_single_sampling_plan,
23
+ evaluate_plan,
24
+ inspect_lot,
25
+ oc_curve,
26
+ probability_of_acceptance,
27
+ quality_for_acceptance,
28
+ )
29
+ from capstat_core.bias import (
30
+ BiasReport,
31
+ bias,
32
+ )
33
+ from capstat_core.capability import (
34
+ CapabilityReport,
35
+ capability,
36
+ )
37
+ from capstat_core.constants import A2, A3, B3, B4, D3, D4, E2, c4, d2, d2_star, d3
38
+ from capstat_core.control_charts import (
39
+ ChartPair,
40
+ ControlChart,
41
+ ControlLimits,
42
+ i_mr_chart,
43
+ xbar_r_chart,
44
+ xbar_s_chart,
45
+ )
46
+ from capstat_core.descriptive import (
47
+ DescriptiveSummary,
48
+ describe,
49
+ kurtosis,
50
+ lag1_autocorrelation,
51
+ mean,
52
+ skewness,
53
+ std_dev,
54
+ variance,
55
+ )
56
+ from capstat_core.gage_rr import (
57
+ GageRRReport,
58
+ gage_rr,
59
+ gage_rr_range,
60
+ )
61
+ from capstat_core.linearity import (
62
+ LinearityReport,
63
+ linearity,
64
+ )
65
+ from capstat_core.nonnormal import (
66
+ BoxCoxCapability,
67
+ CapabilityAnalysis,
68
+ DistributionFit,
69
+ PercentileCapability,
70
+ analyze_capability,
71
+ box_cox_capability,
72
+ fit_distribution,
73
+ percentile_capability,
74
+ )
75
+ from capstat_core.normality import (
76
+ NormalityAssessment,
77
+ NormalityTestResult,
78
+ anderson_darling,
79
+ anderson_darling_pvalue,
80
+ assess_normality,
81
+ shapiro_wilk,
82
+ )
83
+ from capstat_core.robust import (
84
+ MAD_NORMAL_CONSISTENCY,
85
+ iqr,
86
+ mad,
87
+ median,
88
+ trimmed_mean,
89
+ winsorized_mean,
90
+ )
91
+ from capstat_core.rules import (
92
+ NELSON_RULES,
93
+ WESTERN_ELECTRIC_RULES,
94
+ RuleViolation,
95
+ nelson_rules,
96
+ western_electric_rules,
97
+ )
98
+ from capstat_core.sampling_scheme import (
99
+ InspectionSeverity,
100
+ LotResult,
101
+ SchemeHistory,
102
+ SchemeStep,
103
+ SwitchingRules,
104
+ apply_switching_rules,
105
+ )
106
+ from capstat_core.stability import (
107
+ StabilityReport,
108
+ stability,
109
+ )
110
+ from capstat_core.time_weighted import (
111
+ CusumChart,
112
+ EwmaChart,
113
+ cusum_chart,
114
+ ewma_chart,
115
+ )
116
+
117
+ __all__ = [
118
+ "A2",
119
+ "A3",
120
+ "B3",
121
+ "B4",
122
+ "D3",
123
+ "D4",
124
+ "E2",
125
+ "MAD_NORMAL_CONSISTENCY",
126
+ "NELSON_RULES",
127
+ "WESTERN_ELECTRIC_RULES",
128
+ "AOQLimit",
129
+ "BiasReport",
130
+ "BoxCoxCapability",
131
+ "CapabilityAnalysis",
132
+ "CapabilityReport",
133
+ "ChartPair",
134
+ "ControlChart",
135
+ "ControlLimits",
136
+ "CusumChart",
137
+ "DescriptiveSummary",
138
+ "DistributionFit",
139
+ "EwmaChart",
140
+ "GageRRReport",
141
+ "InspectionSeverity",
142
+ "LinearityReport",
143
+ "LotDecision",
144
+ "LotResult",
145
+ "NormalityAssessment",
146
+ "NormalityTestResult",
147
+ "OCCurve",
148
+ "PercentileCapability",
149
+ "RuleViolation",
150
+ "SamplingPlan",
151
+ "SamplingPlanReport",
152
+ "SchemeHistory",
153
+ "SchemeStep",
154
+ "StabilityReport",
155
+ "SwitchingRules",
156
+ "__version__",
157
+ "analyze_capability",
158
+ "anderson_darling",
159
+ "anderson_darling_pvalue",
160
+ "aoq_limit",
161
+ "apply_switching_rules",
162
+ "assess_normality",
163
+ "average_outgoing_quality",
164
+ "average_total_inspection",
165
+ "bias",
166
+ "box_cox_capability",
167
+ "c4",
168
+ "capability",
169
+ "cusum_chart",
170
+ "d2",
171
+ "d2_star",
172
+ "d3",
173
+ "describe",
174
+ "design_single_sampling_plan",
175
+ "evaluate_plan",
176
+ "ewma_chart",
177
+ "fit_distribution",
178
+ "gage_rr",
179
+ "gage_rr_range",
180
+ "i_mr_chart",
181
+ "inspect_lot",
182
+ "iqr",
183
+ "kurtosis",
184
+ "lag1_autocorrelation",
185
+ "linearity",
186
+ "mad",
187
+ "mean",
188
+ "median",
189
+ "nelson_rules",
190
+ "oc_curve",
191
+ "percentile_capability",
192
+ "probability_of_acceptance",
193
+ "quality_for_acceptance",
194
+ "shapiro_wilk",
195
+ "skewness",
196
+ "stability",
197
+ "std_dev",
198
+ "trimmed_mean",
199
+ "variance",
200
+ "western_electric_rules",
201
+ "winsorized_mean",
202
+ "xbar_r_chart",
203
+ "xbar_s_chart",
204
+ ]
205
+
206
+ __version__ = "0.2.0" # x-release-please-version
@@ -0,0 +1,38 @@
1
+ """Internal input validation shared by the public statistics modules.
2
+
3
+ Not part of the public API.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import numpy as np
9
+ import numpy.typing as npt
10
+
11
+ __all__ = ["as_sample"]
12
+
13
+
14
+ def as_sample(x: npt.ArrayLike, *, minimum: int = 1) -> npt.NDArray[np.float64]:
15
+ """Validate and coerce ``x`` into a one-dimensional float64 sample.
16
+
17
+ Rejecting non-finite input here (rather than silently propagating ``nan``)
18
+ keeps every downstream statistic total: if a call returns a number, that
19
+ number is meaningful.
20
+
21
+ Raises
22
+ ------
23
+ ValueError
24
+ If the sample is not one-dimensional, holds fewer than ``minimum``
25
+ observations, or contains NaN or infinite values.
26
+ """
27
+ arr = np.asarray(x, dtype=np.float64)
28
+ if arr.ndim != 1:
29
+ raise ValueError(
30
+ f"expected a one-dimensional sample, got {arr.ndim} dimension(s)"
31
+ )
32
+ if arr.size < minimum:
33
+ raise ValueError(
34
+ f"sample must contain at least {minimum} observation(s), got {arr.size}"
35
+ )
36
+ if not np.all(np.isfinite(arr)):
37
+ raise ValueError("sample contains NaN or infinite values")
38
+ return arr