spicefault
Reproducible SPICE-based fault injection and reliability assessment of electronic circuits.
spicefault is a Python framework for studying how a circuit behaves when something
in it fails, under realistic component tolerances and operating conditions. You
describe a circuit, the faults it can have and how its good units vary; the framework
simulates the campaign with ngspice, keeps a record
of every sample, and computes what the results say: which faults are detected, which
are confused with each other, and how tolerance erodes both.
It is not another Python interface to SPICE. It works one level above: the fault, the normal variation of the components and the operating conditions are defined explicitly, simulated as one experiment, and recorded so that every sample can be traced and simulated again.
Documentation · Examples · Changelog
Install
pip install spicefault
and ngspice, which does the simulations (brew install ngspice on macOS,
sudo apt install ngspice on Debian and Ubuntu). Python 3.10 or later.
A first experiment
A resistive divider with 1 % resistors, two faults and two operating conditions:
from spicefault import Circuit, Experiment, OperatingCondition, SimulationConfig
from spicefault.faults import OpenCircuit, ParametricFault
from spicefault.variation import ToleranceVariation
circuit = Circuit("""divider
V1 in 0 dc 1
R1 in out 10k
R2 out 0 10k
.end
""", name="divider")
experiment = Experiment(
circuit,
config=SimulationConfig(analyses=("op",), outputs=("v(out)",)),
faults=[OpenCircuit("R2"), ParametricFault("R1", deviation=0.2)],
variations=[ToleranceVariation("R1", 0.01), ToleranceVariation("R2", 0.01)],
conditions=[
OperatingCondition(),
OperatingCondition("low supply", settings={("V1", "dc"): 0.5}),
],
samples=100,
seed=42,
)
result = experiment.run(workers=4)
print(result.status_counts()) # {'SUCCESS': 600}
table = result.to_frame() # sample definitions, status and realised values
vout = [s.result.plot("op")["v(out)"][0] for s in result]
- The component values are drawn first, the fault is injected into that drawn circuit, and then the operating condition is set.
- Each sample has its own random stream: the result is the same on one worker or on sixteen.
- A simulation that fails stays in the results, with a status and a message.
What it gives you
| Faults as objects | Open, short, leakage, parametric and composite faults, each a recorded change of the netlist with a physical interpretation |
| An auditable fault list | A fault universe generated from rules, a coverage matrix, and a reason for every fault left out |
| A healthy population | Tolerance, normal, log-normal, uniform and joint distributions, kept apart from the faults |
| Reproducible campaigns | To disk in chunks, resumable; the same samples for any number of workers; five explicit simulation statuses |
| Datasets that stand on their own | Integrity check, provenance of each sample, the netlist that was simulated for it, and simulation again from the folder |
| Reliability metrics with intervals | Detection probability, diagnostic coverage, minimum detectable deviation, robustness against tolerance, ambiguity groups |
from spicefault import FaultCampaign, Dataset
from spicefault.reliability import ReliabilityAnalysis
campaign = FaultCampaign(circuit, faults, out_dir="data/study", samples_per_fault=200,
healthy_samples=2000, variations=population, config=config,
measurements=measurements, seed=1)
campaign.run(workers=8) # resumes if it was interrupted
dataset = Dataset("data/study")
dataset.verify() # the files match their fingerprints
dataset.provenance(1234) # everything about one sample
dataset.reproduce(n=50) # simulate again, compare with what is stored
analysis = ReliabilityAnalysis.from_dataset("data/study")
analysis.detectability(alpha=0.01).table # per fault: P(detect) and its interval
analysis.minimum_detectable() # smallest deviation that is visible
analysis.ambiguity() # faults that cannot be told apart
Examples
Runnable scripts in examples/, the same ones shown in the documentation:
| Script | What it shows |
|---|---|
01_quickstart.py |
A circuit, a fault, a simulation, a small experiment |
02_faults_and_coverage.py |
Fault types, a fault universe from rules, coverage |
03_campaign.py |
A campaign to disk, interrupted and resumed |
04_dataset.py |
Integrity, provenance and reproduction of a dataset |
05_reliability.py |
Detection, minimum detectable deviation, ambiguity, tolerance |
06_operating_conditions.py |
The same circuits under several conditions |
07_custom.py |
Your own distributions and measurements |
Open the executable Binder notebooks
for the same examples, paired to the .py sources that the documentation includes, or launch one directly:
| Example | Binder notebook |
|---|---|
| 01 Quickstart | Open |
| 02 Faults and coverage | Open |
| 03 Fault campaign | Open |
| 04 Dataset | Open |
| 05 Reliability | Open |
| 06 Operating conditions | Open |
| 07 Custom variation | Open |
git clone https://github.com/telmomm/spicefault.git && cd spicefault
pip install -e .
python examples/01_quickstart.py
Or try the quickstart in the browser, without installing anything, with the Binder badge above.
Limits
- One simulator: ngspice.
- One fault per sample; faults do not change during a simulation.
- Faults act on the top level of the netlist. A component inside a subcircuit is reached through the parameters of its instance.
- Opens and shorts are finite resistances, recorded with the fault.
- Simulated evidence does not replace testing hardware.
Project
The library is the instrument of a research project on reproducible fault-injection
experiments. Its definitions and plan are part of the documentation:
fault model,
reliability metrics,
scientific scope,
experiment plan,
related work and
comparison with other tools.
The circuits it is validated on are in validation/, the benchmarks in
benchmarks/, and the results obtained so far in results/.
It was extracted from the simulation code of a study on self-diagnosis of ECG analog front-ends (ecg-frontend-fault-diagnosis), which uses it. Nothing in it is specific to that study.
Contributing
Bug reports and contributions are welcome: see CONTRIBUTING.md and the code of conduct.
Citing
If you use spicefault in your work, please cite it. The citation data are in
CITATION.cff; GitHub shows them under "Cite this repository".
Licence
MIT.
Metadata
Release files for spicefault 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| spicefault-0.2.0.tar.gz | 103.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spicefault-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 183.4 kB
Release files / spicefault-0.2.0.tar.gz
| Download URL | spicefault-0.2.0.tar.gz |
|---|---|
| Size | 103.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
204fb27e631c6cfdb8de2ec285502fa1c06f1f4e632fa9d8d6d7c4e3d2a7dd4b
|
|
BLAKE2b-256 checksum How to use checksums |
08b5a804895dee9e1c4f2d81ac610f87b72a4cdd55e413871c511d72e0122226
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / spicefault-0.2.0-py3-none-any.whl
| Download URL | spicefault-0.2.0-py3-none-any.whl |
|---|---|
| Size | 79.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85267cef0abc9f4304f086bb5cd1cf25a674021a479707ec7a10bbeba6a030a9
|
|
BLAKE2b-256 checksum How to use checksums |
99a6b6c5cd0c3c0d3f34563d7accfcb37257cabe5cd01bb83b3b8184c854a603
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logSecurity for spicefault 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for spicefault-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.