Home | Download/Install | Documentation | Packages | Screenshots | News | Forum/Mailing-lists | Contact | GForge

Node Declaration

To simplify node declaration, other syntax can be used.

Factory approach

Inputs and outputs are declared in the factory.

f = Factory(name = 'mynode',
            inputs = ( (dict(name="x", interface=None, value=0.),),
            outputs = ( (dict(name="y", interface=None),), 
            nodemodule = 'mymodule',
            nodeclass = 'myclass')
# mymodule.py
def myclass(a, b):
    return a + b
Metaclass approach
class MyNode(object):
    __metaclass__ = MetaNode
    __inputs__ = [ Port(name="x", interface=None, value=0.) ]
    __outputs__ = [ Port(name="y", interface=None) ]
    def __call__(self, inputs):
        return inputs
Decorator approach
@aleanode(inputs=[ Port(name="x", interface=None, value=0.) ],
          outputs=[ Port(name="y", interface=None) ])
def MyNodeFunc(inputs):
    return inputs
Decorator approach 2

See PEP 318 in and out decorators take interface object as args. Name of input args is computed based on the function signature as well as default value.

def MyNodeFunc(x= 0.,y= 10.):
    return (x+y,)
Decorator approach 3

An other option is to implement the PEP 362 with signature and parameter objects.

def functor(x,y):
  "Sum of the inputs"
  return sum([x,y])
documentation/core/propositions/102_node_declaration.txt · Last modified: 2010/12/07 15:51 by user   Back to top
INRIA GForge RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki