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

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.4
File Size Uploaded Provenance Actions
madng_tpsa-0.3.4.tar.gz 240.6 kB With provenance Details for madng_tpsa-0.3.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for madng-tpsa 0.3.4
File Actions
madng_tpsa-0.3.4-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for madng_tpsa-0.3.4-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
madng_tpsa-0.3.4-cp315-cp315-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 macOS 11.0+ ARM64 Details for madng_tpsa-0.3.4-cp315-cp315-macosx_11_0_arm64.whl
madng_tpsa-0.3.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for madng_tpsa-0.3.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
madng_tpsa-0.3.4-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for madng_tpsa-0.3.4-cp314-cp314-macosx_11_0_arm64.whl
madng_tpsa-0.3.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for madng_tpsa-0.3.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
madng_tpsa-0.3.4-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for madng_tpsa-0.3.4-cp313-cp313-macosx_11_0_arm64.whl
madng_tpsa-0.3.4-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 for madng_tpsa-0.3.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
madng_tpsa-0.3.4-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for madng_tpsa-0.3.4-cp312-cp312-macosx_11_0_arm64.whl
madng_tpsa-0.3.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for madng_tpsa-0.3.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
madng_tpsa-0.3.4-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for madng_tpsa-0.3.4-cp311-cp311-macosx_11_0_arm64.whl

Total release size: 63.9 MB

Release files / madng_tpsa-0.3.4.tar.gz

Download URL madng_tpsa-0.3.4.tar.gz
Size 240.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9285cd4748ddd4020bccac1a7ccf4ae901317d2ce4ee7c582021b9a2bc7f211a
BLAKE2b-256 checksum
How to use checksums
9ffc6f8e6500cb551498632fd6b862984d53b174b89c9e5fdc5f32fd8400ecec
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.4-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL madng_tpsa-0.3.4-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.15 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9326c009a9a96de1872067a3a4e14b1ec2183813aa76f70dfadb3f43d4c0f739
BLAKE2b-256 checksum
How to use checksums
863c51a0c0c4e5469aa80723a5f14c019e93ee1cc3918a8ed26a9a3ac6f613e2
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 21, 2026.

Transparency log

Release files / madng_tpsa-0.3.4-cp315-cp315-macosx_11_0_arm64.whl

Download URL madng_tpsa-0.3.4-cp315-cp315-macosx_11_0_arm64.whl
Size 382.0 kB
Tags CPython 3.15 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6d3121808aa02a3b9ef35ed2c2393af20afbb0f79dbc682b5011179213478376
BLAKE2b-256 checksum
How to use checksums
661a77d31608b70c2330df6a1e149fada7e25c13f226294e09297daa2d0fbad7
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 21, 2026.

Transparency log

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

Download URL madng_tpsa-0.3.4-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
bc20554b2154c6726ca7243788c082fb584abeeef191b97d677a199ebb57d76f
BLAKE2b-256 checksum
How to use checksums
bddd1bf641aa29c81dbe44afa8896be29b87f7205aaae689aefb7626c3ed6214
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 21, 2026.

Transparency log

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

Download URL madng_tpsa-0.3.4-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
71c95f3becb66d3d0547ac0d890fd69b0d45d895d674ff1c806ba4c940c14dad
BLAKE2b-256 checksum
How to use checksums
ec0d31166d31dea73c8dc6b85d513cca581341496b5c2574f9f2455f456bd999
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 21, 2026.

Transparency log

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

Download URL madng_tpsa-0.3.4-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
cc33da03fb56cf1406356f71f288fafcb8eea0df87e7c760301e3eed1f17c21b
BLAKE2b-256 checksum
How to use checksums
faf9237549d457b2951b3c900427bdb4e20631b52390d1f8531556ff8665c7b4
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 21, 2026.

Transparency log

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

Download URL madng_tpsa-0.3.4-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
89699f6f89030505ccd435dcb0c6683b235aacfed65d5fe6188823b25128f1f9
BLAKE2b-256 checksum
How to use checksums
423eea048b1a4a1ba7551579cd93b88216dac777709e7c798ae5caaf2a9003db
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 21, 2026.

Transparency log

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

Download URL madng_tpsa-0.3.4-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
58e058921632aa7ff437249e9aa36be4ab0e456abaaee23af3e522bb2242b350
BLAKE2b-256 checksum
How to use checksums
60f90eae75cdaefef55a33426307539d60355ae1bb9b92e960628cd48b094f7a
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 21, 2026.

Transparency log

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

Download URL madng_tpsa-0.3.4-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
44b70bf4540309cbde70715db85284f8a6cf7a44fd9cdb9e26a95ed0fb6465b9
BLAKE2b-256 checksum
How to use checksums
26225b36a7d90e6976c882b9fa46b306fcfb1775f4e94f6e9c7df3c3f8d73d83
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 21, 2026.

Transparency log

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

Download URL madng_tpsa-0.3.4-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
164e03788508a919c51aca2ebfd2a1a3bc92e50067c7de9039b7a829c90f4e18
BLAKE2b-256 checksum
How to use checksums
b0b0dd9f001d16e7d58aa1449e103a37648ab61f6628d96a7f93d9fb8c780f7a
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 21, 2026.

Transparency log

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

Download URL madng_tpsa-0.3.4-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
5f4f33cecd96caf0f3354e9e3f90453914ede85766f48adff418655b5538f80d
BLAKE2b-256 checksum
How to use checksums
26c14ab71a8da20d02c8bd7ccc0ffccb307cd9bebb1ff9b10ebedcc6933f8f69
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 21, 2026.

Transparency log

Security for madng-tpsa 0.3.4

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 11 files in this release have been uploaded with provenance metadata.

Select from 11 files

Attestation for madng_tpsa-0.3.4.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 21, 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