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.9.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 | |
|---|---|---|---|
| algebrax-0.9.0.tar.gz | 38.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| algebrax-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.0 MB
Release files / algebrax-0.9.0.tar.gz
| Download URL | algebrax-0.9.0.tar.gz |
|---|---|
| Size | 38.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
730a6ba3bb7c22c3224dbe58c8ef47488f354f8ca7cd2c2a59475ac10225902e
|
|
BLAKE2b-256 checksum How to use checksums |
524faa3672bcb6430e0eb48c066bf591c57f7d15db74f07b9f5ccf15e0180604
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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.9.0-py3-none-any.whl
| Download URL | algebrax-0.9.0-py3-none-any.whl |
|---|---|
| Size | 122.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6787698f4f591e58fd8cee535099e61200be8f034070ec3b2dedf0f385d1ea2
|
|
BLAKE2b-256 checksum How to use checksums |
ce67cd501302768244208bdb59b4a0a02d21d1b1bd17191200abe086dd43b67e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","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}
|