A Python-native linear algebra library for learning, experimentation, and visual intuition
Project description
panchi
panchi is a Python-native linear algebra library designed for learning, experimentation, and visual intuition.
The goal is not performance. The goal is clarity.
Why panchi?
Most linear algebra libraries optimize for speed and abstraction. panchi optimizes for understanding.
panchi is built for:
- Students learning linear algebra who want to see the math happen, not just trust a black box
- Educators who need transparent implementations to demonstrate concepts in lectures or workshops
- Self-learners building intuition through experimentation and visual feedback
- Researchers prototyping algorithms where readability matters more than runtime
- Developers who want to understand what's happening under the hood before optimizing
Think of panchi as a laboratory notebook, not a production engine.
Philosophy
- Explicit over implicit – Algorithms are implemented directly, not delegated to opaque backends
- Readable over clever – Code prioritizes clarity and educational value over terse optimizations
- Mathematical over computational – Objects behave like mathematical entities with proper operator overloading
- Visual by default – Visualization is a first-class feature, not an afterthought
- Informative errors – Error messages guide learning by explaining what went wrong and why
Features
✅ Currently Available
Core Primitives
VectorandMatrixclasses with native Python data structures- Natural mathematical syntax through operator overloading (
+,-,*,**) - Comprehensive shape checking with educational error messages
Vector Operations
- Addition, subtraction, scalar multiplication
- Magnitude calculation and normalization
- Dot product and cross product (3D)
- Unit vectors and zero vectors
Matrix Operations
- Addition, subtraction, matrix multiplication
- Scalar multiplication and matrix powers
- Transpose operations
- Matrix-vector transformations
- Trace calculation for square matrices
Utilities
- Identity matrices and zero matrices
- Random vectors and matrices with configurable ranges
- 2D and 3D rotation matrices
- Diagonal matrix construction
🚧 In Development
- Matrix determinants and inverses
- Matrix decompositions (LU, QR, eigenvalue methods)
- Interactive visualization toolkit
- Animated transformations
- Jupyter notebook integration
🔮 Roadmap
- Step-by-step algorithm demonstrations
- Educational machine learning examples (PCA, linear regression)
- Physics simulations using linear operators
- Extended documentation with visual explanations
Installation
pip install panchi
Requirements: Python 3.10 or higher
For the optional Manim-powered visualizations:
pip install panchi[manim]
To install from source for development:
git clone https://github.com/Gustavo-Galvao-e-Silva/panchi.git
cd panchi
pip install -e ".[dev]"
Quick Start
from panchi.primitives import Vector, Matrix
from panchi.operations import dot, identity, rotation_matrix_2d
from math import pi
# Vector operations
v = Vector([3, 4])
magnitude = v.magnitude
normalized = v.normalize()
# Matrix transformations
rotation = rotation_matrix_2d(pi / 2)
point = Vector([1, 0])
rotated = rotation * point
# Matrix algebra
A = Matrix([[1, 2], [3, 4]])
B = Matrix([[5, 6], [7, 8]])
C = A * B
trace = C.trace
# Identity and special matrices
I = identity(3)
product = A * A.right_identity
Use Cases
1. Learning Linear Algebra
Work through textbook problems with code that mirrors mathematical notation:
# Verify that (AB)^T = B^T A^T
A = Matrix([[1, 2], [3, 4]])
B = Matrix([[5, 6], [7, 8]])
left_side = (A * B).T
right_side = B.T * A.T
assert left_side == right_side
Contributing
panchi welcomes contributions that align with its educational mission:
- Clarity First – Code should be readable by someone learning linear algebra
- Tests Required – All new features need comprehensive pytest tests
- Descriptive Docstrings – Follow NumPy documentation style
- Mathematical Accuracy – Verify implementations against textbook algorithms
How to Contribute
- Fork the repository
- Create a feature branch (
git checkout -b feature/determinant-calculation) - Write clear, well-documented code with tests
- Ensure all tests pass (
pytest tests/) - Submit a pull request with a detailed description
See CONTRIBUTING.md for detailed guidelines.
Documentation
Full documentation will be available at panchi.readthedocs.io (coming soon)
- API Reference – Complete function and class documentation
- Tutorials – Step-by-step guides for common operations
- Examples – Real-world use cases and demonstrations
- Theory – Mathematical background and explanations
Project Status
Current Version: 0.1.0a1 (Alpha)
panchi is in early alpha. It is installable and the core primitives are functional, but APIs may change as the library evolves. Not recommended for production use. Feedback and contributions are very welcome.
Support
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Ask questions in GitHub Discussions
License
MIT License – see LICENSE for details.
Acknowledgments
panchi is inspired by educational resources that prioritize understanding:
- Gilbert Strang's Introduction to Linear Algebra
- 3Blue1Brown's Essence of Linear Algebra video series
- The desire to make linear algebra accessible and visual
Final Note
panchi exists to answer a simple question:
"What is linear algebra actually doing?"
If you've ever felt frustrated by libraries that hide the mathematics behind abstractions, or if you want to see transformations happen rather than just trust the output, panchi is for you.
Linear algebra is beautiful. Let's make it visible.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 panchi-0.1.0a1.tar.gz.
File metadata
- Download URL: panchi-0.1.0a1.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dddcfbe8c2907be006ddd880edaf0fd289bab3f32c7250ca5235799d9eea564
|
|
| MD5 |
a3da631e28ce74f3806bce543db7942c
|
|
| BLAKE2b-256 |
cb439bd70bcbe165f9a23238740d9d2085a8aa7a5c3da67a7e82bf54d0fe373b
|
File details
Details for the file panchi-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: panchi-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 34.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcaa6d669b2bb08f95e560a917010e0431ee03df748aa29c45a69ea96af80d0a
|
|
| MD5 |
f0226e6ab14d071bbaf2c3d3eab06438
|
|
| BLAKE2b-256 |
1901fbc5cfe2991ab29c4990bca029f5e3570ab7f3febaee4a3894a15797db66
|