Lightweight mathematical backend for physics libraries.
Project description
pyvelora
pyvelora is a lightweight math backend for scientific and simulation workflows.
It provides structured Vector, Matrix, and Tensor classes, linear algebra helpers,
and an ODE module for differential equation workflows.
What You Get
- Clear, typed array wrappers for vectors, matrices, and tensors
- Loop-based arithmetic with predictable behavior
- Linear algebra helpers for matrix operations, solvers, and decompositions
- Utility helpers for precision control, validation, mesh generation, and plotting
- ODE solving helpers with first-order and second-order system support
Philosophy
- Lightweight abstractions over Python-native containers
- Predictable data containers with explicit operations
- Reusable core infrastructure for physics/simulation libraries
Installation
pip install pyvelora
Optional dependencies:
- SciPy for ODE solving
- Matplotlib for plotting utilities and ODE visualization
Install them with:
pip install scipy matplotlib
Core Quick Start
from pyvelora import Vector, Matrix, Tensor
v = Vector([3, 4])
print(v.magnitude()) # 5.0
m = Matrix([[1, 2], [3, 4]])
print(m.transpose())
t = Tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
print(t.shape) # (2, 2, 2)
Coordinate Vector Input
Vector supports polar, spherical, and cylindrical coordinate input.
from pyvelora import Vector
# Polar input: [r, theta]
v_polar = Vector([2, 45], type="polar", degrees=True)
# Spherical input: [r, theta, phi]
v_spherical = Vector([1, 90, 30], type="spherical", degrees=True)
# Cylindrical input: [rho, phi, z]
v_cyl = Vector([2, 90, 3], type="cylindrical", degrees=True)
Angles are interpreted as radians unless degrees=True is passed.
Linear Algebra Utilities
from pyvelora import Matrix
from pyvelora import Vector
from pyvelora.linalg import solve
A = Matrix([[2, 1], [5, 3]])
b = Vector([4, 11])
print(A.determinant())
print(A.inverse())
print(solve(A, b, method="lu"))
Utilities and Plotting
pyvelora.utils includes numerical cleanup, tolerance management, mesh generation,
and lightweight plotting helpers.
from pyvelora import Matrix
from pyvelora.utils import clean, set_precision, get_precision, heatmap, linspace
set_precision(atol=1e-10, rtol=1e-8)
print(get_precision())
A = Matrix([[1.0, 0.99999999999], [-0.2, 0.3]])
print(clean(A.data))
fig, ax = heatmap(A, annotate=True, show=False)
ODE Module
The ODE API is available under pyvelora.diffeq.ode.
from pyvelora.constants import pi
from pyvelora.diffeq.ode import solve, second_order
from pyvelora.utils import linspace
# First-order system: y' = -y
sol = solve(lambda t, y: -y, (0, 2), [1.0], t_eval=linspace(0, 2, 11))
print(sol.final())
# Convert second-order equation y'' = -y to first-order system
sho = second_order(lambda t, y, v: -y)
sho_sol = solve(sho, (0, 2 * pi), [1.0, 0.0])
print(sho_sol.final())
Error Types
The package provides reusable exception types:
PyveloraErrorShapeErrorDimensionError
from pyvelora import Vector, ShapeError
try:
_ = Vector([1, 2, 3]) + Vector([1, 2])
except ShapeError as exc:
print(exc)
Development
Run the test suite:
python -m pytest src/pyvelora/tests -q
Build source and wheel distributions:
python -m build --no-isolation
AI Use Disclaimer
AI-assisted tooling was used during development for parts of the test suite, docstrings, and project documentation. Library design, implementation decisions, review, and release validation were still performed manually.
Project Status
pyvelora is currently alpha-stage and actively evolving. Core APIs are usable, but minor interface changes may still happen between releases.
Project details
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 pyvelora-0.3.3.tar.gz.
File metadata
- Download URL: pyvelora-0.3.3.tar.gz
- Upload date:
- Size: 54.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4a9635b9b204bc3375d386b858c422a97947fb0180fcc86d59fcfbd71bcb992
|
|
| MD5 |
9255be5d09d37ae46499bb29ea8f6d45
|
|
| BLAKE2b-256 |
94679110932c58028812db1a64668a9738527bec85ce5844b1441d476e524cea
|
File details
Details for the file pyvelora-0.3.3-py3-none-any.whl.
File metadata
- Download URL: pyvelora-0.3.3-py3-none-any.whl
- Upload date:
- Size: 76.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28d6a7feb5e7a3dd8496d0aedf1a888ac19e4552f62a1b63cea387dc604a5357
|
|
| MD5 |
029b8e477bca2050a2dd58477ceabb99
|
|
| BLAKE2b-256 |
ddaa3ec62d1e5bfef2ca85e30ef76860d507170fb73a2646e499e99222ebac43
|