152bbf3432
- operators/: _support + geometry/features/boolean/transform/selection/sketch/product - product/: semantic value model, solver, occurrence, packages, capture - topology/: model, tagging, tracking, autotag (package re-exports model symbols) - params/: units, expr, tolerance, frame - recording/: graph, serializer, source_mapping - _internal/: canonical_json, vendor_warning_filters, semantic, mesh, brep_region Root shrinks from 46 to 7 modules. Drop the legacy geometry/boolean/transform/ selection monolith copies and the operations.py facade; unified operator exports now live in operators/__init__ with monkeypatch mirroring preserved. Remove the legacy evolve generators and their example/tests/docs. Import paths for simplecadapi.topology keep working via package re-export; update all in-repo consumers, tests, tools/auto_docs_gen source tables, and regenerate the skill API reference docs.
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""Focused tests for the 2.0 expression graph layer."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
import simplecadapi as scad
|
|
|
|
|
|
class TestExpressionGraph(unittest.TestCase):
|
|
def test_var_and_expr_roundtrip(self):
|
|
graph = scad.ExpressionGraph()
|
|
r = scad.var("r", 10.0)
|
|
expr = (r + 2) * 3
|
|
graph.register(expr)
|
|
|
|
payload = graph.to_dict()
|
|
rebuilt = scad.ExpressionGraph.from_dict(payload)
|
|
|
|
self.assertEqual(graph.node_count, rebuilt.node_count)
|
|
self.assertGreaterEqual(rebuilt.node_count, 4)
|
|
|
|
def test_expr_evaluates_with_defaults(self):
|
|
r = scad.var("r", 5.0)
|
|
expr = r * 2 + 1
|
|
self.assertAlmostEqual(float(expr), 11.0)
|
|
|
|
def test_expression_canonicalization_does_not_promote_discrete_index_lists(self):
|
|
from simplecadapi.params.expr import ExpressionGraph, canonicalize_params
|
|
|
|
graph = ExpressionGraph()
|
|
params, param_exprs = canonicalize_params(
|
|
{
|
|
"selected_edge_indices": [0, 1, 2],
|
|
"distance": scad.var("d", 2.0),
|
|
},
|
|
graph,
|
|
)
|
|
|
|
self.assertEqual(params["selected_edge_indices"], [0, 1, 2])
|
|
self.assertTrue(
|
|
all(isinstance(v, int) for v in params["selected_edge_indices"])
|
|
)
|
|
self.assertIn("distance", param_exprs)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|