def facing_spinning(sub): start_index = 1 initial_condition = lambda sub, i: ~sub.iloc[i - 1][ 'spinning'] and ~sub.iloc[i - 1]['other_spinning'] and ~sub.iloc[i][ 'spinning'] and sub.iloc[i]['other_spinning'] while_condition = lambda sub, i: ~sub.iloc[i - 1]['facing_spinning'] final_condition = lambda sub, i: sub.iloc[i]['facing_spinning'] return analysis_utils.get_while_value(sub, initial_condition, while_condition, final_condition, start_index)
def face_away_when_low(sub): start_index = 1 initial_condition = lambda sub, i: (sub.iloc[i][ 'ave_dist_others'] > sub.iloc[i]['dist_to_mean_others']) and sub.iloc[ i]['bg_val'] < 1.0 while_condition = lambda sub, i: sub.iloc[i]['bg_val'] < 1.0 final_condition = lambda sub, i: (sub.iloc[i]['ave_dist_others'] < sub. iloc[i]['dist_to_mean_others']) return analysis_utils.get_while_value(sub, initial_condition, while_condition, final_condition, start_index)
def get_while_value(sub): start_index = 5 lookback = 3 initial_condition = lambda sub, i: ~sub.iloc[i - 1][ 'spinning'] and ~sub.iloc[i - 1]['other_spinning'] and ~sub.iloc[i][ 'spinning'] and sub.iloc[i]['other_spinning'] and sub.iloc[i][ 'bg_val'] < 1.0 while_condition = lambda sub, i: ~sub.iloc[i - (lookback + 1)][ 'facing_spinning'] and sub.iloc[i - (lookback + 1)]['bg_val'] < 1.0 final_condition = lambda sub, i: sub.iloc[ (i - lookback):(i + 1)]['facing_spinning'].all() and (~sub.iloc[ (i - lookback):(i + 1)]['spinning']).all() and (sub.iloc[ (i - lookback):(i + 1)]['bg_val'] < 1.0).all() return analysis_utils.get_while_value(sub, initial_condition, while_condition, final_condition, start_index)