Trees | Indices | Help |
|
---|
|
1 # $Id$ 2 # 3 # Copyright (C) 2003 Rational Discovery LLC 4 # All Rights Reserved 5 # 6 import sys 7 8 from rdkit.VLib.Node import VLibNode 911 """ base class for nodes which filter their input 12 13 Assumptions: 14 15 - transform function takes a number of arguments equal to the 16 number of inputs we have. We return whatever it returns 17 18 - inputs (parents) can be stepped through in lockstep 19 20 Usage Example: 21 >>> from rdkit.VLib.Supply import SupplyNode 22 >>> def func(a,b): 23 ... return a+b 24 >>> tform = TransformNode(func) 25 >>> suppl1 = SupplyNode(contents=[1,2,3,3]) 26 >>> suppl2 = SupplyNode(contents=[1,2,3,1]) 27 >>> tform.AddParent(suppl1) 28 >>> tform.AddParent(suppl2) 29 >>> v = [x for x in tform] 30 >>> v 31 [2, 4, 6, 4] 32 >>> tform.reset() 33 >>> v = [x for x in tform] 34 >>> v 35 [2, 4, 6, 4] 36 37 If we don't provide a function, just return the inputs: 38 >>> tform = TransformNode() 39 >>> suppl1 = SupplyNode(contents=[1,2,3,3]) 40 >>> suppl2 = SupplyNode(contents=[1,2,3,1]) 41 >>> tform.AddParent(suppl1) 42 >>> tform.AddParent(suppl2) 43 >>> v = [x for x in tform] 44 >>> v 45 [(1, 1), (2, 2), (3, 3), (3, 1)] 46 47 """ 5167 68 69 70 #------------------------------------ 71 # 72 # doctest boilerplate 73 # 77 78 if __name__ == '__main__': 79 import sys 80 failed,tried = _test() 81 sys.exit(failed) 8253 done = 0 54 parent = self.GetParents()[0] 55 args = [] 56 try: 57 for parent in self.GetParents(): 58 args.append(parent.next()) 59 except StopIteration: 60 raise StopIteration 61 args = tuple(args) 62 if self._func is not None: 63 res = apply(self._func,args) 64 else: 65 res = args 66 return res
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Apr 23 18:49:15 2016 | http://epydoc.sourceforge.net |