def objective(values): for (i, value) in enumerate(values): parents[i].value = value score = sum([obs.chisquare() for obs in obs_nodes]) if score < 0: kabuki.debug_here() return score