Skip to main content

fftloggin

Differentiable FFTLog transforms built on JAX. The core API transforms one real, one-dimensional sample array at a time. Use JAX transformations for compilation, batching, and differentiation.

Full user guides and the API reference are available on Read the Docs.

Installation

uv add fftloggin
# or: pip install fftloggin

For the numerical accuracy expected by the Fortran reference cases, enable JAX 64-bit values before importing JAX or fftloggin:

export JAX_ENABLE_X64=1

The library does not change process-wide JAX configuration on import.

Transform a logarithmic grid

import jax
import jax.numpy as jnp
from fftloggin import BesselJKernel, forward, get_paired_grids, infer_dlog

r = jnp.geomspace(1e-2, 1e2, 128)
a = r * jnp.exp(-(r**2) / 2)
dlog = infer_dlog(r)  # eager spacing validation
kernel = BesselJKernel(mu=0.0)
log_kr = 0.0

r, k = get_paired_grids(r=r, log_kr=log_kr)
A = jax.jit(forward)(a, kernel, dlog=dlog, log_kr=log_kr)

log_kr is the logarithm of the product of the input and output grid centers. get_paired_grids accepts exactly one of r or k and always returns the pair in (r, k) order. To request the traditional low-ringing snap, calculate it explicitly and use the returned value for both the transform and the paired grid:

from fftloggin import lowring_log_kr

log_kr = lowring_log_kr(kernel, dlog=dlog, log_kr=0.0)
r, k = get_paired_grids(r=r, log_kr=log_kr)
A = forward(a, kernel, dlog=dlog, log_kr=log_kr)

The snap is piecewise constant in the requested log_kr. For fitting that parameter, use forward without snapping.

Batch and differentiate

mus = jnp.array([0.0, 1.0, 2.0])
batched = jax.jit(jax.vmap(lambda mu: forward(a, BesselJKernel(mu), dlog=dlog)))(mus)


def loss(mu):
    prediction = forward(a, BesselJKernel(mu), dlog=dlog)
    return jnp.sum((prediction - A) ** 2)


gradient = jax.grad(loss)(0.5)

The built-in kernels are JAX pytrees. forward and inverse require scalar dlog, bias, and log_kr; map over any of them with jax.vmap. Call validate_parameters(kernel, dlog=..., bias=..., log_kr=...) outside JAX transformations for eager value and Mellin-domain checks.

Development and reference comparison

uv sync --all-groups
uv run ruff check .
JAX_ENABLE_X64=1 uv run pytest tests/test_benchmark.py --run-benchmarks

For opt-in runtime checks of the jaxtyping annotations during development, install the development dependencies, then run tests with FFTLOGGIN_RUNTIME_TYPECHECK=1 uv run pytest. This uses beartype to check shapes and dtypes while JAX traces functions; the checks are absent from normal imports and compiled execution. The flag only enables checks when its value is exactly 1.

The benchmark compares with 216 generated reference outputs from the original Fortran FFTLog program. The files are ignored by Git. To generate them, install gfortran and run uv run python scripts/generate_benchmarks.py. The previous API's tests live in tests/legacy/ for the separate test-suite redesign.

References

  • Hamilton, A. J. S. (2000), Uncorrelated modes of the non-linear power spectrum, astro-ph/9905191.
  • Assassi, V., Simonović, M., and Zaldarriaga, A. (2017), Efficient Evaluation of Cosmological Angular Statistics, arXiv:1705.05022.

Metadata

Release files for fftloggin 0.6.0

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

Source distribution (sdist)

Source distribution for fftloggin 0.6.0
File Size Uploaded Provenance Actions
fftloggin-0.6.0.tar.gz 17.4 kB With provenance Details for fftloggin-0.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 38.3 kB

Release files / fftloggin-0.6.0.tar.gz

Download URL fftloggin-0.6.0.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3dc77c1b29586529ef5eb2b254e5c6e9dcbfb2cb0d23aa367ce89177b04aeb72
BLAKE2b-256 checksum
How to use checksums
92904d126865440b51b74b77ea61fe47de275b5e283a845f03a69785092699be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 1, 2026.

Transparency log

Release files / fftloggin-0.6.0-py3-none-any.whl

Download URL fftloggin-0.6.0-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
385e6bbc47394e38aaada7fe4f28fc5f76a34095f27a84a934fd4b105c80a40d
BLAKE2b-256 checksum
How to use checksums
eee72b3c2cf19db4a78c501eb7b54ce37ddf76655bcaf26e49e8e1a3f3dce8b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 1, 2026.

Transparency log

Security for fftloggin 0.6.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fftloggin-0.6.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 Oct 1, 2026.

Transparency log

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