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.2.tar.gz (40.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.2-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cornetto-0.2.2.tar.gz
  • Upload date:
  • Size: 40.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.2.tar.gz
Algorithm Hash digest
SHA256 318b62b126b45523335b820f0fcdff69ef75438a6c11545ef6a663862f257e21
MD5 89213bd20afbaef0e8acc7bd4be2b6ad
BLAKE2b-256 28e7a7de8f9a83e5bd35eefea509e73bfba9b852a3158259dc9e3c34633f5fee

See more details on using hashes here.

Provenance

The following attestation bundles were made for cornetto-0.2.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: cornetto-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 36.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 19778e0bf90ed2a10d68a4f8044cfe3421c8f7f60671d6ba837331d6f508caae
MD5 adcd534150c6a529731a02a51b178133
BLAKE2b-256 39c940c5684f7a82faeae20b3abcfa4ebcf46042819c6725f94808bb04246404

See more details on using hashes here.

Provenance

The following attestation bundles were made for cornetto-0.2.2-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