Skip to main content

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:

  • PyveloraError
  • ShapeError
  • DimensionError
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

pyvelora-0.3.1.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvelora-0.3.1-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file pyvelora-0.3.1.tar.gz.

File metadata

  • Download URL: pyvelora-0.3.1.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for pyvelora-0.3.1.tar.gz
Algorithm Hash digest
SHA256 abccdd3f090619ec535bc7d39b88c7f53369761fb3b29ef29b4a6d4a58ef74bc
MD5 d948184fc5a7ee49429256eb2adce88b
BLAKE2b-256 68bb824d7bc2b0f020e9d0ad62c4510fa97ff315fd5e5f2c59884a5e763dfbe6

See more details on using hashes here.

File details

Details for the file pyvelora-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pyvelora-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for pyvelora-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e048609584370b896e54d052c7a153dba7f58139941c495d8cb9ecc02d4afc71
MD5 a422c72488524e1b63db370a176deefd
BLAKE2b-256 89b8e726bcacc98bae511fb989c7a783f70332b89539e6d0231dcdd623e84441

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page