Registry / data / dcor
library0.7pypypiunverified

dcor is a Python library that provides efficient implementations of distance correlation and energy statistics, powerful tools for measuring dependence and performing two-sample tests. It supports various statistical tests including independence testing and two-sample testing. Currently at version 0.7, it is actively maintained with regular updates and a focus on numerical stability and performance.

pip install dcor
INSTALL
IMPORT
SIG · DCOR
D
dcor
datapythonv0.7
Install
10.9s avg
Import
41991ms
Disk
426MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 11.05s
py 3.11
✕ build_error
✓ 10.95s
py 3.12
✕ build_error
✓ 10.85s
py 3.13
✕ build_error
✓ 10.85s
py 3.9
✕ build_error
✕ timeout
426MB installed
● package 426MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

distance_correlation
✓ from dcor import distance_correlation
✗ from dcor import get_distance_correlation
The function was renamed in a previous major version for clarity.
energy_distance
✓ from dcor import energy_distance
independence_test
✓ from dcor import independence_test

This quickstart demonstrates how to calculate distance correlation, energy distance, and perform an independence test using dcor. It initializes sample NumPy arrays and applies the main functions, printing their results.

import numpy as np import dcor # Example data x = np.array([1, 2, 3, 4, 5]) y = np.array([1, 2, 3, 4, 5]) z = np.array([5, 4, 3, 2, 1]) w = np.array([1, 2, 3, 4, 6]) # Slightly different for energy_distance # Calculate distance correlation dc_xy = dcor.distance_correlation(x, y) dc_xz = dcor.distance_correlation(x, z) print(f"Distance correlation (x, y): {dc_xy:.4f}") print(f"Distance correlation (x, z): {dc_xz:.4f}") # Calculate energy distance ed_xw = dcor.energy_distance(x, w) print(f"Energy distance (x, w): {ed_xw:.4f}") # Perform independence test (requires bootstrapping) # Note: n_bootstraps should be sufficiently large for real analysis independence_p_value = dcor.independence_test(x, y, n_bootstraps=100).p_value print(f"P-value for independence test (x, y): {independence_p_value:.4f}")
Debug
Known issues
breakingThe function `dcor.get_distance_correlation` was renamed to `dcor.distance_correlation` in version 0.4.0. Using the old name will result in an AttributeError.
fix
Update your code to use `dcor.distance_correlation`.
affects: <0.4.0
gotchaInput data for all dcor functions (e.g., `distance_correlation`, `energy_distance`) must be NumPy arrays or objects convertible to them. Passing raw Python lists will lead to TypeError.
fix
Ensure your input data is converted to `numpy.ndarray` before passing it to dcor functions (e.g., `np.array(my_list)`).
affects: All versions
gotchaWhen performing statistical tests like `dcor.independence_test`, the `n_bootstraps` parameter is mandatory and determines the number of bootstrap samples used for p-value calculation. A too small value can lead to unreliable results.
fix
Always provide a sufficiently large `n_bootstraps` argument (e.g., 1000 or more for production) to `independence_test`.
affects: All versions
gotchaThe input arrays `x` and `y` must have the same number of observations (rows). If they represent samples, they must be from the same number of experimental units.
fix
Reshape or filter your data to ensure `x.shape[0] == y.shape[0]` before computing statistics like distance correlation or energy distance.
affects: All versions
Upgrade
Version history
0.7latest on PyPI · released Jan 17, 2026
Audit
Dependencies
numpyrequiredRequired for numerical operations and array handling.
scipyrequiredRequired for statistical functions and scientific computing.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
dcor — pip install dcor · libregistry