AlgebraX - Algebraic Primitives for Sparse Data Structures in Python
| Package |
|
| Code |
|
| Tools |
|
| CI/CD |
|
| Scans |
|
| Mentions |
|
AlgebraX treats Python's native dict as a first-class sparse algebraic object, unifying linear algebra, graph
algorithms, formal language theory, signal transforms, and information metrics under a single polymorphic framework.
Key Features
- ⚡ Zero Heavy Dependencies: Pure Python core requiring no C++ build steps. Includes native bidirectional converters between sparse dict mappings and dense multidimensional arrays.
- 🔄 Polymorphic Semiring Computing: By swapping the algebraic semiring $(\oplus, \otimes)$, the exact same matrix algorithms compute standard linear algebra, tropical shortest path latencies, or symbolic rule provenance.
- 🌌 Sparse Multidimensional Tensors: Arbitrary nested mappings behave as infinite-dimensional sparse tensors, tries,
and lattices (
AlgebraicTrie) with custom key operators. - 🔬 Interactive Desktop GUI: Repo includes DearPyGui with 12 interactive modules, dynamic texture previews, force-directed graph canvases, and signal transforms.
Installation
# Using uv (recommended)
uv add algebrax
# Using pip
pip install algebrax
5-Minute Quickstart
By changing the semiring parameter in matrix.dot, you can transform standard linear matrix multiplication into
shortest-path solvers or symbolic rule derivation tracking:
import algebrax as ax
# Define a Sparse Graph Adjacency / Distance Matrix
graph = {
0: {1: 2.0, 2: 10.0},
1: {2: 3.0},
}
# 1. Standard Linear Matrix Multiplication (+, *)
linear_mult = ax.matrix.dot(graph, graph, semiring=ax.semiring.StandardSemiring())
print('Linear Combination (0->2):', linear_mult[0][2])
# Output: 30.0
# 2. Tropical Shortest Path (min, +)
shortest_path = ax.matrix.dot(graph, graph, semiring=ax.semiring.TropicalSemiring())
print('Shortest Path Cost (0->1->2):', shortest_path[0][2])
# Output: 5.0
# 3. Symbolic Provenance Rule Tracking
provenance_graph = {
0: {1: {('rule_A',): 1}, 2: {('rule_C',): 1}},
1: {2: {('rule_B',): 1}},
}
provenance_mult = ax.matrix.dot(provenance_graph, provenance_graph, semiring=ax.semiring.ProvenanceSemiring())
print('Symbolic Derivation Polynomial:', provenance_mult[0][2])
# Output: {('rule_A', 'rule_B'): 1}
Use Case Recipes & Jupyter Notebooks
The recipes/ directory contains standalone CLI scripts and matching interactive .ipynb notebooks for 29
real-world scenarios:
| Category | Recipe & Notebook | Core Algebraic Components |
|---|---|---|
| Image Processing | 🐍 📓 |
transforms.convolve, StandardSemiring, ArcticSemiring, TropicalSemiring |
| Traffic Resilience | 🐍 📓 |
semiring.TropicalSemiring, matrix.power, analysis.forman_ricci_curvature |
| NLP Parsing | 🐍 📓 |
matrix.dot, semiring.ProvenanceSemiring, probability.entropy |
| Post-Quantum Security | 🐍 📓 |
semiring.DigitalSemiring, transforms.z_transform, probability.mutual_information |
| Supply Chain Logistics | 🐍 📓 |
trie.AlgebraicTrie, lattice.join, lattice.meet, probability.kl_divergence |
| Financial Risk | 🐍 📓 |
automata.simulate_dfa, analysis.eigen_centrality, semiring.VarianceSemiring |
| Structural Analysis | 🐍 📓 |
group.compose, group.signature, matrix.academic.determinant, transforms.hilbert |
| Telecommunications | 🐍 📓 |
transforms.walsh_hadamard, analysis.laplacian, metrics.box_counting_dimension |
| Quantum Optimization | 🐍 📓 |
transforms.legendre_fenchel, matrix.block_diag, matrix.trace, automata.simulate_nfa |
| Sensor Reliability | 🐍 📓 |
semiring.ViterbiSemiring, matrix.power, analysis.gaussian_kernel, analysis.gradient |
| Holographic Duality | 🐍 📓 |
analysis.forman_ricci_curvature, analysis.divergence, trie.AlgebraicTrie, probability.entropy |
| Optical Holography | 🐍 📓 |
transforms.dft, transforms.idft, probability.entropy |
| Topological Data Analysis | 🐍 📓 |
semiring.BooleanSemiring, matrix.power, analysis.forman_ricci_curvature, matrix.academic.determinant |
| Control Theory | 🐍 📓 |
matrix.power, transforms.z_transform, matrix.academic.determinant |
| Algebraic Knot Theory | 🐍 📓 |
semiring.KnotSemiring, semiring.MonoidAlgebraSemiring, group.compose, group.signature |
| Sheaf Cohomology | 🐍 📓 |
analysis.gradient, analysis.laplacian, semiring.MonoidAlgebraSemiring |
| Trajectoid Kinematics | 🐍 📓 |
analysis.gradient, matrix.dot, metrics.sparsity |
| Sparse Tensor Einsum | 🐍 📓 |
tensor.einsum, tensor.outer_product, tensor.tensordot, tensor.flatten_tensor |
| Black Hole Spacetime | 🐍 📓 |
tensor.einsum, transforms.z_transform, analysis.gradient, probability.entropy |
| 3D Gaussian Splatting | 🐍 📓 |
matrix.dot, matrix.transpose, analysis.gaussian_kernel |
| Simplicial Homology | 🐍 📓 |
homology.SimplicialComplex, homology.betti_numbers, analysis.SparseChainComplex |
| Clifford Geometric Algebra | 🐍 📓 |
clifford.CliffordSemiring, clifford.rotor_rotation, semiring.QuotientMonoidAlgebraSemiring |
| Galois Finite Fields | 🐍 📓 |
galois.GaloisFieldSemiring, galois.gf_matrix_mul, semiring.QuotientMonoidAlgebraSemiring |
| Forward-Mode Autodiff | 🐍 📓 |
StandardSemiring(DualNumber), GradientDualNumber, multi-hop gradient flow |
| Sparse Neural Backprop | 🐍 📓 |
matrix.transpose, matrix.dot, adjoint pullback $W^T \cdot \bar{z}$, outer products |
| Functional Autograd Engine | 🐍 📓 |
Value computational DAG, reverse topological VJP traversal, parameter optimization |
| Quantum Path Integrals | 🐍 📓 |
StandardSemiring(dtype=complex), native complex, discrete Feynman path summation, Born's rule, Aharonov-Bohm |
| Relativistic Dirac Spinors | 🐍 📓 |
clifford.CliffordSemiring(1,3), Dirac spinors $\psi \in Cl^+(1,3)$, $4\pi$ rotation periodicity, 4-current $J$ |
| Distributed Vector Clocks | 🐍 📓 |
lattice.combine (supremum join), semiring.ArcticSemiring, causal Happened-Before $\to$, CRDT version vectors |
| Spectral Graph Clustering | 🐍 📓 |
matrix.core.laplacian_matrix, analysis.fiedler_vector, analysis.laplacian_smoothing, analysis.laplacian_spectrum |
Run any recipe using uv:
uv run recipes/image_processing.py
Graphical Desktop Laboratory
Launch the interactive DearPyGui laboratory application featuring 12 interactive modules, live image convolution texture previews, force-directed graph canvases, signal transforms, and information theory calculators:
uv run recipes/lab.py
Documentation
Comprehensive documentation is hosted online and structured into distinct pillars:
- 🚀 Start: Installation, quickstart, and core philosophy.
- 📖 User Guide: In-depth reference for built-in Semirings, Matrices, Tries, Homology, Transforms, and Discrete Analysis.
- 🍳 Recipes & GUI Lab: Real-world use cases, Jupyter notebooks, and laboratory documentation.
Development & Contributing
Golden Source Recipes & Jupytext Sync
All recipes in recipes/ are authored as Python scripts (.py) using Jupytext Percent format (# %% cell markers)
as the canonical Golden Source. Corresponding Jupyter Notebooks (.ipynb) are auto-generated from these scripts.
Pre-Commit Hook Setup
Install the pre-commit hook to automatically sync .ipynb notebooks whenever you modify a .py recipe script:
# Ensure local repository hooks directory is active (recommended if global hooksPath is set)
git config --local core.hooksPath .git/hooks
# Install pre-commit hook
uvx pre-commit install
Manual Sync & Testing
# Refresh all Jupyter notebooks from Golden Source scripts
uvx jupytext --to notebook recipes/*.py
# Run automated tests on all notebooks
uv run pytest --nbmake recipes/
License
Distributed under the MIT License. See LICENSE for more information.
Metadata
Release files for algebrax 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| algebrax-0.11.0.tar.gz | 39.0 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| algebrax-0.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.1 MB
Release files / algebrax-0.11.0.tar.gz
| Download URL | algebrax-0.11.0.tar.gz |
|---|---|
| Size | 39.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0129d878f2d286463c03d96824d6b18c0fe454f7bd0618d18628ac17860fc444
|
|
BLAKE2b-256 checksum How to use checksums |
09b41f399e5a4def1eaf883ebda25bf487a5c075e1ee8884e118182d262d1057
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / algebrax-0.11.0-py3-none-any.whl
| Download URL | algebrax-0.11.0-py3-none-any.whl |
|---|---|
| Size | 136.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0a8b62d796d564896222f257de0925ce90a89ac590a06e7f3098cb5690677b0
|
|
BLAKE2b-256 checksum How to use checksums |
2a9672ae8279f14e3745d9b02ac008e0783966098d003db86f6b65c1db9f054c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for algebrax 0.11.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.