Skip to main content

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)  # => Tpsa({(0, 0): 1.0, (0, 2): -4.0, (2, 1): -4.0})

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

madng_tpsa-0.1.1.tar.gz (97.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

madng_tpsa-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

madng_tpsa-0.1.1-cp314-cp314-macosx_11_0_arm64.whl (367.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

madng_tpsa-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

madng_tpsa-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (367.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

madng_tpsa-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

madng_tpsa-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (367.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

madng_tpsa-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

madng_tpsa-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (367.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file madng_tpsa-0.1.1.tar.gz.

File metadata

  • Download URL: madng_tpsa-0.1.1.tar.gz
  • Upload date:
  • Size: 97.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for madng_tpsa-0.1.1.tar.gz
Algorithm Hash digest
SHA256 06bcd6216e585c0017684e1bc28aef1f16ac8cbcca4fbb242cfd0ac31d4a981d
MD5 bb198510ebe7bdef0ad027014dc5de6c
BLAKE2b-256 6767552f365f6725abb3b698d14ec1cd23439f1393e1474b8e258ec9cf4d114c

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1.tar.gz:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file madng_tpsa-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e48773da4cec62ca1d40afd4719bb105f093046e860fca038cf68399f80cf71f
MD5 1874d39c3affdd742f1483aafc380367
BLAKE2b-256 15fb73975cb6c278cbaa36cb6503d747ec698a17c20097f797306de3e9c70962

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file madng_tpsa-0.1.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.1.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b82164a34321d40aebd6e65a6783deaf99afca982059986ddccc9dbc40366f46
MD5 ba27e000e9c8907261616958ec27ec8b
BLAKE2b-256 3214facdba4bba0a9703fbb5b79297a56a18d1f1c4e0eedab27a66e07a7d2232

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file madng_tpsa-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dc14798530ed1ccfa02b442ae98054c620d2810119f0f0756cdbe923fd9f025e
MD5 8d82417777e558e9418e6496027d9df9
BLAKE2b-256 389510529858a0d1505f96d22e682aca77ebf68479861aef47dc8d32c8c4c26a

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file madng_tpsa-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5739a21f5de49522eb954ae8c5065c04a3967564127550fed9eeb1effd053abf
MD5 34000a75065b1258ad800ae42f0a2cf7
BLAKE2b-256 38c7f5f56f56eaac6da809bf72667ef18a58cd3c08b2a99d3779a88c44db1e22

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file madng_tpsa-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 86f2add02442a9064d215c5bcb6e43d74f0e488d127f73a39fbe9a9fa90ea586
MD5 d4a757ad29d785f438da7679ed589592
BLAKE2b-256 422178a03ebe480a52a8ef0f912be2a1f5e18c90c07d0b26a9d0cfc45e4db746

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file madng_tpsa-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a4f882fa7ac846e398ef9b4eab3400318b6a64edbd59ed683c8502e3f1a3b486
MD5 aefc58c55289245de3e78ef7e39d2066
BLAKE2b-256 a41284e23d245ad08c42ee2950ca1847a1c79659f7706f1534ff74acf3bcf336

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file madng_tpsa-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 782b9a17308aae37a662c5c7611fc2988d561431e7b47ba67f2712741d5f911d
MD5 e5292eba43ef7b4b88439c5e8a15ad7b
BLAKE2b-256 070b4f6ddfec3637bffccdc27c9a3b3c60e169cc16ff993aa42fc16be923e1cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file madng_tpsa-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a9961fad77c361b276b27ae76ab24239572b84733fce8c392d0de27aa8191d9
MD5 bea1114228038db79bdc3ab1f20a2e63
BLAKE2b-256 f44a25a01a448e964f1b7936c4c1ce39a475983b24c1a4377aa9ffcdd176086e

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.1.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yaml on babreufig/madng-tpsa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.0

9 files

0.2.0

9 files

This release

0.1.1 This release

9 files

0.1.0

7 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