madng-tpsa - GTPSA (truncated power series) for Python
This repository exposes the features of MAD-NG's GTPSA (Generalised Truncated Power Series
Algebra) through a Python interface. The package builds libmadng_tpsa.so on Linux or
libmadng_tpsa.dylib on macOS, and uses CFFI ABI mode to access the native functionality.
import numpy as np
import scipy
from madng_tpsa import Descriptor
d = Descriptor(variables=['x', 'y'], order=3)
x, y = d.vars()
f = x * x + 2.0 * y
# Inspect!
f # => Tpsa({(0, 1): 2.0, (2, 0): 1.0})
f.format() # => '2 * y + x**2'
f.format('table') # => a Rich table showing all coefficients
# Basic operations
c = d.constant(42)
c.const_part # => 42
f.const_part # => 0
f.monomial_coeffs() # => {(0, 1): 2.0, (2, 0): 1.0}
f.derivative('y') # => Tpsa({(0, 0): 2.0})
f.grad() # => [0, 2]
# Compatible with Numpy protocol
np.sin(f) # => Tpsa({(0, 1): 2.0, (2, 0): 1.0, (0, 3): -1.3333333333333333})
scipy.special.wofz(f) # => ComplexTpsa({(0, 0): (1+0j), (0, 1): 2.256...j, (2, 0): 1.128...j, (0, 2): (-4+0j), (2, 1): (-4+0j), (0, 3): -6.018...j})
Through the xobjects entry point declared in pyproject.toml, the MAD-NG TPSA C API is
automatically made available to Xobjects, so projects built on Xobjects can reuse it without
much extra wiring, relying on madng-tpsa abstractions in the Python-side API.
Build
The project uses scikit-build-core and CMake:
git submodule update --init --recursive
pip install .
pip install -e .
python -m build
pip install -e . runs CMake and copies the generated shared library into
src/madng_tpsa/lib/, matching the installed wheel layout. MAD-NG headers copied into
src/madng_tpsa/include/ and platform shared libraries in src/madng_tpsa/lib/ are generated
artefacts and ignored by Git.
By default, CMake builds from the bundled madng/src checkout. To use another MAD-NG
source tree:
pip install . --config-settings=cmake.define.MADNG_SRC=/path/to/madng/src
Requirements: a C compiler, CMake, BLAS/LAPACK on Linux, and Accelerate on macOS.
Development
Install the package together with the development tools:
python -m pip install --group dev -e .
Enable the pre-commit hooks:
pre-commit install
The hooks run Ruff formatting/linting and Ty type checking. To run the same checks manually:
pre-commit run --all-files
Tests
pytest tests/
The tests exercise the standalone engine bindings; xtrack is not imported.
Metadata
Release files for madng-tpsa 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| madng_tpsa-0.3.1.tar.gz | 97.1 MB | Details |
Built distributions (wheels)
Total release size: 148.0 MB
Release files / madng_tpsa-0.3.1.tar.gz
| Download URL | madng_tpsa-0.3.1.tar.gz |
|---|---|
| Size | 97.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad2d4b04d736c6687181d7a8e8cbe86bc0e7f8bb9425ef4849de613e781cf256
|
|
BLAKE2b-256 checksum How to use checksums |
effcc387116ab332fe3431eb487579cf04e03f2e1977749d5995fae96c1efbbe
|
| 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 Sep 15, 2026.
Transparency logRelease files / madng_tpsa-0.3.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | madng_tpsa-0.3.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.3 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
2a695274df1d06c0aaabd829056876f72849d9d9c4717c4673abfcad31038f02
|
|
BLAKE2b-256 checksum How to use checksums |
2a81273862df9813b0164ca6708edd88bfce5ddebce56c6c095ee7ec209ba362
|
| 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 Sep 15, 2026.
Transparency logRelease files / madng_tpsa-0.3.1-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | madng_tpsa-0.3.1-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 381.0 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1a8a6fb52fdf238613493f0e0fb7bc68a876868b547e0daf13da5dc92ae7800c
|
|
BLAKE2b-256 checksum How to use checksums |
5f049bef379082d1dd7b384ed654b955e901a7dfb13c5f35c9c571125f52136c
|
| 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 Sep 15, 2026.
Transparency logRelease files / madng_tpsa-0.3.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | madng_tpsa-0.3.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.3 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
1121b24def2ed5122e71bebd7de6ea53beb24c85a029c997ffe57ca6b9dc3770
|
|
BLAKE2b-256 checksum How to use checksums |
23a710ae8794f6c9f586a5f7ec75f475190e915236f111d969bb7cb5b3bb644b
|
| 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 Sep 15, 2026.
Transparency logRelease files / madng_tpsa-0.3.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | madng_tpsa-0.3.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 381.0 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1c96c6e0d0acd1843c77d630182792a924b5326af88538ef00d3d764d1df74aa
|
|
BLAKE2b-256 checksum How to use checksums |
aebaee9245d106e6efc2dd230f84632a28abdc8379c4d6a997a3e79d9703d494
|
| 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 Sep 15, 2026.
Transparency logRelease files / madng_tpsa-0.3.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | madng_tpsa-0.3.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.3 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
5e0db9a542f5da3d87e7c4fe312c9a7073c6161d886fe63f7f690837916dcb72
|
|
BLAKE2b-256 checksum How to use checksums |
6709dafb747519ea40653aedd19562a7d7b496fdac955e62688d13c18ac171e2
|
| 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 Sep 15, 2026.
Transparency logRelease files / madng_tpsa-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | madng_tpsa-0.3.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 381.0 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
39d4949508915c87b52debd314502b11a51b17ac89e5af167356899007e51fd3
|
|
BLAKE2b-256 checksum How to use checksums |
346420ae5f71049cd1b1a04fa508a9684e90742591520445baa6113fee723d0d
|
| 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 Sep 15, 2026.
Transparency logRelease files / madng_tpsa-0.3.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | madng_tpsa-0.3.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.3 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
c27dbd1ab0a840912985fa6a608eaa3ba26fcbde390cb9ecd0437f8ed49b7a32
|
|
BLAKE2b-256 checksum How to use checksums |
9570640d63d7ee5c22264931352de0a1a575ba2d4ab0af44c96aa55989292000
|
| 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 Sep 15, 2026.
Transparency logRelease files / madng_tpsa-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | madng_tpsa-0.3.1-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 381.0 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a1d5b248534afd2cbce7075cfebd8083044e39f132e26013455f9bc9815dd6cb
|
|
BLAKE2b-256 checksum How to use checksums |
89717d0c7ffdd2aa03aad30e4fbda0189fdeab5380e177b4cbdc0a020152b14d
|
| 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 Sep 15, 2026.
Transparency log