Lightweight NumPy-based mathematical backend for physics libraries.
Project description
pyvelora
pyvelora is a lightweight NumPy-based 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 operators with predictable behavior
- Linear algebra helpers for decomposition and matrix operations
- ODE solving helpers with first-order and second-order system support
Philosophy
- Thin abstraction over NumPy
- 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 ODE plotting
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.linalg import determinant, inverse, solve
from pyvelora.core import Vector
A = Matrix([[2, 1], [5, 3]])
b = Vector([4, 11])
print(determinant(A))
print(inverse(A))
print(solve(A, b))
ODE Module
The ODE API is available under pyvelora.diffeq.ode.
import numpy as np
from pyvelora.diffeq.ode import solve, second_order
# First-order system: y' = -y
sol = solve(lambda t, y: -y, (0, 2), [1.0], t_eval=np.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 * np.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
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.0.tar.gz.
File metadata
- Download URL: pyvelora-0.3.0.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b21e341665e61f3285aaa473addb52a3bd1aa166e3619b71481f1e2acbfcb777
|
|
| MD5 |
519954ade061a91da71f733301fb432c
|
|
| BLAKE2b-256 |
c55733623c9f1b7ded1cf011dfe241ae57296b4517d7f9dcd7b71f22301150b5
|
File details
Details for the file pyvelora-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pyvelora-0.3.0-py3-none-any.whl
- Upload date:
- Size: 30.7 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 |
f20c8055550a6ba6db86f960728751bfcfca249708ea17410938dbb641dc7971
|
|
| MD5 |
391ee41bc9e20d148cdf9eb042b00000
|
|
| BLAKE2b-256 |
4eca46efefdd00a28e48d6d05c0f40dd91d9a81f685b57c49662dcef2646ccd3
|