lineshapes
Fast, composable optical-constant models for soft X-ray work. A model is a sum of analytic Kramers-Kronig-paired peaks (Gaussian, Lorentzian, Voigt, pseudo-Voigt) plus a continuum parameterized in beta (linear background + erf ionization steps) and a fixed continuum delta table (e.g. precomputed once with kkcalc). Rust core, Python bindings.
Evaluating a model returns delta + 1j*beta (n = 1 - delta + i beta) on an energy grid in eV.
Python
import numpy as np
from lineshapes import Model
E = np.linspace(900, 1000, 4001)
m = (Model()
.gaussian(e0=933.8, width=0.49, amp=4.1e-5) # width = 1/e half-width
.lorentzian(e0=936.0, gamma=0.3, amp=2e-5) # gamma = HWHM
.voigt(e0=938.3, sigma=0.7, gamma=0.2, amp=5e-5) # sigma = Gaussian std, gamma = HWHM
.pseudo_voigt(e0=955.0, fwhm=1.5, eta=0.4, amp=2e-5)
.continuum(bkg=3.6e-4, slope=-3.7e-7)
.step(e0=939.4, width=6.1, height=7.2e-5, decay=0.0)
.delta_table(E, delta_continuum) # fixed continuum delta (kkcalc)
.scale(1.0).shift(0.0))
n = m(E) # complex128, single core
n = m(E, parallel=True) # all cores
Builder methods mutate the model and return it; m.copy() gives an independent copy to extend.
Build once, call many times.
Conventions:
delta = H[beta], so delta < 0 below a resonance and > 0 above it. No mirror term at -E0.ampis the height of beta ate0for every lineshape.- The pseudo-Voigt is stored as one Lorentzian plus one Gaussian, so its delta is exact.
Documentation
make docs builds the site (mkdocs with the mkdocs_rsoxs theme) into site/; make docs-serve previews it.
The docs run the ZnPc and Alq3 examples (examples/, data shipped in lineshapes.datasets) to render their
figures; make docs-figures regenerates them. The theme needs Python >= 3.13, so docs use their own
environment (.venv-docs); the library itself supports Python >= 3.12.
Layout
crates/lineshapes/ pure-Rust crate `lineshapes` (no Python/pyo3): Model, Evaluator, special functions
crates/lineshapes-py/ thin PyO3 bindings crate -> lineshapes._core (not published to crates.io)
python/lineshapes/ Python package (re-exports, function API, type stubs)
docs/ examples/ tools/ mkdocs site, example scripts, data/docs generators
tests/ benchmarks/ prototypes/ pytest suite vs numpy reference, timings, figures
Each half stands alone: cargo add lineshapes for Rust only (feature parallel, on by default,
adds rayon), or pip install lineshapes for Python (bundles the compiled core). See
crates/lineshapes/README.md for Rust usage.
Development
cargo test --workspace --release # Rust unit, integration and doc tests
uv sync # builds the extension (release)
uv run --with maturin maturin develop --release --uv # rebuild after Rust changes
uv run pytest # precision + speed vs numpy reference
uv run python -m benchmarks.bench # timings
strip = false(workspace[profile.release]) is required: stripping corrupts the extension on this macOS toolchain ("mis-aligned LINKEDIT string pool").
Validation (tests/) compares against a pure-numpy reference (tests/reference/lineshapes_ref.py),
numerical Hilbert transforms, and kkcalc2 (pinned commit e750040) on a real Cu L-edge model.
Note that kkcalc2's output scales with its density argument. Use density=1.0.
Metadata
Release files for lineshapes 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lineshapes-0.1.0.tar.gz | 171.1 kB | With provenance | Details for lineshapes-0.1.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| lineshapes-0.1.0-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details for lineshapes-0.1.0-cp312-abi3-win_amd64.whl |
| lineshapes-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ x86-64 | Details for lineshapes-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| lineshapes-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ ARM64 | Details for lineshapes-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| lineshapes-0.1.0-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details for lineshapes-0.1.0-cp312-abi3-macosx_11_0_arm64.whl |
| lineshapes-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl | CPython 3.12 | abi3 | macOS 10.12+ x86-64 | Details for lineshapes-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl |
Total release size: 3.4 MB
Release files / lineshapes-0.1.0.tar.gz
| Download URL | lineshapes-0.1.0.tar.gz |
|---|---|
| Size | 171.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06699b0f90a0a66323c1927a85d6cf8df8ad3e536ff214ff346a6ccd26e4299a
|
|
BLAKE2b-256 checksum How to use checksums |
2f3db8affe122b1ece58c26d610f2bfb2e5412084386a58384663c6a3fc6dd37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 24, 2026.
Transparency logRelease files / lineshapes-0.1.0-cp312-abi3-win_amd64.whl
| Download URL | lineshapes-0.1.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 400.0 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
24250cb107a8120f001be899e45bf9348eec0c4e44af32db4657ca4d5e10aa87
|
|
BLAKE2b-256 checksum How to use checksums |
3ca96590a69975c3a826a4c5a0a21869d34d6bfb3951cf2f1c09f4ee2b40c164
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 24, 2026.
Transparency logRelease files / lineshapes-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | lineshapes-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 971.4 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
64511883bbc8a8ed9f913207d46d9b26208553fa040426ad39a82883618f2775
|
|
BLAKE2b-256 checksum How to use checksums |
f7d4fa4d37789368252daee703dfbdf39bfdd6cf4c3c7d597685b256f4c26707
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 24, 2026.
Transparency logRelease files / lineshapes-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | lineshapes-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 898.8 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
bef45dedf9ec5880c80866ed2c319d953b3c4210880e280c7fd4d58be304ec1a
|
|
BLAKE2b-256 checksum How to use checksums |
5129643f8c16083a3bc4974cf4b6b88c781c43e9816fb71be6c7e5f218618a37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 24, 2026.
Transparency logRelease files / lineshapes-0.1.0-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | lineshapes-0.1.0-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 500.2 kB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
44eb3bde4181690983811a9065f703ece14839467c273e391d1b53a41f135b64
|
|
BLAKE2b-256 checksum How to use checksums |
51ae161223487ca316cf7dbea061c444d12a061780dfa6bf272caae6782badce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 24, 2026.
Transparency logRelease files / lineshapes-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | lineshapes-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 507.1 kB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e6738f9ee71419c37ddf1ede9073fef545f94f5f63b4958b00e6f01ffd0fc25e
|
|
BLAKE2b-256 checksum How to use checksums |
cd6f75dafae9bc7945345c9f38bea5b7c29d94538746bdc055ab205a2e8d07be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 24, 2026.
Transparency logSecurity for lineshapes 0.1.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
All 6 files in this release have been uploaded with provenance metadata.
Attestation for lineshapes-0.1.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 24, 2026.
Transparency logA 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.