Skip to main content

CI PyPI Version Docs

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.

Documentation

Build the API documentation with:

python -m pip install --group docs -e .
make -C docs html

Metadata

Release files for madng-tpsa 0.3.2

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

Source distribution (sdist)

Source distribution for madng-tpsa 0.3.2
File Size Uploaded
madng_tpsa-0.3.2.tar.gz 97.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for madng-tpsa 0.3.2
File
madng_tpsa-0.3.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
madng_tpsa-0.3.2-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
madng_tpsa-0.3.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
madng_tpsa-0.3.2-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
madng_tpsa-0.3.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
madng_tpsa-0.3.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
madng_tpsa-0.3.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
madng_tpsa-0.3.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 148.0 MB

Release files / madng_tpsa-0.3.2.tar.gz

Download URL madng_tpsa-0.3.2.tar.gz
Size 97.1 MB
Tags Source
SHA-256 checksum
How to use checksums
bcded827b436de5823f74c158c20ad569ecb53b7d9adb9449b7c046054140150
BLAKE2b-256 checksum
How to use checksums
3bbd63d14244d8dd8ba608e83d50921c295d059e252f6b8459b8214964ab5bcf
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL madng_tpsa-0.3.2-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
e1e6186fae30c47d9085c8c8c942d32b7483f79dfee072003e6eaabfb95ca80f
BLAKE2b-256 checksum
How to use checksums
cd17de317d837fda6b387dfbf4e8f08e81723e96d4434ecdd364fee8d896291d
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.2-cp314-cp314-macosx_11_0_arm64.whl

Download URL madng_tpsa-0.3.2-cp314-cp314-macosx_11_0_arm64.whl
Size 382.0 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e6aa72dfc74bc58ce8538d92ea34bf2eede3d3ff738ebbf5eeee0568c9aecae3
BLAKE2b-256 checksum
How to use checksums
91dac611faee38ba36189fa9bc46fa0e9b1ec405db79ef0afc3d0bb14cedd586
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL madng_tpsa-0.3.2-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
f58628b6ead12dd1a0405e6c9c5a676ade6d59dc9ad4f0dc523efe3df4547172
BLAKE2b-256 checksum
How to use checksums
550cd88118a3022bb2a10ceb318b5fde2532a901633a2ed729b82bbfe647e038
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.2-cp313-cp313-macosx_11_0_arm64.whl

Download URL madng_tpsa-0.3.2-cp313-cp313-macosx_11_0_arm64.whl
Size 382.0 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2e9b5c6e0729965d836b18474702bf5061660ba40bcfffee500a65d906286cfc
BLAKE2b-256 checksum
How to use checksums
3be17e9077137cd61403040332e21d01fb323ab5da7ad012b06992b1ddb7c6b4
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL madng_tpsa-0.3.2-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
fc1f41ac86621a17f5c6694c9852a44312133615059eb27f392a65867d693a84
BLAKE2b-256 checksum
How to use checksums
6976fc56a0d4bb3dd8679a8e72883798a227cfd5d21819962fee6dbef42acd65
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL madng_tpsa-0.3.2-cp312-cp312-macosx_11_0_arm64.whl
Size 382.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
734c6a9b9b13e9af2e94b85fd9f452a8a4d12203faf033bbf770bde8f415ccda
BLAKE2b-256 checksum
How to use checksums
005afde08b531cae077d5aa14ecaa32120f4d2746b3f20c73e00a59d5c95d72a
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL madng_tpsa-0.3.2-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
1ded98bc9e6f20adb55e2de758d04b8b8b1ce61c68ac6caf76e2f3f81a359acc
BLAKE2b-256 checksum
How to use checksums
4c39aeb8398a838cbddfa4165ca8eb47d356a86c9c19feda3b1a4e8b4368bf44
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL madng_tpsa-0.3.2-cp311-cp311-macosx_11_0_arm64.whl
Size 382.0 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f6dd40f9cf8683312952da9bea62462caa312037fe3a03d92303555325eabf2f
BLAKE2b-256 checksum
How to use checksums
e860588c7cb6ab90e116ccc42ad61d342486544953a7efded2647ec29f03e831
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 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.2 This release

9 release files

0.3.1

9 release files

0.3.0

9 release files

0.2.0

9 release files

0.1.1

9 release files

0.1.0

7 release files

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