Skip to main content

Add your description here

Project description

lazysym

A lazy-evaluation symbolic calculator, geometric primitive engine, and constraint solver built on SymPy.

lazysym overloads standard Python operators on wrapped symbols, vectors, matrices, physical quantities, and geometric entities to defer evaluation, enabling fluent definition of complex math systems that are solved dynamically.

Installation

pip install lazysym

Quick Start

1. Symbolic Calculations & Equation Solving

Define symbolic variables in a context, register constraints (using native Python operators), and solve for target variables.

from lazysym import Context

ctx = Context()
x = ctx.Symbol('x')
y = ctx.Symbol('y')

# Register equations
ctx.given(
    2 * x + y == 10,
    x - y == 2
)

# Solve dynamically
print("x =", ctx.find(x))  # x = 4
print("y =", ctx.find(y))  # y = 2

2. Physical Quantities with Units

Perform arithmetic across different units with automatic base conversion.

from lazysym import Quantity

# Quantities auto-convert to a base representation during operations
distance1 = Quantity(5, 'km')
distance2 = Quantity(500, 'm')

total = distance1 + distance2
print(total)                # 5.5 km
print(total.convert_to('m')) # 5500.0

3. Constraint Satisfaction (Digit/Alphametic Solvers)

Solve discrete constraint-satisfaction problems or cryptarithms using digit domains and numerical constraints.

from lazysym import Context

ctx = Context()

# Define digits with ranges
A = ctx.Digit('A', domain=(1, 9))
B = ctx.Digit('B', domain=(0, 9))

# Add constraints (e.g. A + B must equal 10, and A must be a prime number)
ctx.given(
    A + B == 10,
    A.isPrime()
)

# Find all valid combinations
solutions = ctx.findAll(A, B)
print(solutions)  # [(2, 8), (3, 7), (5, 5), (7, 3)]

4. Geometry and Selection Transformations (2D & 3D)

Construct points, lines, circles, spheres, and other geometric primitives in a canvas environment. Group entities into a selection to perform bulk spatial transformations (translation, rotation, scaling, dilation, reflection).

from lazysym import Context, Plot

ctx = Context()
plot = Plot(ctx, dim=2)

p1 = plot.Point('p1', 0, 0)
p2 = plot.Point('p2', 3, 4)

# Calculate dynamic distances
distance = p1.distance(p2)
print("Distance:", distance)  # Distance: 5 m

# Create a circle at p1
circle = plot.Circle('c1', center=p1, radius=5)

# Selection-based bulk transformation
selection = plot.selection(p1, circle)
selection.translate(dx=10, dy=5)

# Original points are modified in-place
print(p1.x, p1.y)          # 10, 5
print(circle.center.coords()) # (10, 5)

5. Custom Matrix & Vector Wrappers

Construct vectors and matrices with custom support for dot products, cross products, and matrix multiplication under symbolic contexts.

from lazysym import Context

ctx = Context()

# Access namespace matrices and vectors
v1 = ctx.Vector.Vector([1, 2, 3])
v2 = ctx.Vector.Vector([4, 5, 6])

print("Dot product:", v1.dot(v2))    # 32
print("Cross product:", v1.cross(v2))  # Vector([-3, 6, -3])

Features

  • Deferred Symbolic Operations: Overloaded magic methods map arithmetic and comparison operators directly into SymPy expressions.
  • Physical Quantities System: Pre-configured factors for metric units (m, cm, mm, km), imperial units (inch, ft, yd, mi), and angles (radians, degrees, gradians, turns).
  • Geometric Primitives: 2D/3D support for points, lines, rays, segments, circles, spheres, triangles, ellipses, parabolas, cylinders, cones, and planes.
  • Dynamic Solver Contexts: Behind the scenes, the context uses SymPy solver utilities to resolve systems of equations, with automatic coordinate gauge-fixing for under-constrained geometric layouts.
  • Sequence Patterns: Built-in support for evaluating arithmetic or custom recurrence relations based on pattern configuration.

License

MIT

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

lazysym-1.0.1.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

lazysym-1.0.1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file lazysym-1.0.1.tar.gz.

File metadata

  • Download URL: lazysym-1.0.1.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for lazysym-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a2aa9a54707d149542f1587373dca27e6ad5b6228960a05cdfcf1c853de2bb55
MD5 510fc1bc3cf1514d244b80c9d75e2d30
BLAKE2b-256 d836c33aa79bc74e7e25e55932c10dfb650b72006f46834faa92faa5794e71f7

See more details on using hashes here.

File details

Details for the file lazysym-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: lazysym-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for lazysym-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 caba38f484e1ee40edd2b644a4ddfa3390bcba294299412f4b5d2151d163e4ac
MD5 9ccebd7823e8b164572e5b2b640fbe67
BLAKE2b-256 44b821aecef29d65b7fd033f26ddf1cc18413121d889ab654515cd3096ea6518

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