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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06bcd6216e585c0017684e1bc28aef1f16ac8cbcca4fbb242cfd0ac31d4a981d
|
|
| MD5 |
bb198510ebe7bdef0ad027014dc5de6c
|
|
| BLAKE2b-256 |
6767552f365f6725abb3b698d14ec1cd23439f1393e1474b8e258ec9cf4d114c
|
Provenance
The following attestation bundles were made for madng_tpsa-0.1.1.tar.gz:
Publisher:
release.yaml on babreufig/madng-tpsa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1.tar.gz -
Subject digest:
06bcd6216e585c0017684e1bc28aef1f16ac8cbcca4fbb242cfd0ac31d4a981d - Sigstore transparency entry: 2687588743
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type:
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
- Download URL: madng_tpsa-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 12.3 MB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e48773da4cec62ca1d40afd4719bb105f093046e860fca038cf68399f80cf71f
|
|
| MD5 |
1874d39c3affdd742f1483aafc380367
|
|
| BLAKE2b-256 |
15fb73975cb6c278cbaa36cb6503d747ec698a17c20097f797306de3e9c70962
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
e48773da4cec62ca1d40afd4719bb105f093046e860fca038cf68399f80cf71f - Sigstore transparency entry: 2687588764
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type:
File details
Details for the file madng_tpsa-0.1.1-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: madng_tpsa-0.1.1-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 367.8 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b82164a34321d40aebd6e65a6783deaf99afca982059986ddccc9dbc40366f46
|
|
| MD5 |
ba27e000e9c8907261616958ec27ec8b
|
|
| BLAKE2b-256 |
3214facdba4bba0a9703fbb5b79297a56a18d1f1c4e0eedab27a66e07a7d2232
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1-cp314-cp314-macosx_11_0_arm64.whl -
Subject digest:
b82164a34321d40aebd6e65a6783deaf99afca982059986ddccc9dbc40366f46 - Sigstore transparency entry: 2687588798
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type:
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
- Download URL: madng_tpsa-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 12.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc14798530ed1ccfa02b442ae98054c620d2810119f0f0756cdbe923fd9f025e
|
|
| MD5 |
8d82417777e558e9418e6496027d9df9
|
|
| BLAKE2b-256 |
389510529858a0d1505f96d22e682aca77ebf68479861aef47dc8d32c8c4c26a
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
dc14798530ed1ccfa02b442ae98054c620d2810119f0f0756cdbe923fd9f025e - Sigstore transparency entry: 2687588879
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type:
File details
Details for the file madng_tpsa-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: madng_tpsa-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 367.8 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5739a21f5de49522eb954ae8c5065c04a3967564127550fed9eeb1effd053abf
|
|
| MD5 |
34000a75065b1258ad800ae42f0a2cf7
|
|
| BLAKE2b-256 |
38c7f5f56f56eaac6da809bf72667ef18a58cd3c08b2a99d3779a88c44db1e22
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
5739a21f5de49522eb954ae8c5065c04a3967564127550fed9eeb1effd053abf - Sigstore transparency entry: 2687588830
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type:
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
- Download URL: madng_tpsa-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 12.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86f2add02442a9064d215c5bcb6e43d74f0e488d127f73a39fbe9a9fa90ea586
|
|
| MD5 |
d4a757ad29d785f438da7679ed589592
|
|
| BLAKE2b-256 |
422178a03ebe480a52a8ef0f912be2a1f5e18c90c07d0b26a9d0cfc45e4db746
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
86f2add02442a9064d215c5bcb6e43d74f0e488d127f73a39fbe9a9fa90ea586 - Sigstore transparency entry: 2687588812
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type:
File details
Details for the file madng_tpsa-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: madng_tpsa-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 367.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4f882fa7ac846e398ef9b4eab3400318b6a64edbd59ed683c8502e3f1a3b486
|
|
| MD5 |
aefc58c55289245de3e78ef7e39d2066
|
|
| BLAKE2b-256 |
a41284e23d245ad08c42ee2950ca1847a1c79659f7706f1534ff74acf3bcf336
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
a4f882fa7ac846e398ef9b4eab3400318b6a64edbd59ed683c8502e3f1a3b486 - Sigstore transparency entry: 2687588861
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type:
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
- Download URL: madng_tpsa-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 12.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
782b9a17308aae37a662c5c7611fc2988d561431e7b47ba67f2712741d5f911d
|
|
| MD5 |
e5292eba43ef7b4b88439c5e8a15ad7b
|
|
| BLAKE2b-256 |
070b4f6ddfec3637bffccdc27c9a3b3c60e169cc16ff993aa42fc16be923e1cf
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
782b9a17308aae37a662c5c7611fc2988d561431e7b47ba67f2712741d5f911d - Sigstore transparency entry: 2687588779
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type:
File details
Details for the file madng_tpsa-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: madng_tpsa-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 367.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a9961fad77c361b276b27ae76ab24239572b84733fce8c392d0de27aa8191d9
|
|
| MD5 |
bea1114228038db79bdc3ab1f20a2e63
|
|
| BLAKE2b-256 |
f44a25a01a448e964f1b7936c4c1ce39a475983b24c1a4377aa9ffcdd176086e
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
madng_tpsa-0.1.1-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
1a9961fad77c361b276b27ae76ab24239572b84733fce8c392d0de27aa8191d9 - Sigstore transparency entry: 2687588893
- Sigstore integration time:
-
Permalink:
babreufig/madng-tpsa@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/babreufig
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@2c2500d3198d722bfeba68b73ce05a8d3c8d8d57 -
Trigger Event:
push
-
Statement type: