Skip to main content

Fast, smooth corner plots for MCMC chains.

Project description

cornetto

Tests Coverage License: MIT PyPI Built with Claude

Fast, smooth corner plots for MCMC chains.

[!NOTE] Early release - cornetto is built for research use and works well for everyday analysis, but the API may still evolve and some features are still maturing. Feedback and contributions are very welcome.

Cornetto takes a dict[str, array] of posterior samples and produces publication-ready corner plots. Under the hood it uses KDExpress - a JAX-based FFT-KDE library - so contours are smooth and rendering stays fast even at 50k+ samples.

cornetto corner plot

Install

pip install cornetto

Requires Python ≥ 3.10, NumPy, Matplotlib, SciPy, and KDExpress.

Usage

import numpy as np
from cornetto import corner

# data is a plain dict: parameter name → 1-D sample array
data = {
    "mass_1": chain["mass_1"],   # shape (N_samples,)
    "mass_2": chain["mass_2"],
    "chi_eff": chain["chi_eff"],
}

fig, axes = corner(
    data,
    labels={"mass_1": r"$m_1\,[M_\odot]$",
            "mass_2": r"$m_2\,[M_\odot]$",
            "chi_eff": r"$\chi_{\mathrm{eff}}$"},
    truths={"mass_1": 35.6},
    chain_labels=["GW200129"],
)
fig.savefig("posterior.pdf", bbox_inches="tight")

Multiple chains (e.g. two events, or prior vs posterior) are just 2-D arrays:

data = {
    "mass_1": np.stack([chain_A["mass_1"], chain_B["mass_1"]]),  # (2, N)
    "mass_2": np.stack([chain_A["mass_2"], chain_B["mass_2"]]),
}
corner(data, chain_labels=["GW150914", "GW190521"])

For fast iteration during analysis, quick_corner skips KDE entirely:

from cornetto import quick_corner
fig, axes = quick_corner(data)   # histograms only, sub-second

Documentation

Full guide, API reference, and benchmarks at cornetto.readthedocs.io.

License

MIT - see LICENSE.

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

cornetto-0.2.1.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

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

cornetto-0.2.1-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file cornetto-0.2.1.tar.gz.

File metadata

  • Download URL: cornetto-0.2.1.tar.gz
  • Upload date:
  • Size: 39.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cornetto-0.2.1.tar.gz
Algorithm Hash digest
SHA256 95955a10eecf705701440daf6a6412c09602c76e517bfbb341c6b785b3de9d92
MD5 5756f93b61e7104f68f3cd685e2e71c5
BLAKE2b-256 3f095f810376733a8f03741cd0048f6475f2177e99349e49ed45a7e34b361ba9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cornetto-0.2.1.tar.gz:

Publisher: publish.yml on nicoborghi/cornetto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cornetto-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cornetto-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cornetto-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f36000fba99fd509cb840495f277f88c9bfaaa19a7e1770d9c9cf8d83d5932bb
MD5 2d17b225ffa0374d08979c6a965e9356
BLAKE2b-256 ec377b767d3f6cc54df8dffa40f9dd031c386a4a7dbdc0479e0d18f31372f731

See more details on using hashes here.

Provenance

The following attestation bundles were made for cornetto-0.2.1-py3-none-any.whl:

Publisher: publish.yml on nicoborghi/cornetto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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