citests: A Conditional Independence Test Toolkit
Full documentation is hosted on GitHub Pages.
citests is a Python library that provides a comprehensive toolkit for conditional independence (CI) testing. It is designed to be seamlessly integrated with the causal-learn package and offers a collection of partial correlation, contingency table, regression, nearest neighbor, kernel, and machine-learning-based CI tests, plus adapter strategies.
The library is structured to be a powerful benchmark for causal discovery and a practical toolkit for researchers and practitioners.
Features
causal-learncompatible: All tests are designed as drop-in replacements for the standard tests in thecausal-learnecosystem, allowing you to easily use them with algorithms like PC.
Installation
Install directly from GitHub with pip:
pip install git+https://github.com/averinpa/citests.git
For local development with extras:
uv sync --all-extras
Optional dependency groups in pyproject.toml:
pycomets— required forgcm,wgcm,pcm(installsxgboostonly;pycometsitself is GitHub-only and must be installed separately:pip install git+https://github.com/shimenghuang/pycomets.git)tigramite— required forcmiknn,cmiknn_mixed,regcir— required forrcit,rcot,ci_mm,hartemink_chisq(installsrpy2); the corresponding R packages must also be installed:RCITfrom GitHubericstrobl/RCIT(forrcit,rcot)MXMfrom CRAN (forci_mm)bnlearnfrom CRAN (forhartemink_chisq)
The mcmiknn test uses a vendored copy of the upstream hpi-epic/mCMIkNN source under citests/_vendor/indeptests/; no additional installation is required.
Quickstart Example
Here is a simple example of how to use a citests test within the causal-learn PC algorithm.
import numpy as np
from causallearn.search.ConstraintBased.PC import pc
import citests.tests
# 1. Generate some data
np.random.seed(42)
data = np.random.randn(200, 3)
data[:, 2] = 0.5 * data[:, 0] + 0.5 * data[:, 1] + 0.1 * np.random.randn(200)
# 2. Run the PC algorithm using a citests test
# Example test ids: "fisherz_citests", "spearman", "gsq", "chisq", "kci", "gcm"
cg = pc(data, alpha=0.05, indep_test='spearman')
# 3. View the learned graph
print("Learned Graph Edges:")
print(cg.G.get_edges())
Available Tests
| Test Name | Family | Wrapped From |
|---|---|---|
fisherz_citests |
Partial Correlation | causal-learn (CIT(..., method_name="fisherz")) |
spearman |
Partial Correlation | causal-learn Fisher-Z on ranked data |
chisq |
Contingency Table | causal-learn (Chisq_or_Gsq(..., method_name="chisq")) |
gsq |
Contingency Table | causal-learn (Chisq_or_Gsq(..., method_name="gsq")) |
regci |
Regression | tigramite.independence_tests.regressionCI.RegressionCI (optional) |
ci_mm |
Regression | R MXM::ci.mm via rpy2 (optional) |
cmiknn |
Nearest Neighbor | tigramite.independence_tests.cmiknn.CMIknn (optional) |
cmiknn_mixed |
Nearest Neighbor | tigramite CMIknnMixed wrapper (optional) |
mcmiknn |
Nearest Neighbor | Vendored indeptests.mCMIkNN from hpi-epic/mCMIkNN (no install required) |
kci |
Kernel | causal-learn Python KCI |
rcit |
Kernel | R RCIT::RCIT via rpy2 (optional) |
rcot |
Kernel | R RCIT::RCoT via rpy2 (optional) |
gcm |
Machine-Learning-Based | pycomets GCM with random forest regression (optional) |
wgcm |
Machine-Learning-Based | pycomets WGCM with random forest regression (optional) |
pcm |
Machine-Learning-Based | pycomets PCM with random forest regression (optional) |
disc_chisq |
Adapter Strategies | Native citests equal-frequency discretization + causal-learn Chi-Square |
disc_gsq |
Adapter Strategies | Native citests equal-frequency discretization + causal-learn G-Square |
dummy_fisherz |
Adapter Strategies | Native citests one-hot encoding + causal-learn Fisher-Z aggregation |
hartemink_chisq |
Adapter Strategies | R bnlearn Hartemink discretization + causal-learn Chi-Square (optional) |
Module Layout (Survey Taxonomy)
citests/tests/partial_correlation_tests.pycitests/tests/contingency_table_tests.pycitests/tests/regression_tests.pycitests/tests/nearest_neighbor_tests.pycitests/tests/kernel_tests.pycitests/tests/ml_based_tests.pycitests/tests/adapter_tests.py
For detailed documentation on each test and its parameters, please see our full documentation page HERE.
Acknowledgements
citests is a toolkit-style assembly. Several tests are adapters over
upstream implementations:
- KCI wraps
causallearn.utils.cit.KCIfrom causal-learn (MIT) under the optional[causallearn]extra. - disc_chisq / disc_gsq / dummy_fisherz route discretised / one-hot data through causal-learn's Chi-Square, G-Square, and Fisher-Z back-ends respectively.
- mCMIkNN is vendored verbatim from
hpi-epic/mCMIkNN (MIT). See
citests/_vendor/NOTICE.mdfor the full attribution including authors, paper citation, and vendored revision SHA. - hartemink_chisq uses
bnlearn(R) for Hartemink discretisation viarpy2, paired with causal-learn's Chi-Square test. - RCIT / RCoT wrap the R RCIT
package via
rpy2under the optional[r]extra. - CiMM wraps the
ci.mmtest from the R MXM package (GPL-2+) viarpy2under the optional[r]extra; MXM is invoked rather than vendored, so the GPL boundary remains in the user's R installation. - CMIknn / RegressionCI wrap
tigramite (GPL-3) under
the optional
[tigramite]extra; tigramite is invoked at the user's installation rather than vendored, so the GPL-3 boundary remains in the user's environment.
Native citests tests (FisherZ, Spearman, χ²/G², regression-based) are
independent implementations. Cross-package interop with cbcd is via
the structural cbcd.CITest Protocol — neither package imports the
other.
License
Metadata
Release files for citests 0.1.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 | Actions |
|---|---|---|---|---|
| citests-0.1.0.tar.gz | 73.8 kB | With provenance | Details for citests-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| citests-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for citests-0.1.0-py3-none-any.whl |
Total release size: 106.8 kB
Release files / citests-0.1.0.tar.gz
| Download URL | citests-0.1.0.tar.gz |
|---|---|
| Size | 73.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0faa18b94a53d0fff23d42f1afef5881ff2258b31ec90f6e497af222a1ac4f4
|
|
BLAKE2b-256 checksum How to use checksums |
d5b6046fbcded7f2c7811ebcf13a9fc8199c80de986f895d58d15b0256e1f8f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 17, 2026.
Transparency logRelease files / citests-0.1.0-py3-none-any.whl
| Download URL | citests-0.1.0-py3-none-any.whl |
|---|---|
| Size | 33.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8081429e88c5505c604fd74761415559a96cd70674c2e959d9e677d177b766cd
|
|
BLAKE2b-256 checksum How to use checksums |
75b49a2ddfa3e73f1796c1f925f3de67958979f6100b8a262d83bd4f8d17ef3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 17, 2026.
Transparency logSecurity for citests 0.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for citests-0.1.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 May 17, 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.