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)  # => 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.

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.2.0.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.2.0-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.2.0-cp314-cp314-macosx_11_0_arm64.whl (380.3 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

madng_tpsa-0.2.0-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.2.0-cp313-cp313-macosx_11_0_arm64.whl (380.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

madng_tpsa-0.2.0-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.2.0-cp312-cp312-macosx_11_0_arm64.whl (380.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

madng_tpsa-0.2.0-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.2.0-cp311-cp311-macosx_11_0_arm64.whl (380.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: madng_tpsa-0.2.0.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.2.0.tar.gz
Algorithm Hash digest
SHA256 7112d29f73e55ea8091b963ceb98b741ab5f060d7f84548d63d59f6aeb55b826
MD5 d6099a47d65a0bb341debfd6afc869e3
BLAKE2b-256 ffdfc7014d6b867dd499df3c2bb32f70c423277aaa303b06a9d0fd2cee0fbb24

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0.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.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cb1fb0508624cad3dfcf928919ee5d411eb7be648d2aa1429afa19d95a17f8c9
MD5 c9259a1d38060da186386d8daf82fd8c
BLAKE2b-256 ecba4a11561e79b3fa5ea3c5d6bff4bc71cc615ef008044dc64271a94c83bdde

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0-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.2.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a382618719c6f38c496d7ccf5c3882b8e434430493553bbf49a009edec8e3e3c
MD5 29f03604da93c4b2d80ec33c97e1b7db
BLAKE2b-256 ab8b63b5448427fbbfebc908d6be56de33d3a429eb7f9ebb9bf436dd091fd6c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0-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.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 419295589a7f47eb95cd6f44ef213c6f0b352e276cc6c2d4d96632e783762c7f
MD5 391a217cbf6597af472c6c8d92ad9a63
BLAKE2b-256 775147c79b3a96ef1ec8c20ccb2146c7a56b2fab996300f5f8e76317bf5edfec

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0-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.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bed1fa9e6a41639a824cbefac71697ba889ee0e9f501aa3c8354cbfd8d380a4e
MD5 0b045639a4b1c3f524cdb36b54ae781c
BLAKE2b-256 dedbe43fcf60fa1c3749cb24cef3943e39d148e04d0215173040ae67bdde0b7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0-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.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc1fc26367e7b5c4f967d2c405466f4ed1387f663a751c6e9b1e44dec156f2b0
MD5 dbb8f10cefb09147a8b4d9193bcef905
BLAKE2b-256 32e7ae459df49d926ddf0ccf2bb8f0f528e1cd10826412d5a97a395751dd9e60

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0-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.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1415213e15c0c500f8127f2031fcfb355d7a439d105ed53f417b0ee5b4d335fa
MD5 c6a8fb15cd12f36668b9c5654c8edc3b
BLAKE2b-256 1f28fe5f388c4b2badf6762525452c9c4adf8b5a283edb187074f6faecf92568

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0-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.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3f476d341efae3e964425abb4d1a7ff5808938152dc450fbf5102161ce02d846
MD5 ea9b10d0e360f6471fd70332b0249ad4
BLAKE2b-256 432310c24f3efb2a9886dab2b3ff4d3bd7e9d76d4016d6c12413b888ce61daf6

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0-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.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for madng_tpsa-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b97243dfb259f620e912b626b683a580c4a2e36ea853f927c9473bfaf155120
MD5 240bd94af0d94f21a5de46b088df9854
BLAKE2b-256 c0f14bde4c5647c2571271ec482633765d3b8461c9fff351756acd8ea5aa0a6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for madng_tpsa-0.2.0-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

This release

0.2.0 This release

9 files

0.1.1

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