Skip to main content

Causal Testing Framework

A Causal Inference-Driven Software Testing Framework

Project Status: Active – The project has reached a stable, usable state and is being actively developed. CI tests codecov Documentation Status Ask DeepWiki Dynamic TOML Badge PyPI - Version conda-forge GitHub License DOI DOI

The Causal Testing Framework is composed of a causal inference-driven architecture designed for functional black-box testing. It leverages graphical causal inference (CI) techniques to specify and evaluate software behaviour from a black-box perspective. Within this framework, causal directed acyclic graphs (DAGs) are used to represent the expected cause–effect relationships between the inputs and outputs of the system under test, supported by mathematical foundations for designing statistical procedures that enable causal inference. Each causal test case targets the causal effect of a specific intervention on the system under test--that is, a deliberate modification to the input configuration expected to produce a corresponding change in one or more outputs.

Causal Testing Workflow Causal Testing Workflow

Installation

Requirements

  • Python 3.11, 3.12, 3.13 and 3.14

We recommend using conda or mamba for installation, as they provide better dependency management and environment isolation, particularly for scientific computing workflows.

First, create a new conda environment with a supported Python version, e.g:

conda create -n causal-testing-env python=3.13
conda activate causal-testing-env

Note: If you have Miniforge installed, you can replace conda with mamba in any of the commands below for faster package resolution.

Add the conda-forge channel:

conda config --add channels conda-forge
conda config --set channel_priority strict

Install causal-testing-framework:

conda install causal-testing-framework

Alternative: Install from PyPI

If you prefer using pip or need the development packages, you can install from PyPI:

pip install causal-testing-framework

or if you want to install with the development packages/tools:

pip install causal-testing-framework[dev]

For Developers/Contributors: Install from source

If you're planning to contribute to the project or need an editable installation for development, you can install directly from source:

git clone https://github.com/CITCOM-project/CausalTestingFramework
cd CausalTestingFramework

then to install a specific release:

git fetch --all --tags --prune
git checkout tags/<tag> -b <branch>
pip install . # For core API only
pip install -e . # For editable install, useful for development work

For more information on how to use the Causal Testing Framework, please refer to our documentation. If you have any questions, you can also reach us by email.

[!NOTE] We recommend you use a 64-bit OS (standard in most modern machines) as we have had reports of the installation crashing on legacy 32-bit Debian systems.

Usage

[!NOTE] Step-by-step tutorials can be found on our documentation.

  1. To run the causal testing framework, you need some runtime data from your system, some causal test cases, and a causal DAG that specifies the expected causal relationships between the variables in your runtime data (and any other relevant variables that are not recorded in the data but are known to be relevant).

  2. If you do not already have causal test cases, you can convert your causal DAG to causal tests by running the following command.

causal-testing generate --dag-path $PATH_TO_DAG --output $PATH_TO_TESTS
  1. You can now execute your tests by running the following command.
causal-testing test --dag-path $PATH_TO_DAG --data-paths $PATH_TO_DATA --test-config $PATH_TO_TESTS --output $OUTPUT

The results will be saved for inspection in a JSON file located at $OUTPUT. In the future, we hope to add a visualisation tool to assist with this.

How to Cite

If you use our framework in your work, please cite the following:

This research has used version X.Y.Z (software citation) of the Causal Testing Framework (paper citation).

The paper citation should be the Causal Testing Framework paper, and the software citation should contain the specific Figshare DOI of the version used in your work.

BibTeX Citations
Paper ``` @ARTICLE{Clark_etal_2023, author = {Clark, Andrew G. and Foster, Michael and Prifling, Benedikt and Walkinshaw, Neil and Hierons, Robert M. and Schmidt, Volker and Turner, Robert D.}, title = {Testing Causality in Scientific Modelling Software}, year = {2023}, publisher = {Association for Computing Machinery}, url = {https://doi.org/10.1145/3607184}, doi = {10.1145/3607184}, journal = {ACM Trans. Softw. Eng. Methodol.}, month = {jul}, keywords = {Software Testing, Causal Testing, Causal Inference} } ```
Software (example) ``` @ARTICLE{Wild2023, author = {Foster, Michael and Clark, Andrew G. and Somers, Richard and Wild, Christopher and Allian, Farhad and Hierons, Robert M. and Wagg, David and Walkinshaw, Neil}, title = {CITCOM Software Release}, year = {2023}, month = {nov}, url = {https://orda.shef.ac.uk/articles/software/CITCOM_Software_Release/24427516}, doi = {10.15131/shef.data.24427516.v1} } ```

Acknowledgements

The Causal Testing Framework is supported by the UK's Engineering and Physical Sciences Research Council (EPSRC), with the project name CITCOM - "Causal Inference for Testing of Computational Models" under the grant EP/T030526/1.

Metadata

Release files for causal-testing-framework 16.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for causal-testing-framework 16.1.0
File Size Uploaded Provenance Actions
causal_testing_framework-16.1.0.tar.gz 2.7 MB Without provenance Details for causal_testing_framework-16.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for causal-testing-framework 16.1.0
File Interpreter ABI Platform Actions
causal_testing_framework-16.1.0-py3-none-any.whl Python 3 none any Details for causal_testing_framework-16.1.0-py3-none-any.whl

Total release size: 5.5 MB

Release files / causal_testing_framework-16.1.0.tar.gz

Download URL causal_testing_framework-16.1.0.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
106ba53914603e39198914ad38b98ce1acdfb49bec88e164575a533f877b7ae2
BLAKE2b-256 checksum
How to use checksums
b599322276ec371d2f750ebfe4ea4f0d65d035ecb2a6c3547e9f3b7d8b2e9095
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / causal_testing_framework-16.1.0-py3-none-any.whl

Download URL causal_testing_framework-16.1.0-py3-none-any.whl
Size 2.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
06db3fbb24bd46e20a548073eecb261216409fc494f949927ebbbec8a2f592da
BLAKE2b-256 checksum
How to use checksums
2e401b4b43b85bea9683c0bbb13fa67a29c6acfd06166c18c9b669fee8a3faab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for causal-testing-framework 16.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

Release history Release notifications | RSS feed

This release

16.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page