I have been playing around with dictionaries and trying to become more comfortable with them. I came across this post, which got me thinking about potential applications. Before getting ahead of myself, I tried to start with a basic example.
import numpy as np
times = np.linspace(0,20,21)
obs = np.linspace(50,100,21)
def square(x):
return x**2
def cube(x):
return x**3
def root_six(x):
return x**(1/6)
dispatcher = {'sq':square, 'cb':cube, '6th':root_six}
def gimme(func_dict=dispatcher, values=times):
res = []
for func in func_dict:
res.append(func(t) for t in values)
return res
gg = np.array(list(gimme())) # I tried various combinations
print(gg)
>> [<generator object gimme.<locals>.<genexpr> at 0x101b886d0>
>> <generator object gimme.<locals>.<genexpr> at 0x108fc1678>
>> <generator object gimme.<locals>.<genexpr> at 0x108fc1a40>]
How can I test whether my code is executing correctly?