Package VLib :: Module Transform :: Class TransformNode
[hide private]
[frames] | no frames]

Class TransformNode

source code

   object --+    
            |    
Node.VLibNode --+
                |
               TransformNode
Known Subclasses:
NodeLib.SmartsRemover.SmartsRemover

base class for nodes which filter their input

Assumptions:

  - transform function takes a number of arguments equal to the
    number of inputs we have.  We return whatever it returns

  - inputs (parents) can be stepped through in lockstep

Usage Example:
  >>> from VLib.Supply import SupplyNode
  >>> def func(a,b):
  ...   return a+b
  >>> tform = TransformNode(func)
  >>> suppl1 = SupplyNode(contents=[1,2,3,3])
  >>> suppl2 = SupplyNode(contents=[1,2,3,1])
  >>> tform.AddParent(suppl1)
  >>> tform.AddParent(suppl2)
  >>> v = [x for x in tform]
  >>> v
  [2, 4, 6, 4]
  >>> tform.reset()
  >>> v = [x for x in tform]
  >>> v
  [2, 4, 6, 4]

  If we don't provide a function, just return the inputs:
  >>> tform = TransformNode()
  >>> suppl1 = SupplyNode(contents=[1,2,3,3])
  >>> suppl2 = SupplyNode(contents=[1,2,3,1])
  >>> tform.AddParent(suppl1)
  >>> tform.AddParent(suppl2)
  >>> v = [x for x in tform]
  >>> v
  [(1, 1), (2, 2), (3, 3), (3, 1)]



Instance Methods [hide private]
 
__init__(self, func=None, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
next(self)
part of the iterator interface...
source code

Inherited from Node.VLibNode: AddChild, AddParent, Destroy, GetChildren, GetParents, RemoveChild, RemoveParent, __iter__, reset

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, func=None, **kwargs)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: Node.VLibNode.__init__

next(self)

source code 
part of the iterator interface

raises StopIteration on failure

Overrides: Node.VLibNode.next
(inherited documentation)