Axiovora-X / tests /test_demo_expanded.py
ZAIDX11's picture
Add files using upload-large-folder tool
19faf57 verified
import math
from demo import Vector, polygon_area, generate_random_polygon, apply_ops
from pipeline import compose_demo_pipeline
from alphageometry.transformer_demo import demo_attention_run
def test_vector_area_centroid_convex():
pts = [Vector(0, 0), Vector(1, 0), Vector(0, 1)]
area = polygon_area(pts)
assert math.isclose(area, 0.5, rel_tol=1e-9)
def test_generate_random_polygon_deterministic():
p1 = generate_random_polygon(5, radius=2.0, seed=123)
p2 = generate_random_polygon(5, radius=2.0, seed=123)
assert all(math.isclose(a.x, b.x) and math.isclose(a.y, b.y) for a, b in zip(p1, p2))
def test_apply_ops_length():
res = apply_ops(1.0, 2.0)
assert len(res) == 200
def test_pipeline_demo_smoke():
p = compose_demo_pipeline()
out = p.run([0.0, 1.0, -1.0, 2.0, -2.0])
assert isinstance(out, list)
def test_transformer_demo_attention():
out = demo_attention_run()
# out is 2x2 and values are finite
assert len(out) == 2 and len(out[0]) == 2
assert all(math.isfinite(x) for row in out for x in row)