<commit_before>from __future__ import print_function
from pandas import DataFrame

#calculate whether under- or over-correcting
def underOverCorrected(df):
    #Expect dataframes with fields tilt, startLeft, upDown, respFwdBackslash
    #Actually only can give legitimate answer when tilt is 0, because only that is an ambiguous stimulus
    #canonical case is startLeft, upDown, tilt 0
    #    1
    #A     B
    #    2
    #If you undercorrect, /  fwdSlash
    #startLeft mean target moves to right? So upDown undercorrect would be fwdslash
    startLeft = df['startLeft']
    upDown = df['upDown']
    respFwdBackslash= df['respFwdBackslash']
    if respFwdBackslash: #for canonical case. backslash means overcorrect
        underCorrect = False
    else:
        underCorrect = True #fwdslash means undercorrect
    #any departure from canonical case inverts the answer
    if not startLeft: #otherwise-canonical case gives backslash
        underCorrect = not underCorrect
    if not upDown:
        underCorrect = not underCorrect
    
    underCorrect = underCorrect 
    #print('startLeft*2=',startLeft*2)
    #ans= startLeft*2-1 * upDown*2-1 * respFwdBackslash
    return underCorrect

data = {'tilt': [0,0], 'startLeft':[True, True], 'upDown':[True, True], 'respFwdBackslash':[False,True]}
df = DataFrame(data , #index=[nDone],
                            columns = ['tilt','startLeft','upDown','respFwdBackslash']) #columns included purely to specify their order
#forCalculatn = df.loc[neutralStimIdxs, ['tilt','startLeft','upDown','respFwdBackslash']]

underCorrected = underOverCorrected(df.loc[0])
print('underCorrected=',underCorrected)
#underOverCorrected(df)
#forCalculatn = df.loc[neutralStimIdxs, ['tilt','startLeft','upDown','respFwdBackslash']]<commit_msg>Test underOvercorrect works, now need to try selective<commit_after>from __future__ import print_function
from pandas import DataFrame

#calculate whether under- or over-correcting
def underOverCorrected(df):
    #Expect dataframes with fields tilt, startLeft, upDown, respFwdBackslash
    #Actually only can give legitimate answer when tilt is 0, because only that is an ambiguous stimulus
    #canonical case is startLeft, upDown, tilt 0
    #    1
    #A     B
    #    2
    #If you undercorrect, /  fwdSlash
    #startLeft mean target moves to right? So upDown undercorrect would be fwdslash
    startLeft = df['startLeft']
    upDown = df['upDown']
    respFwdBackslash= df['respFwdBackslash']
    underCorrect = ~ respFwdBackslash #tilde is bitwise NOT have to use it to apply operation to each element
    #for canonical case. backslash means overcorrect, fwdslash means undercorrect
    #any departure from canonical case inverts the answer. Use XOR (^) to invert conditional on another boolean.
    startLeft_not_canonical = ~ startLeft #startLeft = True is canonical case. So, flip otherwise
    underCorrect = underCorrect ^ startLeft_not_canonical
    upDown_not_canonical = ~ upDown #otherwise-canonical case gives backslash
    underCorrect =  underCorrect ^ upDown_not_canonical
    return underCorrect

data = {'tilt': [0,0,-2,-2], 'startLeft':[True, True,True,True], 'upDown':[True, True,True,False], 'respFwdBackslash':[False,True,True,True]}
df = DataFrame(data , #index=[nDone],
                            columns = ['tilt','startLeft','upDown','respFwdBackslash']) #columns included purely to specify their order
#forCalculatn = df.loc[neutralStimIdxs, ['tilt','startLeft','upDown','respFwdBackslash']]
underCorrected = underOverCorrected(df.loc[0])
print('underCorrected=',underCorrected)
underCorrected = underOverCorrected(df)
print('underCorrected=\n',underCorrected)

#forCalculatn = df.loc[neutralStimIdxs, ['tilt','startLeft','upDown','respFwdBackslash']]
{'fraction_non_alphanumeric': 0.09885729471166622, 'fraction_numerical': 0.005846399149614669, 'mean_word_length': 4.576296296296296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1168661', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1102, 'n_words': 328}