mfgQC
Auditable SPC, capability, and gage R&R for manufacturing, by Brantner Solutions. Full documentation: mfgqc.brantnersolutions.com.
Quality-control analysis for manufacturing practitioners, not statisticians or programmers. Three pillars:
- Statistical guardrails. Every analysis checks its own assumptions and reports the outcome. It warns and recommends; it never silently switches methods. Auto-correction is opt-in.
- Practitioner-oriented. You bring domain knowledge; mfgQC brings the statistics, data handling, and canonical charts. Errors say what's missing and why.
- Auditable by construction.
QCDataand result objects are immutable and carry a structured, propagating provenance history, so the full lineage from raw data to final number can be reconstructed.
Install
pip install mfgqc
For development (editable install with test extras):
pip install -e ".[test]"
Requires Python 3.10+. Core dependencies are NumPy, pandas, SciPy, Matplotlib, statsmodels, and scikit-learn.
Use
The idiom is always the same: load a frame, attach metadata with .spec() /
.roles(), then call an analysis. Every result has .report() (text),
.summary() (a flat dict), .to_dict() (full structured payload), and .view()
(the canonical chart).
import pandas as pd, mfgqc
qc = (mfgqc.load(df, measure="width", subgroup="lot", subgroup_size=5)
.spec(lower=1.0, upper=2.0, target=1.5))
print(qc.capability()) # Cp/Cpk (within-sigma) + Pp/Ppk (overall) + assumption report
print(qc.control_chart()) # inferred chart, run-rules violations
print(qc.gage_rr()) # ANOVA gage R&R (needs part/operator/replicate roles)
fig = qc.capability().view(save="capability.png") # canonical chart (matplotlib Figure)
To load a CSV, read it with pandas first: mfgqc.load(pd.read_csv(path), measure=...).
Provenance & auditability
The lineage from raw data to the final number is recorded, immutable, and verifiable, not asserted in a doc.
What is recorded. Every step that derives a number appends a structured provenance entry: ingest, spec/role binding, each transform (e.g. Box-Cox), subgroup aggregation, the sigma method chosen, and each assumption check. The chain is reconstructable end to end:
qc = mfgqc.load(df, measure="y").spec(lower=0.1, upper=8)
cap = qc.transform("boxcox").capability()
[s["operation"] for s in cap.lineage()]
# ['load', 'spec', 'transform', 'capability', 'assumption:normality']
Immutability guarantee (append-only by construction). QCData and every
result are frozen dataclasses; the history is an immutable tuple of frozen steps,
so it cannot be reordered, inserted into, or edited in place. The ingest boundary
defensive-copies the input frame, .frame hands back a copy, and .values() is
read-only, so nothing a caller does to what mfgQC returns can reach back and
change a recorded result.
Tamper-evidence (hash-chained and verifiable). Each step folds into a
running SHA-256, exposed as provenance_digest() and stamped into to_dict().
Capture the digest when you record a number, and re-check it later:
digest = cap.provenance_digest() # store alongside the reported Cpk
cap.verify_provenance(digest) # True; flips to False if any step was edited
The limit, stated honestly. The digest is a content hash, not a cryptographic
signature: code running in the same process could edit a step and recompute the
digest. It defends against accidental corruption and post-hoc edits to a stored
result, not against an adversary who controls the interpreter. One boundary is
explicit: once you extract the matplotlib Figure from .view(), edits to that
Figure are outside the lineage.
Modules
- Capability: Cp/Cpk (within-subgroup sigma) vs Pp/Ppk (overall sigma), Cpm, each with confidence intervals (small-n point estimates are overconfident; the interval is reported so you see it); normal plus Box-Cox / Clements / Johnson non-normal methods.
- Control charts: I-MR, Xbar-R, Xbar-S, p/np/c/u, EWMA, CUSUM, short-run; Nelson and Western Electric run rules.
- Measurement systems analysis: ANOVA gage R&R, bias, linearity, stability, attribute agreement (Cohen/Fleiss/weighted kappa).
- Hypothesis testing: assumption-routing two-sample / one-sample / variance / proportion tests, one-way ANOVA, post-hoc (Tukey/Games-Howell/Dunn/Dunnett), non-parametrics (Mood's median, repeated measures).
- Regression & DOE: OLS, model selection, logistic, non-linear least squares, Box-Cox; full and fractional factorial design generation and effect analysis (Lenth for unreplicated designs) with alias structure.
- Sample size & power: t-test, ANOVA, proportion, and variance, via the noncentral distributions.
- Attributes & reliability: DPMO/sigma level, life-distribution fitting with censoring, Kaplan-Meier, system reliability, bearing life (ISO 281), MTBF, availability, demonstration tests.
- Acceptance sampling: single attribute plans, OC curves, ANSI/ASQ Z1.4 and Z1.9.
Method choices
The choices a practitioner needs to trust the number are explicit, not hidden:
- Control-chart inference.
control_chart()with nokind=picks the variables chart from the subgroup size: size 1 → I-MR (individuals + moving range), size 2–10 → X-bar R, size > 10 → X-bar S. Passkind=to override; attribute charts (p/np/c/u) are always explicit. - Within-subgroup sigma (Cp/Cpk). Equal subgroups use R-bar/d₂; individuals use
MR-bar/d₂; unequal subgroup sizes use the pooled within-subgroup standard
deviation. Pp/Ppk always use the overall standard deviation. The estimator
actually used is reported in the capability result (
sigma_used, e.g."within (R-bar/d2)").
Building on mfgQC
mfgQC is built to be driven programmatically (e.g. by a report builder or UI):
mfgqc.list_analyses()/mfgqc.ANALYSES: machine-readable catalog of every analysis and its required inputs.result.to_dict(): full JSON-serializable payload (fields, assumption checks, provenance);result.summary()is the flat form.result.view(save="chart.png"): headless chart rendering to PNG/SVG.mfgqc.MissingPrerequisiteError: specific, catchable error naming what an analysis still needs.
Documentation
Full user guide and reference (with the formula, assumptions, and source standard each method is pinned to) live at mfgqc.brantnersolutions.com.
Tests
The suite has two layers. Regression tests pin mfgQC to its build oracles
(Montgomery; AIAG MSA 4th ed.; Lawson, Design and Analysis of Experiments with
R). A separate tests/correctness/ suite pins each analysis to an independent
source it was not built against (the NIST/SEMATECH e-Handbook and StRD certified
datasets, the R qcc/SixSigma packages, and scipy/statsmodels computed in-test).
pytest
© Brantner Solutions · brantnersolutions.com · MIT License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mfgqc-0.3.1.tar.gz.
File metadata
- Download URL: mfgqc-0.3.1.tar.gz
- Upload date:
- Size: 260.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bdc7a5d60192ba11f95b1ac1740205957ed08838c64b12be45cc00efac33d0a
|
|
| MD5 |
505dbac5f262737923a18875eeacae2d
|
|
| BLAKE2b-256 |
b622942b7c17cb8a4088a572430fbb2b7ec1a4d3f1497a8444c8d6d5a0dd0a26
|
File details
Details for the file mfgqc-0.3.1-py3-none-any.whl.
File metadata
- Download URL: mfgqc-0.3.1-py3-none-any.whl
- Upload date:
- Size: 243.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2912d4a3731ecee9d8f37eecef4939b405c58620b6fa0df9af0ab328429b781
|
|
| MD5 |
d6abf2be1b296039a58438da9bd6fd19
|
|
| BLAKE2b-256 |
b223ede645f9748d95f36f209dc47dd449a7db85316cd03b26f2a02e8bace9e7
|