deepgraph.output_names

output_names(*names)[source]

Decorator to specify the output variable names of a connector or selector function.

Use this decorator to explicitly define the names of the output variables returned by your connector or selector functions. This is necessary when the source code of the function is not available at runtime.

Parameters:

*names (str) – One or more positional string arguments representing the names of the output variables.

Returns:

A decorator that attaches the specified output names to the decorated function via the _output_names attribute.

Return type:

callable

Examples

Specifying output variable names for a connector function:

>>> import deepgraph as dg
>>>
>>> @dg.output_names("dx", "dt", "v"):
>>> def velocity(x_s, x_t, time_s, time_t):
>>>     dx = x_t - x_s
>>>     dt = time_t - time_s
>>>     v = dx/dt
>>>     return dx, dt, v

Specifying output variable names for a selector function:

>>> import deepgraph as dg
>>>
>>> @dg.output_names("sources", "targets", "dx")
>>> def distance_selector(x_s, x_t, sources, targets):
>>>     dx = x_t - x_s
>>>     sources = sources[dx <= 5]
>>>     targets = targets[dx <= 5]
>>>     return sources, targets, dx