Hi Danilo,
The idea of decorating a function to show that the return variables could be fed back in in a scan form is interesting and could solve my problem in a nice way without new syntax.
I looked at your code but got a bit confused as to how it works (there seems to be some magic where the decorator injects the scanned variable into the namespace). Are you able to show how you'd implement the moving average example with your package?
I tried:
@enable_scan("average")
def exponential_moving_average_pyscan(signal, decay, initial=0):
yield from ((1-decay)*(average or initial) + decay*x for x in signal)
smooth_signal_9 = list(exponential_moving_average_pyscan(signal, decay=decay))[1:]
Which almost gave the right result, but seemed to get the initial conditions wrong.
- Peter