pycopa is a thin, user-friendly Python wrapper around the Fortran copa library. It exposes copa’s ensemble MCMC samplers and convenient I/O helpers to the Python ecosystem so you can:
- call copa samplers from Python,
- read / write the binary chain outputs (NumPy-friendly
.npyblobs), - combine Fortran speed with NumPy / SciPy / plotting tools for analysis.
pycopa is intended for researchers and engineers who want to run copa’s high-performance samplers from Python (for example inside notebooks, pipelines, or analysis scripts).
pycopa is built on top of the original Fortran copa library, which provides efficient implementations of ensemble Markov Chain Monte Carlo (MCMC) samplers. The underlying package is available via the Fortran Package Manager (fpm). See the repository: copa
pycopa is licensed under the GNU General Public License v3 (GPLv3).
If you use copa in academic work, please cite the accompanying paper on evortran:
[arXiv:2507.06082]: Thomas Biekötter (IFT, Madrid), evortran: a modern Fortran package for genetic algorithms with applications from LHC data fitting to LISA signal reconstruction, SciPost Phys. Codebases 64 (2026)
@article{Biekotter:2025gkp,
author = {Biek{\"o}tter, Thomas},
title = "{evortran: A modern Fortran package for genetic algorithms with applications from LHC data fitting to LISA signal reconstruction}",
eprint = "2507.06082",
archivePrefix = "arXiv",
primaryClass = "hep-ph",
reportNumber = "IFT-UAM/CSIC-25-76",
doi = "10.21468/SciPostPhysCodeb.64",
journal = "SciPost Phys. Codeb.",
volume = "64",
pages = "1",
year = "2026"
}Prerequisites
- The
gfortranFortran compiler. - Fortran Package Manager (fpm) version ≥ 0.13.0 available on
PATH. - Python 3.6+ and
pip. make(the provided Makefile target uses it).patchelf(used to embed rpaths into the installed wheel so users normally don't have to setLD_LIBRARY_PATH).
Quick install (recommended)
Clone the repository and navigate to the pycopa directory:
git clone https://github.com/thomasbiekoetter/pycopa.git
cd pycopaInstall the package with:
make pycopaTo force a rebuild:
make clean && make pycopaInstall in debug mode (slower)
pycopa can be installed in debug mode which contains additional runtime checks and without compiler optimizations:
make pycopa-debugpycopa includes an example program to demonstate the usage and to validate that the installation has been successful. To execute the example, navigate to the python/test folder and run the python script:
cd python/test/rosenbrock/single
python rosenbrock.pyThis program samples the two-dimensional Rosenbrock function. The MCMC chains and the final walkers at completion are stored in the numpy arrays chains and walkers, respectively.