mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-29 17:30:09 +02:00
Introducing variables for layout queries:
1.) The ExpressionContext class is a mapping of tl::Eval
and allows providing a variable context for the LQ.
Expression class is derived from ExpressionContext now.
2.) The variable lookup has been changed so that variables
can be modified even if they come from a parent context.
3.) LayoutQuery and iterator has been given an argument to
supply the context
This commit is contained in:
Vendored
+5
@@ -24,6 +24,11 @@ class TLTest(unittest.TestCase):
|
||||
|
||||
def test_1(self):
|
||||
|
||||
ctx = pya.ExpressionContext()
|
||||
self.assertEqual(ctx.eval("1+2"), 3)
|
||||
ctx.var("a", 21)
|
||||
self.assertEqual(ctx.eval("2*a"), 42)
|
||||
|
||||
expr = pya.Expression()
|
||||
res = expr.eval()
|
||||
self.assertEqual(str(type(res)).replace("class", "type"), "<type 'NoneType'>")
|
||||
|
||||
Reference in New Issue
Block a user