Hi,
Many thanks for your reply @pixel27 - when I paste in the code:
using StatsBase
d = Dict{String,Function}()
functions = names(StatsBase, all= false, imported = false)
for f in functions
# func = f
if getfield(StatsBase, f) isa Function
d[string(f)] = getfield(StatsBase, f)
end
end
I get the following error:
UndefVarError: findat not defined
Stacktrace:
[1] top-level scope at .\In[44]:11
[2] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
where line 11 is the “isa” line. Did you get the same? I’m using Julia 1.5.3
The end state for this is create arrays of function, grouped around the common variable (vector) set they all share e.g. (assuming d now populated):
d = Dict{String,Function}()
computeNames1 = FunctionWrangler([d["Mean"], d["percentile"]])
computeNames2 = FunctionWrangler([ d["Mean"]])
computeSets = [computeNames1 , computeNames2]
vector1 = [i for i in 1:10]
vector2 = [i for i in 10:20]
vectorGrouping = [vector1,vector2]
computeSetIncrement = 1
Threads.@threads for v in vectorGrouping
result = zeros(Float64, length(computeSets[computeSetIncrement]))
smap!(result , computeSets[computeSetIncrement], v)
computeSetIncrement += 1
end
using the FunctionWranglers.jl package to wrap the function array and then execute each group in parallel. Since I wasn’t sure if it is possible to execute functions in parallel in a thread safe way when acting on different datasources (closer to the Actor.jl model) I assumed a reference to the method would be required.
Note that an alternative to the above would be to bring the threads into the loop to execute over the computesets in parallel and and / or the vectorGrouping.
@tisztamo , @pbayer - does this use case look valid for your respective packages? My need is to be able to dynamically group methods and dispatch against common data as above, but I don’t think this is a unique scenario so interested in your thoughts on how to implement.
Regards