This page describes two very basic wrappers called iot and iot_merge. The signatures are:

iot(func, in_stream, *args, **kwargs) 

and

iot_merge(func, in_streams, *args, **kwargs)

where func is the function that is wrapped to create the agent, and where in_stream is an input stream of the agent, and in_streams is a list of input streams. Typically the positional and keyeword arguments, *args and **kwargs, include output streams. The iot and iot_merge are different from the other wrappers because their signatures do not include output streams, state or call_streams, and the functions they wrap may operate on streams. For example compare iot with map_element. The signature for map_element is:

map_element(
   func, in_stream, out_stream, 
   state=None, call_streams=None, name=None,
   *args, **kwargs) 

If we want to create an agent in which the elements of its single output stream, t, is twice the elements of its single input stream, s, we could implement the agent in to following way:

@map_e
def twice(v): return 2*v

twice(s, t)

We could implement the agent using the iot wrapper in the following way:

def f(s, t):
   t.extend([2*element for element in s])
   return len(s)

iot(f, s, t)

Observe three differences between iot and map_element:

  1. The function f which is wrapped by iot operates on a list (s) whereas the function twice operates on a single element.

  2. Function f operates on a stream, t, whereas function twice only operates on standard Python types such as int.

  3. Function f returns a pointer to the list that it has processed showing how far the agent as processed the input. In this example, since f processes the entire input, f returns len(s). By contrast, twice does not return any pointers.

iot wrapper with Stream Arrays

The following example of using the iot wrapper with stream arrays illustrates that this simple wrapper is adequate for some applications using stream arrays. In this example, x and y are stream arrays of int. We want to define an agent that makes the elements of y twice the corresponding elements of x.

# Create the streams arrays.
x = StreamArray(name='x', dtype=int)
y = StreamArray(name='y', dtype=int)

# f is the function that is wrapped using the
# iot wrapper get the agent
def f(x, y):
   y.extend(x * 2)
   return len(x)

# Create the agent by wrapping function f.
iot(f, x, y)