Skip to main content
logo

halox

JAX-powered Python library for differentiable dark matter halo property and mass function calculations.

License: MIT tests coverage PyPi version Documentation Status arXiv

Installation

halox can be installed via pip:

pip install halox

For a manual installation, see the documentation pages.

Features

halox offers a JAX-powered differentiable and GPU-accelerated implementation of some widely used properties of dark matter halos and large-scale structure, including:

  • halox.halo: Radial profiles of dark matter halos following Navarro-Frenk-White (NFW) and Einasto distributions;
  • halox.cm: Mass-concentration relations of dark matter halos;
  • halox.lss: Large-scale structure ($$\sigma(R)$$, $$\sigma(M)$$);
  • halox.hmf: The halo mass function, quantifying the abundance of dark matter halos in mass and redshift and its dependence on cosmological parameters;
  • halox.bias: The halo bias;
  • halox.emus: A neural-network emulator for $$\sigma(M)$$, providing up to 95× speedup over the analytic calculation while remaining differentiable and GPU-accelerated.

All functions support jax.jit, jax.vmap, and jax.grad. Halo masses, redshifts, and cosmological parameters are all valid differentiation targets. All properties support cosmology dependence using jax-cosmo. More information on the modules available can be found in the documentation pages.

Quick start

import jax
import jax.numpy as jnp
from halox import cosmology, hmf, halo

jax.config.update("jax_enable_x64", True)  # optional

cosmo = cosmology.Planck18()

# Halo mass function at z = 0.5
M = jnp.logspace(13, 15, 100)
dn_dlnM = hmf.tinker08_mass_function(M, 0.5, cosmo)

# NFW profile
h = halo.nfw.NFWHalo(1e14, 5.0, 0.0, cosmo)
r = jnp.logspace(-1, 1, 50)
rho = h.density(r)

# Derivative w.r.t. halo mass
dhmf_dM = jax.grad(lambda M: hmf.tinker08_mass_function(M, 0.5, cosmo))(1e14)

Units

All input/output units for halox functions are reported in docstrings. Units are assumed to be in proper coordinates (not comoving) and include factors of little h.

Testing

All functions available in halox are validated against existing, non-JAX-based software, and a 100% coverage threshold is enforced. Cosmology calculations are validated against Astropy for varying cosmological parameters and redshifts. Other quantities are validated against Colossus or gala for varying halo masses, redshifts, critical overdensities, and cosmological parameters. These tests are included in the automatic CI/CD pipeline; a visual comparison is also included in the documentation.

Documentation

For more detail on the code and features, please visit our documentation pages.

Contributing

Contributions are welcome! See CONTRIBUTING.md for development setup, code conventions, and the pull-request process.

Citation

If you use halox for your research, please cite the original paper:

@ARTICLE{2025arXiv250922478K,
       author = {{K{\'e}ruzor{\'e}}, Florian},
        title = "{halox: Dark matter halo properties and large-scale structure calculations using JAX}",
      journal = {arXiv e-prints},
     keywords = {Instrumentation and Methods for Astrophysics, Cosmology and Nongalactic Astrophysics},
         year = 2025,
        month = sep,
          eid = {arXiv:2509.22478},
        pages = {arXiv:2509.22478},
          doi = {10.48550/arXiv.2509.22478},
archivePrefix = {arXiv},
       eprint = {2509.22478},
 primaryClass = {astro-ph.IM},
}

Metadata

Release files for halox 2.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for halox 2.1.1
File Size Uploaded Provenance Actions
halox-2.1.1.tar.gz 1.5 MB Without provenance Details for halox-2.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for halox 2.1.1
File Interpreter ABI Platform Actions
halox-2.1.1-py3-none-any.whl Python 3 none any Details for halox-2.1.1-py3-none-any.whl

Total release size: 1.5 MB

Release files / halox-2.1.1.tar.gz

Download URL halox-2.1.1.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
1ab1b3c2a26a3b20851467679256adcc2cfcd5f5fa2fbdf9c9e8e108f3eb2910
BLAKE2b-256 checksum
How to use checksums
1544f1c3ddf70c81b56b0a562a964089fe28c538abfebb906d55ee4d75d75318
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / halox-2.1.1-py3-none-any.whl

Download URL halox-2.1.1-py3-none-any.whl
Size 69.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdcd581d0ba674910bfb1e43b0be99dc088cb792a68034a46258b667eaac00ec
BLAKE2b-256 checksum
How to use checksums
453f11b187eff7a49293a158938efc404d4732dfa25c296fb44cc898cdd00fd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for halox 2.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page