Class FilterNode
source code
object --+
|
Node.VLibNode --+
|
FilterNode
base class for nodes which filter their input
Assumptions:
- filter function takes a number of arguments equal to the
number of inputs we have. It returns a bool
- inputs (parents) can be stepped through in lockstep
- we return a tuple if there's more than one input
Usage Example:
>>> from rdkit.VLib.Supply import SupplyNode
>>> def func(a,b):
... return a+b < 5
>>> filt = FilterNode(func=func)
>>> suppl1 = SupplyNode(contents=[1,2,3,3])
>>> suppl2 = SupplyNode(contents=[1,2,3,1])
>>> filt.AddParent(suppl1)
>>> filt.AddParent(suppl2)
>>> v = [x for x in filt]
>>> v
[(1, 1), (2, 2), (3, 1)]
>>> filt.reset()
>>> v = [x for x in filt]
>>> v
[(1, 1), (2, 2), (3, 1)]
>>> filt.Destroy()
Negation is also possible:
>>> filt = FilterNode(func=func,negate=1)
>>> suppl1 = SupplyNode(contents=[1,2,3,3])
>>> suppl2 = SupplyNode(contents=[1,2,3,1])
>>> filt.AddParent(suppl1)
>>> filt.AddParent(suppl2)
>>> v = [x for x in filt]
>>> v
[(3, 3)]
>>> filt.Destroy()
With no function, just return the inputs:
>>> filt = FilterNode()
>>> suppl1 = SupplyNode(contents=[1,2,3,3])
>>> filt.AddParent(suppl1)
>>> v = [x for x in filt]
>>> v
[1, 2, 3, 3]
>>> filt.Destroy()
|
__init__(self,
func=None,
negate=0,
**kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature |
source code
|
|
|
|
|
|
|
|
|
|
Inherited from Node.VLibNode :
AddChild ,
AddParent ,
Destroy ,
GetChildren ,
GetParents ,
RemoveChild ,
RemoveParent ,
__iter__ ,
reset
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
Inherited from object :
__class__
|
__init__(self,
func=None,
negate=0,
**kwargs)
(Constructor)
| source code
|
x.__init__(...) initializes x; see help(type(x)) for signature
- Overrides:
object.__init__
- (inherited documentation)
|
part of the iterator interface
raises StopIteration on failure
- Overrides:
Node.VLibNode.next
- (inherited documentation)
|
part of the iterator interface
raises StopIteration on failure
- Overrides:
Node.VLibNode.next
- (inherited documentation)
|