capstat-core 0.2.0__py3-none-any.whl

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.
@@ -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