def test_namespace(): a = Stream([1, 2, 3]).rename("a") with Module("world") as world: a1 = Stream([4, 5, 6]).rename("a1") a2 = Stream([7, 8, 9]).rename("a2") with Module("sub-world") as sub_world: a3 = Stream([10, 11, 12]).rename("a3") a4 = Stream([13, 14, 15]).rename("a4") t3 = BinOp(np.add)(a2, a4).rename("t3") t1 = BinOp(np.multiply)(a, t3).rename("t1") feed = DataFeed([t1, world, sub_world]) assert feed.next() == { "world:/a1": 4, "world:/a2": 7, "world:/sub-world:/a3": 10, "world:/sub-world:/a4": 13, "world:/sub-world:/t3": 20, "t1": 20 } feed.reset() assert feed.next() == { "world:/a1": 4, "world:/a2": 7, "world:/sub-world:/a3": 10, "world:/sub-world:/a4": 13, "world:/sub-world:/t3": 20, "t1": 20 }
def test_namespace(): a = Stream("a", [1, 2, 3]) with Module("world") as world: a1 = Stream("a1", [4, 5, 6]) a2 = Stream("a2", [7, 8, 9]) with Module("sub-world") as sub_world: a3 = Stream("a3", [10, 11, 12]) a4 = Stream("a4", [13, 14, 15]) t3 = BinOp("t3", operator.add)(a2, a4) t1 = BinOp("t1", operator.mul)(a, t3) feed = DataFeed()(t1, world, sub_world) assert feed.next() == { "world:/a1": 4, "world:/a2": 7, "world:/sub-world:/a3": 10, "world:/sub-world:/a4": 13, "world:/sub-world:/t3": 20, "t1": 20 } feed.reset() assert feed.next() == { "world:/a1": 4, "world:/a2": 7, "world:/sub-world:/a3": 10, "world:/sub-world:/a4": 13, "world:/sub-world:/t3": 20, "t1": 20 }
def test_namespace(): a1 = Array("a1", [7, 8, 9]) a2 = Array("a2", [3, 2, 1]) t1 = BinOp("t1", operator.mul)(a1, a2) a = Namespace("world")(a1, a2) feed = DataFeed([t1, a]) assert feed.next() == {"world:/a1": 7, "world:/a2": 3, "t1": 21} feed.reset() assert feed.next() == {"world:/a1": 7, "world:/a2": 3, "t1": 21}