Skip to main content

A framework for causal testing using causal directed acyclic graphs.

Project description

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

Recommended: Install from conda-forge

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

causal_testing_framework-14.2.0.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

causal_testing_framework-14.2.0-py3-none-any.whl (2.5 MB view details)

Uploaded Python 3

File details

Details for the file causal_testing_framework-14.2.0.tar.gz.

File metadata

File hashes

Hashes for causal_testing_framework-14.2.0.tar.gz
Algorithm Hash digest
SHA256 c1cbbca5e46145e18bfe155aa066cdd7649a47fd179109f11a3d82626e35a2e7
MD5 972756caa30f4c781793b4fc1885cb0f
BLAKE2b-256 3659de7820937fe4e18e97e6e609a0a04129b4de1867ccf9e8de909d927a6a9b

See more details on using hashes here.

File details

Details for the file causal_testing_framework-14.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for causal_testing_framework-14.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e4a4ffef91ed5d911e58220c22288158c8cc438b4f07380f36aa1fa046637a5
MD5 614caac2227a08d10dba72dfb7f276d0
BLAKE2b-256 b5c18c94e98a6c8a00b7c52de03650eadc7e17da660782f6cd4b9ddf7ca89af8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page