`cumulative_p_w_sample = p_w_c.take(y, axis=1).sum(axis=1).cumsum()` would make Travis happy.