acldpy
Summary
This Python 3 package assigns letters to indicate statistically significant differences between treatments following pairwise comparisons. It strives to be compatible with all major Python statistics libraries.
acldpy = agnostic compact letter display for Python
Users conduct their statistical test with the library of their choice. Then, they pass their result to acldpy. The package implements algorithms that were described by Piepho and coworkers [1,2].
Installation
Install from PyPI test server:
pip install acldpy
Basic usage
To calculate the cld, you need three arguments.
- List of all first treatment names used in the pairwise comparisons.
- List of all second treatment names used in the pairwise comparisons.
- List of the p-values associated with each comparison.
Generally, one's input should follow this structure: i-th entry of p_values corresponds to the p-value for the comparison between the i-th entry in first_treatments and the i-th entry in second_treatments:
first_treatments = ["element 1", "element 1", "element 2"]
second_treatments = ["element 2", "element 3", "element 3"]
p_values = [0.9, 0.2, 0.01]
These three lists are passed to the run_cld function of the acldpy library. run_cld returns a dictionary where each key is a unique treatment and the value is its associated letters.
from acldpy import run_cld
cld = run_cld(first_treatments, second_treatments, p_values)
print (cld) # {'element 1': 'ab', 'element 2': 'b', 'element 3': 'a'}
Typically, these three required lists can be parsed from the returned object of a statistical test, as illustrated here with the Pingouin implementation of the Tukey-Kramer test.
import pingouin as pg
from acldpy import run_cld
penguins = pg.read_dataset("penguins") # Example dataset
tk_result = penguins.pairwise_tukey(dv='body_mass_g', between='species')
first_treatments, second_treatments, p_values = list(tk_result["A"]), list(tk_result["B"]), list(tk_result["p-tukey"])
cld = run_cld(first_treatments, second_treatments, p_values)
print (cld) # {'Adelie': 'b', 'Chinstrap': 'b', 'Gentoo': 'a'}
Besides these three lists, run_cld accepts two optional arguments:
alpha(float, default: 0.05): Significance level. Two treatments are considered significantly different if their p‑value is less ("<", not "=<"!) than alpha.letter_order(None | list, default: None): If set, a list containing all treatments in the order of which they should be assigned letters to. Often, one would like to assign the letters in ascending order of the treatment mean values.
from acldpy import run_cld
first_treatments = ["element 1", "element 1", "element 1", "element 2", "element 2", "element 3"]
second_treatments = ["element 2", "element 3", "element 4", "element 3", "element 4", "element 4"]
p_values = [0.08, 0.02, 0.01, 0.2, 0.04, 0.08]
mean_values = {"element 1": 1.2, "element 2": 2.8, "element 3": 3.2, "element 4": 4.0}
cld = run_cld(first_treatments, second_treatments, p_values) # default values for alpha and letter_order
print(cld) # {'element 1': 'c', 'element 2': 'bc', 'element 3': 'ab', 'element 4': 'a'}
mean_values_sorted = dict(sorted(mean_values.items(), key=lambda item: item[1]))
cld = run_cld(first_treatments, second_treatments, p_values, alpha=0.1, letter_order=mean_values_sorted.keys())
print(cld) # {'element 1': 'a', 'element 2': 'b', 'element 3': 'b', 'element 4': 'c'}
Extra Functionality
find_cld_columns is a helper function that accepts the result objects of the most common statistical tests and returns the three required lists.
from acldpy import find_cld_columns
first_treatments, second_treatments, p_values = find_cld_columns(penguins_tk_result, "pg_tk")
Currently it works with the output of the following tests:
result_type="pg_tk": pingouin's Tukey-Kramer testresult_type="stm_tk": statsmodels' Tukey-Kramer test
Development and Distribution
This package is provided under the MIT license. I (NJung) am its sole developer. I encourage you to report issues, when you find them under https://github.com/anyusernameisokay/acldpy/issues. If you do so, please provide your input data, and the error you receive.
Currently, the package is still under development, and I expect that some inputs lead to unhandled exceptions. However, the package will never silently return a wrong cld!
Furthermore, the following improvements are planned:
- Different and custom alternatives to the classical small letters.
- Optimal utilization of NumPy under the hood.
References
[1] J. Gramm, J. Guo, F. Hüffner, R. Niedermeier, H.-P. Piepho, and R. Schmid, “Algorithms for compact letter displays: Comparison and evaluation,” Computational Statistics & Data Analysis, vol. 52, no. 2, pp. 725–736, Oct. 2006, doi: 10.1016/j.csda.2006.09.035.
[2]
H.-P. Piepho, “An algorithm for a Letter-Based representation of
All-Pairwise comparisons,” Journal of Computational and Graphical Statistics,
vol. 13, no. 2, pp. 456–466, Jun. 2004,
doi: 10.1198/1061860043515.
I am not affiliated with the authors of these studies.
Links
Metadata
Release files for acldpy 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 | |
|---|---|---|---|---|
| acldpy-0.2.0.tar.gz | 14.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| acldpy-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.1 kB
Release files / acldpy-0.2.0.tar.gz
| Download URL | acldpy-0.2.0.tar.gz |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f259cbe6b3b42573d4e6f6f9995b5b7345cba3595e77701114880bb6aac55bcc
|
|
BLAKE2b-256 checksum How to use checksums |
15a43029c12e72066e153e52c4a6c45cf0b76574ef3e0390d238d0f25939d46c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 30, 2025.
Transparency logRelease files / acldpy-0.2.0-py3-none-any.whl
| Download URL | acldpy-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41433819b09167356e236de475485f4a060713f380ccfbf216c335e1418fc7c1
|
|
BLAKE2b-256 checksum How to use checksums |
51b0bf2fd7dd464782720aa99609e0025d17d6b79172539bb812cb697ef2c6ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 30, 2025.
Transparency logSecurity for acldpy 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 acldpy-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 Dec 30, 2025.
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.