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.3.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.3.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.3.0-cp314-cp314-macosx_11_0_arm64.whl (381.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

madng_tpsa-0.3.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.3.0-cp313-cp313-macosx_11_0_arm64.whl (381.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

madng_tpsa-0.3.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.3.0-cp312-cp312-macosx_11_0_arm64.whl (381.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

madng_tpsa-0.3.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.3.0-cp311-cp311-macosx_11_0_arm64.whl (381.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: madng_tpsa-0.3.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.3.0.tar.gz
Algorithm Hash digest
SHA256 ec3f3c4e5a8284260198de53d82bf66717efd866ac3d1790d4514653b1129ff3
MD5 ec162c0276810fdafc29b12a5024e718
BLAKE2b-256 5d6a3b2da39f6a15838cf3dc854aacea5237b4890a8323ca02787bbc71d30f6f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for madng_tpsa-0.3.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea6622cd92b5792128f0974728d5b31953e2faa4ed14fbfaeef6918d636ab23b
MD5 3d5d3a40227d39c2a59dec9d247ddc93
BLAKE2b-256 64cc97b15862ea09c325892ad69068b1eac57b691716147d2c61d28a0c5d4382

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for madng_tpsa-0.3.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4723d2acfb0e6c3929cebe2bb06a066cb951ddaf560f91006488b7c8eb325d42
MD5 b59deb1ccc341c5e44291282f4b5687c
BLAKE2b-256 c7ba44c8aacf6ded7a86298119545f090573ff6749b5f3ebb6424fd2fed85210

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for madng_tpsa-0.3.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 37ac1471017d6f215b888c120449423b5076b00889cd2c57ed1486ce8de50340
MD5 106bdc5c2fa5cb194ab8aabbca391b54
BLAKE2b-256 4d0389ed3880c4c8c71a77c70e31b3af9e2b13e586038f39874d1aba7912c219

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for madng_tpsa-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38a90aea83ae016e30c4e07b8c3a49a106bb176a10f94fe34f33ea81b87631d5
MD5 1da2f5391a2c3e25737e7c1c57682d4e
BLAKE2b-256 0306eb9677af58161b919bf193dad79f639e9e7b94d86ca6fe0ec0018ccea85c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for madng_tpsa-0.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 93180c5ab3e588fb2e61dac865dffc1e6359465a222289fcaaa18a18bf0401c9
MD5 d03b8e758eff3e43e8f7437d96958e9a
BLAKE2b-256 df78e430a5c77087dda74863701a9211f56788b8c144a8c2bf4c8f6e34c6b4bc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for madng_tpsa-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e28828107e95b3f782bae558d46eaf5d941c058f7871be7f408e749d639b06c
MD5 5a375cd8d80e97f9845de173928b6b53
BLAKE2b-256 7213eca15c6d9abe9564c9839e1b057180a6d31ba3fca581b8c266c5fa34c9f1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for madng_tpsa-0.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 457265b4ccf39afb029d2d0aed463b8783f5b65e318c66f9c36e6c9ee9c18f1c
MD5 7651c24a781b350a9a45702db8b7b059
BLAKE2b-256 4b722ebf3b898ab4de5e040c95f5278f502e596ce10ee90bf583a1efbb765c95

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for madng_tpsa-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17b27a5971f4533cfad812e15426b5df0bc72b0b20102005a93cb115ba5ae8bf
MD5 9805e1bdafe61777f5068bdcecd7fcde
BLAKE2b-256 5417e54a3830d7c6a0e58f8f7616849e592ca71ac181130b34541c3e89c76c55

See more details on using hashes here.

Provenance

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

This release

0.3.0 This release

9 files

0.2.0

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