def continuous_worker(spec): LOGGER.debug(spec) version = spec["version"] cntrl_type = spec["control_type"] global_vars = globals() control = getattr(pyreg, spec["control"]) ctc = getattr(pyreg, spec["ctc"]) measure = getattr(pyreg, spec["measure"]) net = global_vars["networks"][version][cntrl_type][spec["projection"]] prepared = global_vars["prepared"][version][cntrl_type][spec["experiment"]] if spec["ctc"].startswith("delayed"): index = prepared["time"].index(spec["time"]) active = prepared["delayed"][spec["delay"]][spec["projection"]]["active"][index] levels = prepared["delayed"][spec["delay"]][spec["projection"]]["levels"][index] delayed = prepared["delayed"][spec["delay"]][spec["projection"]]["delayed"][index] effective = pyreg.effective_network(net, active) res_cntrl = control(effective, active, levels, delayed, measure=measure) (res_ctc, samples) = ctc(effective, active, levels, delayed, random_num=spec["random_num"], measure=measure, return_sample=True) elif spec["measure"].endswith("comparison"): index = prepared["rate"]["time"].index(spec["time"]) active = prepared["rate"][spec["projection"]]["active"][index] levels = prepared["rate"][spec["projection"]]["levels"][index] effective = pyreg.effective_network(net, active) res_cntrl = control(effective, active, levels, measure=measure) (res_ctc, samples) = ctc(effective, active, levels, random_num=spec["random_num"], measure=measure, return_sample=True) else: index = prepared["time"].index(spec["time"]) active = prepared[spec["projection"]]["active"][index] levels = prepared[spec["projection"]]["levels"][index] LOGGER.debug(len(active)) effective = pyreg.effective_network(net, active) res_cntrl = control(effective, active, levels, measure=measure) (res_ctc, samples) = ctc(effective, active, levels, random_num=spec["random_num"], measure=measure, return_sample=True) return (spec, res_cntrl, res_ctc, samples)
def discrete_worker(spec): LOGGER.debug(spec) version = spec["version"] cntrl_type = spec["control_type"] global_vars = globals() control = getattr(pyreg, spec["control"]) ctc = getattr(pyreg, spec["ctc"]) measure = getattr(pyreg, spec["measure"]) net = global_vars["networks"][version][cntrl_type][spec["projection"]] if cntrl_type == "analog": active = global_vars["prepared"][version][cntrl_type][spec["experiment"]][spec["projection"]][spec["direction"]] else: active = global_vars["prepared"][version][cntrl_type][spec["experiment"]][spec["projection"]] LOGGER.debug(len(active)) effective = pyreg.effective_network(net, active) res_cntrl = control(effective, measure=measure) (res_ctc, samples) = ctc(effective, net, measure=measure, random_num=spec["random_num"], return_sample=True) return (spec, res_cntrl, res_ctc, samples)