How to use capped method in hypothesis

Best Python code snippet using hypothesis

baseline_functions.py

Source:baseline_functions.py Github

copy

Full Screen

1from helper_functions import *2from error_functions import *3from data_get import *4from calendar_date import *5import global_vars6from datetime import datetime7# runBaseline(interval_df, DRDays, temp_df, interval, date, storage_list)8# runs baseline functions for an SAID for given day using passed in data9# input10# interval_df, pandas.Dataframe, contains all interval data relevant to SAID11# DRdays, list, contains list of DR event dates in datetime form12# temp_df, pandas.Dataframe, contains all temperature data13# interval, int, 15 or 60, data collection interval used to find correct sql table14# date, pandas.datetime, date to run baselines on 15# storage_list, list, starter list for new row16# output17# row_data, list, all data including baseline for specific SAID 18def runBaseline(interval_df, DRDays, temp_df, interval, date, storage_list):19 try:20 maxTemp = getMaxTemp(temp_df, date)21 if(global_vars.PRINTFLAG >= 2):22 print("Max Temp is",maxTemp,"F")23 except:24 # print("Failed MaxTemp")25 return 'NA'26 maxTemp = str(maxTemp)27 # used for time inputs28 twoPM = pd.to_datetime(('14:00').strip(),format='%H:%M').time()29 eightPM = pd.to_datetime(('20:00').strip(),format='%H:%M').time()30 31 try:32 errorsTTN = getTenTenNonAdjustment(interval_df, DRDays, date)33 except:34 return 'NA'35 if errorsTTN == 'NA':36 return 'NA'37 try:38 errorsTTA, cappedAdjustmentsErrorsTTA = getTenTenWithAdjustment(interval_df, DRDays, date, twoPM, interval)39 except:40 return 'NA'41 if errorsTTA == 'NA':42 return 'NA'43 errorsThTN = getThreeTenNonAdjustment(interval_df, DRDays, date, twoPM, eightPM)44 if errorsThTN == 'NA':45 return 'NA'46 try:47 errorsThTA, cappedAdjustmentsErrorsThTA = getThreeTenWithAdjustment(interval_df, DRDays, date, twoPM, eightPM, interval)48 except:49 return 'NA'50 if errorsThTA == 'NA':51 return 'NA'52 try:53 errorsFN, cappedAdjustmentsErrorsFN = getFourNintyWeather(interval_df, DRDays, temp_df, date)54 except:55 return 'NA'56 if errorsFN == 'NA':57 return 'NA'58 if isHoliday(date):59 try:60 errorsF, cappedAdjustmentsErrorsF = getThreeFiveWeather(interval_df, DRDays, temp_df, date)61 except:62 return 'NA'63 if errorsF == 'NA':64 return 'NA'65 if(global_vars.PRINTFLAG >= 2):66 print("errors", errorsF)67 print("cappedAdjustmentsErrors", cappedAdjustmentsErrorsF)68 try:69 errorsT, cappedAdjustmentsErrorsT = getFourFourWeather(interval_df, DRDays, temp_df, date)70 except:71 return 'NA'72 if errorsT == 'NA':73 return 'NA'74 75 #bussinessday76 else:77 try:78 errorsF, cappedAdjustmentsErrorsF = getFiveTenWeather(interval_df, DRDays, temp_df, date)79 except:80 return 'NA'81 if errorsF == 'NA':82 return 'NA'83 try: 84 errorsT, cappedAdjustmentsErrorsT = getTenTenWeather(interval_df, DRDays, temp_df, date)85 except:86 return 'NA'87 if errorsT == 'NA':88 return 'NA'89 today = str(datetime.now().date())90 row_data = [errorsTTN[0], errorsTTN[1], errorsTTN[2], errorsTTA[0], errorsTTA[1], errorsTTA[2], cappedAdjustmentsErrorsTTA[0][0], cappedAdjustmentsErrorsTTA[0][1], cappedAdjustmentsErrorsTTA[0][2], cappedAdjustmentsErrorsTTA[1][0], cappedAdjustmentsErrorsTTA[1][1], cappedAdjustmentsErrorsTTA[1][2], cappedAdjustmentsErrorsTTA[2][0], cappedAdjustmentsErrorsTTA[2][1], cappedAdjustmentsErrorsTTA[2][2], cappedAdjustmentsErrorsTTA[3][0], cappedAdjustmentsErrorsTTA[3][1], cappedAdjustmentsErrorsTTA[3][2], cappedAdjustmentsErrorsTTA[4][0], cappedAdjustmentsErrorsTTA[4][1], cappedAdjustmentsErrorsTTA[4][2], cappedAdjustmentsErrorsTTA[5][0], cappedAdjustmentsErrorsTTA[5][1], cappedAdjustmentsErrorsTTA[5][2], cappedAdjustmentsErrorsTTA[6][0], cappedAdjustmentsErrorsTTA[6][1], cappedAdjustmentsErrorsTTA[6][2], cappedAdjustmentsErrorsTTA[7][0], cappedAdjustmentsErrorsTTA[7][1], cappedAdjustmentsErrorsTTA[7][2], cappedAdjustmentsErrorsTTA[8][0], cappedAdjustmentsErrorsTTA[8][1], cappedAdjustmentsErrorsTTA[8][2], cappedAdjustmentsErrorsTTA[9][0], cappedAdjustmentsErrorsTTA[9][1], cappedAdjustmentsErrorsTTA[9][2], cappedAdjustmentsErrorsTTA[10][0], cappedAdjustmentsErrorsTTA[10][1], cappedAdjustmentsErrorsTTA[10][2], errorsThTN[0], errorsThTN[1], errorsThTN[2], errorsThTA[0], errorsThTA[1], errorsThTA[2], cappedAdjustmentsErrorsThTA[0][0], cappedAdjustmentsErrorsThTA[0][1], cappedAdjustmentsErrorsThTA[0][2], cappedAdjustmentsErrorsThTA[1][0], cappedAdjustmentsErrorsThTA[1][1], cappedAdjustmentsErrorsThTA[1][2], cappedAdjustmentsErrorsThTA[2][0], cappedAdjustmentsErrorsThTA[2][1], cappedAdjustmentsErrorsThTA[2][2], cappedAdjustmentsErrorsThTA[3][0], cappedAdjustmentsErrorsThTA[3][1], cappedAdjustmentsErrorsThTA[3][2], cappedAdjustmentsErrorsThTA[4][0], cappedAdjustmentsErrorsThTA[4][1], cappedAdjustmentsErrorsThTA[4][2], cappedAdjustmentsErrorsThTA[5][0], cappedAdjustmentsErrorsThTA[5][1], cappedAdjustmentsErrorsThTA[5][2], cappedAdjustmentsErrorsThTA[6][0], cappedAdjustmentsErrorsThTA[6][1], cappedAdjustmentsErrorsThTA[6][2], cappedAdjustmentsErrorsThTA[7][0], cappedAdjustmentsErrorsThTA[7][1], cappedAdjustmentsErrorsThTA[7][2], cappedAdjustmentsErrorsThTA[8][0], cappedAdjustmentsErrorsThTA[8][1], cappedAdjustmentsErrorsThTA[8][2], cappedAdjustmentsErrorsThTA[9][0], cappedAdjustmentsErrorsThTA[9][1], cappedAdjustmentsErrorsThTA[9][2], cappedAdjustmentsErrorsThTA[10][0], cappedAdjustmentsErrorsThTA[10][1], cappedAdjustmentsErrorsThTA[10][2], errorsFN[0], errorsFN[1], errorsFN[2], cappedAdjustmentsErrorsFN[0][0], cappedAdjustmentsErrorsFN[0][1], cappedAdjustmentsErrorsFN[0][2], cappedAdjustmentsErrorsFN[1][0], cappedAdjustmentsErrorsFN[1][1], cappedAdjustmentsErrorsFN[1][2], cappedAdjustmentsErrorsFN[2][0], cappedAdjustmentsErrorsFN[2][1], cappedAdjustmentsErrorsFN[2][2], cappedAdjustmentsErrorsFN[3][0], cappedAdjustmentsErrorsFN[3][1], cappedAdjustmentsErrorsFN[3][2], cappedAdjustmentsErrorsFN[4][0], cappedAdjustmentsErrorsFN[4][1], cappedAdjustmentsErrorsFN[4][2], cappedAdjustmentsErrorsFN[5][0], cappedAdjustmentsErrorsFN[5][1], cappedAdjustmentsErrorsFN[5][2], cappedAdjustmentsErrorsFN[6][0], cappedAdjustmentsErrorsFN[6][1], cappedAdjustmentsErrorsFN[6][2], cappedAdjustmentsErrorsFN[7][0], cappedAdjustmentsErrorsFN[7][1], cappedAdjustmentsErrorsFN[7][2], cappedAdjustmentsErrorsFN[8][0], cappedAdjustmentsErrorsFN[8][1], cappedAdjustmentsErrorsFN[8][2], cappedAdjustmentsErrorsFN[9][0], cappedAdjustmentsErrorsFN[9][1], cappedAdjustmentsErrorsFN[9][2], cappedAdjustmentsErrorsFN[10][0], cappedAdjustmentsErrorsFN[10][1], cappedAdjustmentsErrorsFN[10][2], errorsF[0], errorsF[1], errorsF[2], cappedAdjustmentsErrorsF[0][0], cappedAdjustmentsErrorsF[0][1], cappedAdjustmentsErrorsF[0][2], cappedAdjustmentsErrorsF[1][0], cappedAdjustmentsErrorsF[1][1], cappedAdjustmentsErrorsF[1][2], cappedAdjustmentsErrorsF[2][0], cappedAdjustmentsErrorsF[2][1], cappedAdjustmentsErrorsF[2][2], cappedAdjustmentsErrorsF[3][0], cappedAdjustmentsErrorsF[3][1], cappedAdjustmentsErrorsF[3][2], cappedAdjustmentsErrorsF[4][0], cappedAdjustmentsErrorsF[4][1], cappedAdjustmentsErrorsF[4][2], cappedAdjustmentsErrorsF[5][0], cappedAdjustmentsErrorsF[5][1], cappedAdjustmentsErrorsF[5][2], cappedAdjustmentsErrorsF[6][0], cappedAdjustmentsErrorsF[6][1], cappedAdjustmentsErrorsF[6][2], cappedAdjustmentsErrorsF[7][0], cappedAdjustmentsErrorsF[7][1], cappedAdjustmentsErrorsF[7][2], cappedAdjustmentsErrorsF[8][0], cappedAdjustmentsErrorsF[8][1], cappedAdjustmentsErrorsF[8][2], cappedAdjustmentsErrorsF[9][0], cappedAdjustmentsErrorsF[9][1], cappedAdjustmentsErrorsF[9][2], cappedAdjustmentsErrorsF[10][0], cappedAdjustmentsErrorsF[10][1], cappedAdjustmentsErrorsF[10][2], errorsT[0], errorsT[1], errorsT[2], cappedAdjustmentsErrorsT[0][0], cappedAdjustmentsErrorsT[0][1], cappedAdjustmentsErrorsT[0][2], cappedAdjustmentsErrorsT[1][0], cappedAdjustmentsErrorsT[1][1], cappedAdjustmentsErrorsT[1][2], cappedAdjustmentsErrorsT[2][0], cappedAdjustmentsErrorsT[2][1], cappedAdjustmentsErrorsT[2][2], cappedAdjustmentsErrorsT[3][0], cappedAdjustmentsErrorsT[3][1], cappedAdjustmentsErrorsT[3][2], cappedAdjustmentsErrorsT[4][0], cappedAdjustmentsErrorsT[4][1], cappedAdjustmentsErrorsT[4][2], cappedAdjustmentsErrorsT[5][0], cappedAdjustmentsErrorsT[5][1], cappedAdjustmentsErrorsT[5][2], cappedAdjustmentsErrorsT[6][0], cappedAdjustmentsErrorsT[6][1], cappedAdjustmentsErrorsT[6][2], cappedAdjustmentsErrorsT[7][0], cappedAdjustmentsErrorsT[7][1], cappedAdjustmentsErrorsT[7][2], cappedAdjustmentsErrorsT[8][0], cappedAdjustmentsErrorsT[8][1], cappedAdjustmentsErrorsT[8][2], cappedAdjustmentsErrorsT[9][0], cappedAdjustmentsErrorsT[9][1], cappedAdjustmentsErrorsT[9][2], cappedAdjustmentsErrorsT[10][0], cappedAdjustmentsErrorsT[10][1], cappedAdjustmentsErrorsT[10][2]]91 row_data.append(today)92 row_data.insert(0, maxTemp)93 # Holiday is H, Bussiness is B94 if isHoliday(date):95 row_data.insert(0, 'H')96 else:97 row_data.insert(0, 'B')98 row_data.insert(0, date)99 row_data.insert(0, storage_list[2])100 row_data.insert(0, storage_list[1])101 row_data.insert(0, storage_list[0])102 if(global_vars.PRINTFLAG >= 2):103 print("returning row")104 return row_data105def runBaseline2(interval_df, DRDays, temp_df, interval, date, storage_list):106 try:107 maxTemp = getMaxTemp(temp_df, date)108 if(global_vars.PRINTFLAG >= 2):109 print("Max Temp is",maxTemp,"F")110 except:111 # print("Failed MaxTemp")112 return 'NA'113 maxTemp = str(maxTemp)114 # used for time inputs115 twoPM = pd.to_datetime(('14:00').strip(),format='%H:%M').time()116 eightPM = pd.to_datetime(('20:00').strip(),format='%H:%M').time()117 118 try:119 errorsTTN = getTenTenNonAdjustment(interval_df, DRDays, date)120 except:121 return 'NA'122 if errorsTTN == 'NA':123 return 'NA'124 try:125 errorsTTA, cappedAdjustmentsErrorsTTA = getTenTenWithAdjustment(interval_df, DRDays, date, twoPM, interval)126 except:127 return 'NA'128 if errorsTTA == 'NA':129 return 'NA'130 errorsThTN = getThreeTenNonAdjustment(interval_df, DRDays, date, twoPM, eightPM)131 if errorsThTN == 'NA':132 return 'NA'133 try:134 errorsThTA, cappedAdjustmentsErrorsThTA = getThreeTenWithAdjustment(interval_df, DRDays, date, twoPM, eightPM, interval)135 except:136 return 'NA'137 if errorsThTA == 'NA':138 return 'NA'139 errorsFiveTN = getFiveTenNonAdjustment(interval_df, DRDays, date, twoPM, eightPM)140 if errorsThTN == 'NA':141 return 'NA'142 try:143 errorsFiveTA, cappedAdjustmentsErrorsFiveTA = getFiveTenWithAdjustment(interval_df, DRDays, date, twoPM, eightPM, interval)144 except:145 return 'NA'146 if errorsThTA == 'NA':147 return 'NA'148 try:149 errorsFN, cappedAdjustmentsErrorsFN = getFourNintyWeather(interval_df, DRDays, temp_df, date)150 except:151 return 'NA'152 if errorsFN == 'NA':153 return 'NA'154 if isHoliday(date):155 try:156 errorsF, cappedAdjustmentsErrorsF = getThreeFiveWeather(interval_df, DRDays, temp_df, date)157 except:158 return 'NA'159 if errorsF == 'NA':160 return 'NA'161 if(global_vars.PRINTFLAG >= 2):162 print("errors", errorsF)163 print("cappedAdjustmentsErrors", cappedAdjustmentsErrorsF)164 try:165 errorsT, cappedAdjustmentsErrorsT = getFourFourWeather(interval_df, DRDays, temp_df, date)166 except:167 return 'NA'168 if errorsT == 'NA':169 return 'NA'170 171 #bussinessday172 else:173 try:174 errorsF, cappedAdjustmentsErrorsF = getFiveTenWeather(interval_df, DRDays, temp_df, date)175 except:176 return 'NA'177 if errorsF == 'NA':178 return 'NA'179 try: 180 errorsT, cappedAdjustmentsErrorsT = getTenTenWeather(interval_df, DRDays, temp_df, date)181 except:182 return 'NA'183 if errorsT == 'NA':184 return 'NA'185 today = str(datetime.now().date())186 row_data = [errorsTTN[0], errorsTTN[1], errorsTTN[2], errorsTTA[0], errorsTTA[1], errorsTTA[2], cappedAdjustmentsErrorsTTA[0][0], cappedAdjustmentsErrorsTTA[0][1], cappedAdjustmentsErrorsTTA[0][2], cappedAdjustmentsErrorsTTA[1][0], cappedAdjustmentsErrorsTTA[1][1], cappedAdjustmentsErrorsTTA[1][2], cappedAdjustmentsErrorsTTA[2][0], cappedAdjustmentsErrorsTTA[2][1], cappedAdjustmentsErrorsTTA[2][2], cappedAdjustmentsErrorsTTA[3][0], cappedAdjustmentsErrorsTTA[3][1], cappedAdjustmentsErrorsTTA[3][2], cappedAdjustmentsErrorsTTA[4][0], cappedAdjustmentsErrorsTTA[4][1], cappedAdjustmentsErrorsTTA[4][2], cappedAdjustmentsErrorsTTA[5][0], cappedAdjustmentsErrorsTTA[5][1], cappedAdjustmentsErrorsTTA[5][2], cappedAdjustmentsErrorsTTA[6][0], cappedAdjustmentsErrorsTTA[6][1], cappedAdjustmentsErrorsTTA[6][2], cappedAdjustmentsErrorsTTA[7][0], cappedAdjustmentsErrorsTTA[7][1], cappedAdjustmentsErrorsTTA[7][2], cappedAdjustmentsErrorsTTA[8][0], cappedAdjustmentsErrorsTTA[8][1], cappedAdjustmentsErrorsTTA[8][2], cappedAdjustmentsErrorsTTA[9][0], cappedAdjustmentsErrorsTTA[9][1], cappedAdjustmentsErrorsTTA[9][2], cappedAdjustmentsErrorsTTA[10][0], cappedAdjustmentsErrorsTTA[10][1], cappedAdjustmentsErrorsTTA[10][2], errorsThTN[0], errorsThTN[1], errorsThTN[2], errorsThTA[0], errorsThTA[1], errorsThTA[2], cappedAdjustmentsErrorsThTA[0][0], cappedAdjustmentsErrorsThTA[0][1], cappedAdjustmentsErrorsThTA[0][2], cappedAdjustmentsErrorsThTA[1][0], cappedAdjustmentsErrorsThTA[1][1], cappedAdjustmentsErrorsThTA[1][2], cappedAdjustmentsErrorsThTA[2][0], cappedAdjustmentsErrorsThTA[2][1], cappedAdjustmentsErrorsThTA[2][2], cappedAdjustmentsErrorsThTA[3][0], cappedAdjustmentsErrorsThTA[3][1], cappedAdjustmentsErrorsThTA[3][2], cappedAdjustmentsErrorsThTA[4][0], cappedAdjustmentsErrorsThTA[4][1], cappedAdjustmentsErrorsThTA[4][2], cappedAdjustmentsErrorsThTA[5][0], cappedAdjustmentsErrorsThTA[5][1], cappedAdjustmentsErrorsThTA[5][2], cappedAdjustmentsErrorsThTA[6][0], cappedAdjustmentsErrorsThTA[6][1], cappedAdjustmentsErrorsThTA[6][2], cappedAdjustmentsErrorsThTA[7][0], cappedAdjustmentsErrorsThTA[7][1], cappedAdjustmentsErrorsThTA[7][2], cappedAdjustmentsErrorsThTA[8][0], cappedAdjustmentsErrorsThTA[8][1], cappedAdjustmentsErrorsThTA[8][2], cappedAdjustmentsErrorsThTA[9][0], cappedAdjustmentsErrorsThTA[9][1], cappedAdjustmentsErrorsThTA[9][2], cappedAdjustmentsErrorsThTA[10][0], cappedAdjustmentsErrorsThTA[10][1], cappedAdjustmentsErrorsThTA[10][2], errorsFiveTN[0], errorsFiveTN[1], errorsFiveTN[2], errorsFiveTA[0], errorsFiveTA[1], errorsFiveTA[2], cappedAdjustmentsErrorsFiveTA[0][0], cappedAdjustmentsErrorsFiveTA[0][1], cappedAdjustmentsErrorsFiveTA[0][2], cappedAdjustmentsErrorsFiveTA[1][0], cappedAdjustmentsErrorsFiveTA[1][1], cappedAdjustmentsErrorsFiveTA[1][2], cappedAdjustmentsErrorsFiveTA[2][0], cappedAdjustmentsErrorsFiveTA[2][1], cappedAdjustmentsErrorsFiveTA[2][2], cappedAdjustmentsErrorsFiveTA[3][0], cappedAdjustmentsErrorsFiveTA[3][1], cappedAdjustmentsErrorsFiveTA[3][2], cappedAdjustmentsErrorsFiveTA[4][0], cappedAdjustmentsErrorsFiveTA[4][1], cappedAdjustmentsErrorsFiveTA[4][2], cappedAdjustmentsErrorsFiveTA[5][0], cappedAdjustmentsErrorsFiveTA[5][1], cappedAdjustmentsErrorsFiveTA[5][2], cappedAdjustmentsErrorsFiveTA[6][0], cappedAdjustmentsErrorsFiveTA[6][1], cappedAdjustmentsErrorsFiveTA[6][2], cappedAdjustmentsErrorsFiveTA[7][0], cappedAdjustmentsErrorsFiveTA[7][1], cappedAdjustmentsErrorsFiveTA[7][2], cappedAdjustmentsErrorsFiveTA[8][0], cappedAdjustmentsErrorsFiveTA[8][1], cappedAdjustmentsErrorsFiveTA[8][2], cappedAdjustmentsErrorsFiveTA[9][0], cappedAdjustmentsErrorsFiveTA[9][1], cappedAdjustmentsErrorsFiveTA[9][2], cappedAdjustmentsErrorsFiveTA[10][0], cappedAdjustmentsErrorsFiveTA[10][1], cappedAdjustmentsErrorsFiveTA[10][2], errorsFN[0], errorsFN[1], errorsFN[2], cappedAdjustmentsErrorsFN[0][0], cappedAdjustmentsErrorsFN[0][1], cappedAdjustmentsErrorsFN[0][2], cappedAdjustmentsErrorsFN[1][0], cappedAdjustmentsErrorsFN[1][1], cappedAdjustmentsErrorsFN[1][2], cappedAdjustmentsErrorsFN[2][0], cappedAdjustmentsErrorsFN[2][1], cappedAdjustmentsErrorsFN[2][2], cappedAdjustmentsErrorsFN[3][0], cappedAdjustmentsErrorsFN[3][1], cappedAdjustmentsErrorsFN[3][2], cappedAdjustmentsErrorsFN[4][0], cappedAdjustmentsErrorsFN[4][1], cappedAdjustmentsErrorsFN[4][2], cappedAdjustmentsErrorsFN[5][0], cappedAdjustmentsErrorsFN[5][1], cappedAdjustmentsErrorsFN[5][2], cappedAdjustmentsErrorsFN[6][0], cappedAdjustmentsErrorsFN[6][1], cappedAdjustmentsErrorsFN[6][2], cappedAdjustmentsErrorsFN[7][0], cappedAdjustmentsErrorsFN[7][1], cappedAdjustmentsErrorsFN[7][2], cappedAdjustmentsErrorsFN[8][0], cappedAdjustmentsErrorsFN[8][1], cappedAdjustmentsErrorsFN[8][2], cappedAdjustmentsErrorsFN[9][0], cappedAdjustmentsErrorsFN[9][1], cappedAdjustmentsErrorsFN[9][2], cappedAdjustmentsErrorsFN[10][0], cappedAdjustmentsErrorsFN[10][1], cappedAdjustmentsErrorsFN[10][2], errorsF[0], errorsF[1], errorsF[2], cappedAdjustmentsErrorsF[0][0], cappedAdjustmentsErrorsF[0][1], cappedAdjustmentsErrorsF[0][2], cappedAdjustmentsErrorsF[1][0], cappedAdjustmentsErrorsF[1][1], cappedAdjustmentsErrorsF[1][2], cappedAdjustmentsErrorsF[2][0], cappedAdjustmentsErrorsF[2][1], cappedAdjustmentsErrorsF[2][2], cappedAdjustmentsErrorsF[3][0], cappedAdjustmentsErrorsF[3][1], cappedAdjustmentsErrorsF[3][2], cappedAdjustmentsErrorsF[4][0], cappedAdjustmentsErrorsF[4][1], cappedAdjustmentsErrorsF[4][2], cappedAdjustmentsErrorsF[5][0], cappedAdjustmentsErrorsF[5][1], cappedAdjustmentsErrorsF[5][2], cappedAdjustmentsErrorsF[6][0], cappedAdjustmentsErrorsF[6][1], cappedAdjustmentsErrorsF[6][2], cappedAdjustmentsErrorsF[7][0], cappedAdjustmentsErrorsF[7][1], cappedAdjustmentsErrorsF[7][2], cappedAdjustmentsErrorsF[8][0], cappedAdjustmentsErrorsF[8][1], cappedAdjustmentsErrorsF[8][2], cappedAdjustmentsErrorsF[9][0], cappedAdjustmentsErrorsF[9][1], cappedAdjustmentsErrorsF[9][2], cappedAdjustmentsErrorsF[10][0], cappedAdjustmentsErrorsF[10][1], cappedAdjustmentsErrorsF[10][2], errorsT[0], errorsT[1], errorsT[2], cappedAdjustmentsErrorsT[0][0], cappedAdjustmentsErrorsT[0][1], cappedAdjustmentsErrorsT[0][2], cappedAdjustmentsErrorsT[1][0], cappedAdjustmentsErrorsT[1][1], cappedAdjustmentsErrorsT[1][2], cappedAdjustmentsErrorsT[2][0], cappedAdjustmentsErrorsT[2][1], cappedAdjustmentsErrorsT[2][2], cappedAdjustmentsErrorsT[3][0], cappedAdjustmentsErrorsT[3][1], cappedAdjustmentsErrorsT[3][2], cappedAdjustmentsErrorsT[4][0], cappedAdjustmentsErrorsT[4][1], cappedAdjustmentsErrorsT[4][2], cappedAdjustmentsErrorsT[5][0], cappedAdjustmentsErrorsT[5][1], cappedAdjustmentsErrorsT[5][2], cappedAdjustmentsErrorsT[6][0], cappedAdjustmentsErrorsT[6][1], cappedAdjustmentsErrorsT[6][2], cappedAdjustmentsErrorsT[7][0], cappedAdjustmentsErrorsT[7][1], cappedAdjustmentsErrorsT[7][2], cappedAdjustmentsErrorsT[8][0], cappedAdjustmentsErrorsT[8][1], cappedAdjustmentsErrorsT[8][2], cappedAdjustmentsErrorsT[9][0], cappedAdjustmentsErrorsT[9][1], cappedAdjustmentsErrorsT[9][2], cappedAdjustmentsErrorsT[10][0], cappedAdjustmentsErrorsT[10][1], cappedAdjustmentsErrorsT[10][2]]187 # errorsFiveTN[0], errorsFiveTN[1], errorsFiveTN[2], errorsFiveTA[0], errorsFiveTA[1], errorsFiveTA[2], cappedAdjustmentsErrorsFiveTA[0][0], cappedAdjustmentsErrorsFiveTA[0][1], cappedAdjustmentsErrorsFiveTA[0][2], cappedAdjustmentsErrorsFiveTA[1][0], cappedAdjustmentsErrorsFiveTA[1][1], cappedAdjustmentsErrorsFiveTA[1][2], cappedAdjustmentsErrorsFiveTA[2][0], cappedAdjustmentsErrorsFiveTA[2][1], cappedAdjustmentsErrorsFiveTA[2][2], cappedAdjustmentsErrorsFiveTA[3][0], cappedAdjustmentsErrorsFiveTA[3][1], cappedAdjustmentsErrorsFiveTA[3][2], cappedAdjustmentsErrorsFiveTA[4][0], cappedAdjustmentsErrorsFiveTA[4][1], cappedAdjustmentsErrorsFiveTA[4][2], cappedAdjustmentsErrorsFiveTA[5][0], cappedAdjustmentsErrorsFiveTA[5][1], cappedAdjustmentsErrorsFiveTA[5][2], cappedAdjustmentsErrorsFiveTA[6][0], cappedAdjustmentsErrorsFiveTA[6][1], cappedAdjustmentsErrorsFiveTA[6][2], cappedAdjustmentsErrorsFiveTA[7][0], cappedAdjustmentsErrorsFiveTA[7][1], cappedAdjustmentsErrorsFiveTA[7][2], cappedAdjustmentsErrorsFiveTA[8][0], cappedAdjustmentsErrorsFiveTA[8][1], cappedAdjustmentsErrorsFiveTA[8][2], cappedAdjustmentsErrorsFiveTA[9][0], cappedAdjustmentsErrorsFiveTA[9][1], cappedAdjustmentsErrorsFiveTA[9][2], cappedAdjustmentsErrorsFiveTA[10][0], cappedAdjustmentsErrorsFiveTA[10][1], cappedAdjustmentsErrorsFiveTA[10][2],188 row_data.append(today)189 row_data.insert(0, maxTemp)190 # Holiday is H, Bussiness is B191 if isHoliday(date):192 row_data.insert(0, 'H')193 else:194 row_data.insert(0, 'B')195 row_data.insert(0, date)196 row_data.insert(0, storage_list[2])197 row_data.insert(0, storage_list[1])198 row_data.insert(0, storage_list[0])199 if(global_vars.PRINTFLAG >= 2):200 print("returning row")201 return row_data202# runFrequentBaseline(interval_df, DRDays, temp_df, interval, date, storage_list)203# runs baseline functions for an SAID for given day using passed in data204# input205# interval_df, pandas.Dataframe, contains all interval data relevant to SAID206# DRdays, list, contains list of DR event dates in datetime form207# temp_df, pandas.Dataframe, contains all temperature data208# interval, int, 15 or 60, data collection interval used to find correct sql table209# date, pandas.datetime, date to run baselines on 210# storage_list, list, starter list for new row211# output212# row_data, list, all data including baseline for specific SAID 213def runFrequentBaseline(interval_df, DRDays, temp_df, interval, date, storage_list):214 try:215 maxTemp = getMaxTemp(temp_df, date)216 if(global_vars.PRINTFLAG >= 2):217 print("Max Temp is",maxTemp,"F")218 except:219 print("Might be error with python version if this prints many times, try Python 3.5.5")220 return 'NA'221 maxTemp = str(maxTemp)222 # used for time inputs223 twoAM = pd.to_datetime(('02:00').strip(),format='%H:%M').time() 224 fourAM = pd.to_datetime(('04:00').strip(),format='%H:%M').time() 225 eightAM = pd.to_datetime(('08:00').strip(),format='%H:%M').time()226 tenAM = pd.to_datetime(('10:00').strip(),format='%H:%M').time()227 twoPM = pd.to_datetime(('14:00').strip(),format='%H:%M').time()228 fourPM = pd.to_datetime(('16:00').strip(),format='%H:%M').time() 229 eightPM = pd.to_datetime(('20:00').strip(),format='%H:%M').time()230 tenPM = pd.to_datetime(('22:00').strip(),format='%H:%M').time() 231 event_times = [fourAM, eightAM, tenAM, twoPM, fourPM, eightPM, tenPM]232 event_tuples = [(eightAM, tenAM), (twoPM, fourPM), (eightPM, tenPM), 233 (fourAM, eightAM), (tenAM, twoPM), (fourPM, eightPM),234 (fourAM, tenAM), (tenAM, fourPM), (fourPM, tenPM), 235 (eightAM, fourPM), (twoPM, tenPM)]236 # all data that will be returned for that date237 row_data = []238 try:239 for start_time in event_times:240 errorsTTA, cappedAdjustmentsErrorsTTA = getTenTenWithAdjustment(interval_df, DRDays, date, start_time, interval)241 if errorsTTA == 'NA':242 return 'NA'243 row_data.append(errorsTTA[0])244 row_data.append(errorsTTA[1])245 row_data.append(errorsTTA[2]) 246 except:247 return 'NA'248 try:249 for (start_time, end_time) in event_tuples:250 errorsThTN = getThreeTenNonAdjustment(interval_df, DRDays, date, start_time, end_time)251 if errorsThTN == 'NA':252 return 'NA'253 row_data.append(errorsThTN[0])254 row_data.append(errorsThTN[1])255 row_data.append(errorsThTN[2]) 256 except:257 return 'NA'258 try:259 for (start_time, end_time) in event_tuples:260 errorsThTA, cappedAdjustmentsErrorsThTA = getThreeTenWithAdjustment(interval_df, DRDays, date, start_time, end_time, interval)261 if errorsTTA == 'NA':262 return 'NA'263 row_data.append(errorsThTA[0])264 row_data.append(errorsThTA[1])265 row_data.append(errorsThTA[2]) 266 except:267 return 'NA'268 today = str(datetime.now().date())269 row_data.append(today)270 row_data.insert(0, maxTemp)271 # Holiday is H, Bussiness is B272 if isHoliday(date):273 row_data.insert(0, 'H')274 else:275 row_data.insert(0, 'B')276 row_data.insert(0, date)277 row_data.insert(0, storage_list[2])278 row_data.insert(0, storage_list[1])279 row_data.insert(0, storage_list[0])280 if(global_vars.PRINTFLAG >= 2):281 print("returning row")282 return row_data283def runXSPBaseline(interval_df, DRDays, temp_df, interval, date, storage_list):284 # used for time inputs285 twoPM = pd.to_datetime(('14:00').strip(),format='%H:%M').time()286 eightPM = pd.to_datetime(('20:00').strip(),format='%H:%M').time()287 288 try:289 errorsTTN = getTenTenNonAdjustment(interval_df, DRDays, date)290 except:291 errorsTTN = ['NA','NA','NA']292 try:293 errorsTTA, cappedAdjustmentsErrorsTTA = getTenTenWithAdjustment(interval_df, DRDays, date, twoPM, interval)294 except:295 errorsTTA = ['NA','NA','NA']296 try:297 errorsThTN = getThreeTenNonAdjustment(interval_df, DRDays, date, twoPM, eightPM)298 except:299 errorsThTN = ['NA','NA','NA']300 try:301 errorsThTA, cappedAdjustmentsErrorsThTA = getThreeTenWithAdjustment(interval_df, DRDays, date, twoPM, eightPM, interval)302 except:303 errorsThTA = ['NA','NA','NA'] 304 row_data = [errorsTTN[0], errorsTTN[1], errorsTTN[2], errorsTTA[0], errorsTTA[1], errorsTTA[2], errorsThTN[0], errorsThTN[1], errorsThTN[2], errorsThTA[0], errorsThTA[1], errorsThTA[2]]305 return row_data306# getTenTenNonAdjustment(interval_df, DRdays, date)307# gets error rates for 10-in-10 Baseline with no adjustment308# input309# interval_df, pandas.Dataframe, contains all interval data relevant to SAID310# DRdays, list, contains list of DR event dates in datetime form311# date, pandas.datetime, date to run baselines on 312# output313# error, triple, (cv, rmse, mape)314def getTenTenNonAdjustment(interval_df, DRDays, date):315 # get numpy array interval data for past 10 days and current date (11 rows)316 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 10, True)317 if numberData.shape[0] <= 10:318 if(global_vars.PRINTFLAG >= 2):319 print("Dataframe has only",numberData.shape[0], "days")320 return 'NA'321 prediction = np.mean(numberData[0:numberData.shape[0]-1], axis=0)322 actual = numberData[numberData.shape[0]-1,:]323 if(global_vars.PRINTFLAG >= 2):324 print("10-in-10 With No Adjustment:")325 errors = getErrors(prediction, actual)326 return errors327# getTenTenWithAdjustment(interval_df, DRdays, date, timeInitial, timeFinal)328# gets error rates for 10-in-10 Baseline with adjustment based on the start and end time329# input330# interval_df, pandas.Dataframe, contains all interval data relevant to SAID331# DRdays, list, contains list of DR event dates in datetime form332# date, pandas.datetime, date to run baselines on 333# eventTime, datetime.time, time of start of event334# interval, int, period between each interval measurement335# output336# error, triple, (cv, rmse, mape)337# cappedAdjustmentsErrors,list of triples, error rates for each capped adjustment in list form338def getTenTenWithAdjustment(interval_df, DRDays, date, eventTime, interval):339 # get numpy array interval data for past 10 days and current date (11 rows)340 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 10, True)341 if numberData.shape[0] <= 10:342 if(global_vars.PRINTFLAG >= 2):343 print("Dataframe has only",numberData.shape[0], "days")344 return 'NA','NA'345 prediction = np.mean(numberData[0:numberData.shape[0]-1], axis=0)346 actual = numberData[numberData.shape[0]-1,:]347 adjustment = getAdjustment(numberData, time_indexes, eventTime, interval)348 if(global_vars.PRINTFLAG >= 2):349 print("10-10 With Adjustment Capped:")350 # -50,-40,-30,-20,-10,0 ,10,20,30,40,50 adjustment list (no)351 cappedAdjustmentsErrors = getCappedAdjustments(prediction, actual, adjustment)352 prediction = [data * adjustment for data in prediction]353 # print("10pred", prediction)354 if(global_vars.PRINTFLAG >= 2):355 print("10-in-10 With Adjustment:")356 errors = getErrors(prediction, actual)357 return errors, cappedAdjustmentsErrors358# getThreeTenNonAdjustment(interval_df, DRdays, date)359# gets error rates for 3-in-10 Baseline (top three days of the last 10) with no adjustment360# input361# interval_df, pandas.Dataframe, contains all interval data relevant to SAID362# DRdays, list, contains list of DR event dates in datetime form363# date, pandas.datetime, date to run baselines on 364# eventStart, datetime.time, event start time365# eventEnd, datetime.time, event end time366# output367# error, triple, (cv, rmse, mape)368def getThreeTenNonAdjustment(interval_df, DRDays, date, eventStart, eventEnd):369 # get numpy array interval data for past 10 days and current date (11 rows)370 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 10, True)371 if numberData.shape[0] <=10:372 if(global_vars.PRINTFLAG >= 2):373 print("Dataframe has only",numberData.shape[0], "days")374 return 'NA','NA'375 numberData = np.asarray(numberData)376 eventStartTimeIndex = time_indexes.index(eventStart)377 eventEndTimeIndex = time_indexes.index(eventEnd)378 numberData_row_part_totals = np.sum(numberData[0:numberData.shape[0]-1, eventStartTimeIndex:eventEndTimeIndex], axis=1)379 max_rows = numberData_row_part_totals.argsort()[-3:][::-1]380 381 prediction = np.mean(numberData[max_rows], axis=0)382 actual = numberData[numberData.shape[0]-1,:]383 if(global_vars.PRINTFLAG >= 2):384 print("3-in-10 With No Adjustment:")385 errors = getErrors(prediction, actual)386 return errors387# getThreeTenWithAdjustment(interval_df, DRdays, date, eventTime, interval)388# gets error rates for 3-in-10 Baseline (top three days of the last 10) with adjustment389# input390# interval_df, pandas.Dataframe, contains all interval data relevant to SAID391# DRdays, list, contains list of DR event dates in datetime form392# date, pandas.datetime, date to run baselines on 393# eventTime, datetime.time, time of start of event394# eventEnd, datetime.time, event end time395# interval, int, period between each interval measurement396# output397# error, triple, (cv, rmse, mape)398# cappedAdjustmentsErrors,list of triples, error rates for each capped adjustment in list form399def getThreeTenWithAdjustment(interval_df, DRDays, date, eventTime, eventEnd, interval):400 # get numpy array interval data for past 10 days and current date (11 rows)401 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 10, True)402 if numberData.shape[0] <=10:403 if(global_vars.PRINTFLAG >= 2):404 print("Dataframe has only",numberData.shape[0], "days")405 return 'NA','NA'406 numberData = np.asarray(numberData)407 eventStartTimeIndex = time_indexes.index(eventTime)408 eventEndTimeIndex = time_indexes.index(eventEnd)409 numberData_row_part_totals = np.sum(numberData[0:numberData.shape[0]-1, eventStartTimeIndex:eventEndTimeIndex], axis=1)410 max_rows = numberData_row_part_totals.argsort()[-3:][::-1]411 prediction = np.mean(numberData[max_rows], axis=0)412 actual = numberData[numberData.shape[0]-1,:]413 414 max_rows = max_rows.tolist()415 max_rows.append(numberData.shape[0]-1)416 # max_rows = np.vstack([max_rows, newrow])417 adjustment = getAdjustment(numberData[max_rows], time_indexes, eventTime, interval)418 419 # print("ey\n",numberData[max_rows])420 # print("adjustment",adjustment)421 if(global_vars.PRINTFLAG >= 2):422 print("3-10 With Adjustment Capped:")423 # -50,-40,-30,-20,-10,0 ,10,20,30,40,50 adjustment list (no)424 cappedAdjustmentsErrors = getCappedAdjustments(prediction, actual, adjustment)425 if(global_vars.PRINTFLAG >= 2):426 print("adjustment", adjustment)427 prediction = [data * adjustment for data in prediction]428 # print("3pred", prediction)429 if(global_vars.PRINTFLAG >= 2):430 print("3-in-10 With Adjustment:")431 errors = getErrors(prediction, actual)432 return errors, cappedAdjustmentsErrors433# getThreeTenNonAdjustment(interval_df, DRdays, date)434# gets error rates for 3-in-10 Baseline (top three days of the last 10) with no adjustment435# input436# interval_df, pandas.Dataframe, contains all interval data relevant to SAID437# DRdays, list, contains list of DR event dates in datetime form438# date, pandas.datetime, date to run baselines on 439# eventStart, datetime.time, event start time440# eventEnd, datetime.time, event end time441# output442# error, triple, (cv, rmse, mape)443def getFiveTenNonAdjustment(interval_df, DRDays, date, eventStart, eventEnd):444 # get numpy array interval data for past 10 days and current date (11 rows)445 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 10, True)446 if numberData.shape[0] <=10:447 if(global_vars.PRINTFLAG >= 2):448 print("Dataframe has only",numberData.shape[0], "days")449 return 'NA','NA'450 numberData = np.asarray(numberData)451 eventStartTimeIndex = time_indexes.index(eventStart)452 eventEndTimeIndex = time_indexes.index(eventEnd)453 numberData_row_part_totals = np.sum(numberData[0:numberData.shape[0]-1, eventStartTimeIndex:eventEndTimeIndex], axis=1)454 max_rows = numberData_row_part_totals.argsort()[-5:][::-1]455 456 prediction = np.mean(numberData[max_rows], axis=0)457 actual = numberData[numberData.shape[0]-1,:]458 if(global_vars.PRINTFLAG >= 2):459 print("3-in-10 With No Adjustment:")460 errors = getErrors(prediction, actual)461 return errors462# getThreeTenWithAdjustment(interval_df, DRdays, date, eventTime, interval)463# gets error rates for 3-in-10 Baseline (top three days of the last 10) with adjustment464# input465# interval_df, pandas.Dataframe, contains all interval data relevant to SAID466# DRdays, list, contains list of DR event dates in datetime form467# date, pandas.datetime, date to run baselines on 468# eventTime, datetime.time, time of start of event469# eventEnd, datetime.time, event end time470# interval, int, period between each interval measurement471# output472# error, triple, (cv, rmse, mape)473# cappedAdjustmentsErrors,list of triples, error rates for each capped adjustment in list form474def getFiveTenWithAdjustment(interval_df, DRDays, date, eventTime, eventEnd, interval):475 # get numpy array interval data for past 10 days and current date (11 rows)476 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 10, True)477 if numberData.shape[0] <=10:478 if(global_vars.PRINTFLAG >= 2):479 print("Dataframe has only",numberData.shape[0], "days")480 return 'NA','NA'481 numberData = np.asarray(numberData)482 eventStartTimeIndex = time_indexes.index(eventTime)483 eventEndTimeIndex = time_indexes.index(eventEnd)484 numberData_row_part_totals = np.sum(numberData[0:numberData.shape[0]-1, eventStartTimeIndex:eventEndTimeIndex], axis=1)485 max_rows = numberData_row_part_totals.argsort()[-5:][::-1]486 prediction = np.mean(numberData[max_rows], axis=0)487 actual = numberData[numberData.shape[0]-1,:]488 489 max_rows = max_rows.tolist()490 max_rows.append(numberData.shape[0]-1)491 # max_rows = np.vstack([max_rows, newrow])492 adjustment = getAdjustment(numberData[max_rows], time_indexes, eventTime, interval)493 494 # print("ey\n",numberData[max_rows])495 # print("adjustment",adjustment)496 if(global_vars.PRINTFLAG >= 2):497 print("3-10 With Adjustment Capped:")498 # -50,-40,-30,-20,-10,0 ,10,20,30,40,50 adjustment list (no)499 cappedAdjustmentsErrors = getCappedAdjustments(prediction, actual, adjustment)500 if(global_vars.PRINTFLAG >= 2):501 print("adjustment", adjustment)502 prediction = [data * adjustment for data in prediction]503 # print("3pred", prediction)504 if(global_vars.PRINTFLAG >= 2):505 print("3-in-10 With Adjustment:")506 errors = getErrors(prediction, actual)507 return errors, cappedAdjustmentsErrors508# getFourNintyWeather(interval_df, DRDays, temp_df, date)509# runs 4-90 baseline function and return error. Top 4 weather days of any error510# input511# interval_df, pandas.Dataframe, contains all interval data relevant to SAID512# DRdays, list, contains list of DR event dates in datetime form513# temp_df, pandas.Dataframe, contains all temperature data514# date, pandas.datetime, date to run baselines on 515# output516# error, triple, (cv, rmse, mape)517# cappedAdjustmentsErrors,list of triples, error rates for each capped adjustment in list form518def getFourNintyWeather(interval_df, DRDays, temp_df, date):519 tempHours, tempData = getPastDaysTemp(temp_df, DRDays, date, 90, False)520 # print("td",len(tempData))521 # print(tempData)522 # Make all tempDatas in the same hour the same523 tempData = adjustTimeTemp(tempHours, tempData)524 # print("td",len(tempData))525 # print(tempData)526 # Temp measurements per day527 chunksize = 48528 # to split days into seperate rows529 max_days_temp = []530 try:531 for i in range(90):532 newRow = max(tempData[(i*chunksize):(i+1)*chunksize])533 max_days_temp.append(newRow)534 except:535 return 'NA','NA'536 # get index of max temps from high to low537 max_days_temp = np.asarray(max_days_temp)538 indexList = list(max_days_temp.argsort())539 indexList.reverse()540 # get numpy array interval data for past 90 days and current date (91 rows)541 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 90, False)542 if numberData.shape[0] <= 90:543 if(global_vars.PRINTFLAG >= 2):544 print("Dataframe has only",numberData.shape[0], "days")545 return 'NA','NA'546 prediction = np.mean(numberData[indexList[:4]], axis=0)547 actual = numberData[numberData.shape[0]-1,:]548 if(global_vars.PRINTFLAG >= 2):549 print("4-90 Weather Capped:")550 # -50,-40,-30,-20,-10,0 ,10,20,30,40,50 adjustment list (no)551 cappedAdjustmentsErrors = getCappedAdjustments(prediction, actual, 1.51)552 if(global_vars.PRINTFLAG >= 2):553 print("4-90 Weather:")554 errors = getErrors(prediction, actual)555 return errors, cappedAdjustmentsErrors556# getFiveTenWeather(interval_df, DRDays, temp_df, date)557# runs 5-10 baseline function and return error. Top 5 weather days of any error558# input559# interval_df, pandas.Dataframe, contains all interval data relevant to SAID560# DRdays, list, contains list of DR event dates in datetime form561# temp_df, pandas.Dataframe, contains all temperature data562# date, pandas.datetime, date to run baselines on 563# output564# error, triple, (cv, rmse, mape)565# cappedAdjustmentsErrors,list of triples, error rates for each capped adjustment in list form566def getFiveTenWeather(interval_df, DRDays, temp_df, date):567 tempHours, tempData = getPastDaysTemp(temp_df, DRDays, date, 10, True)568 # Make all tempDatas in the same hour the same569 tempData = adjustTimeTemp(tempHours, tempData)570 # print("td 5-10",len(tempData),date)571 # print(tempData)572 # Temp measurements per day573 chunksize = 48574 # to split days into seperate rows575 max_days_temp = []576 try:577 for i in range(10):578 newRow = max(tempData[(i*chunksize):(i+1)*chunksize])579 max_days_temp.append(newRow)580 except:581 return 'NA','NA'582 # get index of max temps from high to low583 max_days_temp = np.asarray(max_days_temp)584 indexList = list(max_days_temp.argsort())585 indexList.reverse()586 # get numpy array interval data for past 90 days and current date (91 rows)587 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 10, True)588 # print("5-10", numberData)589 if numberData.shape[0] <= 10:590 if(global_vars.PRINTFLAG >= 2):591 print("Dataframe has only",numberData.shape[0], "days")592 return 'NA','NA'593 prediction = np.mean(numberData[indexList[:5]], axis=0)594 actual = numberData[numberData.shape[0]-1,:]595 596 # print("5-10", prediction)597 if(global_vars.PRINTFLAG >= 2):598 print("5-10 Weather Capped:")599 # -50,-40,-30,-20,-10,0 ,10,20,30,40,50 adjustment list (no)600 cappedAdjustmentsErrors = getCappedAdjustments(prediction, actual, 1.51)601 if(global_vars.PRINTFLAG >= 2):602 print("5-10 Weather:")603 errors = getErrors(prediction, actual)604 return errors, cappedAdjustmentsErrors605# getTenTenWeather(interval_df, DRDays, temp_df, date)606# runs 10-10 baseline function and return error. Top 5 weather days of any error607# input608# interval_df, pandas.Dataframe, contains all interval data relevant to SAID609# DRdays, list, contains list of DR event dates in datetime form610# temp_df, pandas.Dataframe, contains all temperature data611# date, pandas.datetime, date to run baselines on 612# output613# error, triple, (cv, rmse, mape)614# cappedAdjustmentsErrors,list of triples, error rates for each capped adjustment in list form615def getTenTenWeather(interval_df, DRDays, temp_df, date):616 tempHours, tempData = getPastDaysTemp(temp_df, DRDays, date, 10, True)617 # Make all tempDatas in the same hour the same618 tempData = adjustTimeTemp(tempHours, tempData)619 # Temp measurements per day620 chunksize = 48621 # to split days into seperate rows622 max_days_temp = []623 try:624 for i in range(10):625 newRow = max(tempData[(i*chunksize):(i+1)*chunksize])626 max_days_temp.append(newRow)627 except:628 return 'NA','NA'629 # get index of max temps from high to low630 max_days_temp = np.asarray(max_days_temp)631 indexList = list(max_days_temp.argsort())632 indexList.reverse()633 # get numpy array interval data for past 90 days and current date (91 rows)634 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 10, True)635 if numberData.shape[0] <= 10:636 if(global_vars.PRINTFLAG >= 2):637 print("Dataframe has only",numberData.shape[0], "days")638 return 'NA','NA'639 prediction = np.mean(numberData[indexList[:10]], axis=0)640 actual = numberData[numberData.shape[0]-1,:]641 if(global_vars.PRINTFLAG >= 2):642 print("10-10 Weather Capped:")643 # -50,-40,-30,-20,-10,0 ,10,20,30,40,50 adjustment list (no)644 cappedAdjustmentsErrors = getCappedAdjustments(prediction, actual, 1.51)645 if(global_vars.PRINTFLAG >= 2):646 print("10-10 Weather:")647 errors = getErrors(prediction, actual)648 return errors, cappedAdjustmentsErrors649# getThreeFiveWeather(interval_df, DRDays, temp_df, date)650# runs 3-5 baseline function and return error. Top 5 weather days of any error651# input652# interval_df, pandas.Dataframe, contains all interval data relevant to SAID653# DRdays, list, contains list of DR event dates in datetime form654# temp_df, pandas.Dataframe, contains all temperature data655# date, pandas.datetime, date to run baselines on 656# output657# error, triple, (cv, rmse, mape)658# cappedAdjustmentsErrors,list of triples, error rates for each capped adjustment in list form659def getThreeFiveWeather(interval_df, DRDays, temp_df, date):660 tempHours, tempData = getPastDaysTemp(temp_df, DRDays, date, 5, True)661 # print("td",len(tempData))662 # print(tempData)663 # Make all tempDatas in the same hour the same664 tempData = adjustTimeTemp(tempHours, tempData)665 # print("td 3-5",len(tempData), date)666 # print(tempData)667 # Temp measurements per day668 chunksize = 48669 # to split days into seperate rows670 max_days_temp = []671 # try:672 # for i in range(5):673 # newRow = max(tempData[(i*chunksize):(i+1)*chunksize])674 # max_days_temp.append(newRow)675 # print(max_days_temp)676 # except:677 # print("Oh No")678 # return 'NA','NA'679 for i in range(5):680 newRow = max(tempData[(i*chunksize):(i+1)*chunksize])681 max_days_temp.append(newRow)682 # print(max_days_temp)683 # get index of max temps from high to low684 max_days_temp = np.asarray(max_days_temp)685 indexList = list(max_days_temp.argsort())686 indexList.reverse()687 # get numpy array interval data for past 90 days and current date (91 rows)688 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 5, True)689 # print("3-5", numberData)690 if numberData.shape[0] <= 5:691 if(global_vars.PRINTFLAG >= 2):692 print("Dataframe has only",numberData.shape[0], "days")693 return 'NA','NA'694 prediction = (numberData[indexList[0]]*0.5)+(numberData[indexList[1]]*0.3)+(numberData[indexList[2]]*0.2)695 actual = numberData[numberData.shape[0]-1,:]696 # print("3-5", prediction)697 # print("3-5 a", actual)698 if(global_vars.PRINTFLAG >= 2):699 print("3-5 Weather Capped:")700 # -50,-40,-30,-20,-10,0 ,10,20,30,40,50 adjustment list (no)701 cappedAdjustmentsErrors = getCappedAdjustments(prediction, actual, 1.51)702 if(global_vars.PRINTFLAG >= 2):703 print("3-5 Weather:")704 errors = getErrors(prediction, actual)705 return errors, cappedAdjustmentsErrors706# getFourFourWeather(interval_df, DRDays, temp_df, date)707# runs 4-4 baseline function and return error. Top 5 weather days of any error708# input709# interval_df, pandas.Dataframe, contains all interval data relevant to SAID710# DRdays, list, contains list of DR event dates in datetime form711# temp_df, pandas.Dataframe, contains all temperature data712# date, pandas.datetime, date to run baselines on 713# output714# error, triple, (cv, rmse, mape)715# cappedAdjustmentsErrors,list of triples, error rates for each capped adjustment in list form716def getFourFourWeather(interval_df, DRDays, temp_df, date):717 tempHours, tempData = getPastDaysTemp(temp_df, DRDays, date, 4, True)718 # Make all tempDatas in the same hour the same719 tempData = adjustTimeTemp(tempHours, tempData)720 # Temp measurements per day721 chunksize = 48722 # to split days into seperate rows723 max_days_temp = []724 try:725 for i in range(4):726 newRow = max(tempData[(i*chunksize):(i+1)*chunksize])727 max_days_temp.append(newRow)728 except:729 return 'NA','NA'730 # get index of max temps from high to low731 max_days_temp = np.asarray(max_days_temp)732 indexList = list(max_days_temp.argsort())733 indexList.reverse()734 # get numpy array interval data for past 90 days and current date (91 rows)735 numberData, time_indexes = getNeededDates(interval_df, DRDays, date, 4, True)736 if numberData.shape[0] <= 4:737 return 'NA','NA'738 prediction = np.mean(numberData[indexList[:4]], axis=0)739 actual = numberData[numberData.shape[0]-1,:]740 if(global_vars.PRINTFLAG >= 2):741 print("4-4 Weather Capped:")742 # -50,-40,-30,-20,-10,0 ,10,20,30,40,50 adjustment list (no)743 cappedAdjustmentsErrors = getCappedAdjustments(prediction, actual, 1.51)744 if(global_vars.PRINTFLAG >= 2):745 print("4-4 Weather:")746 errors = getErrors(prediction, actual)747 return errors, cappedAdjustmentsErrors748 ...

Full Screen

Full Screen

test_capping_wang.py

Source:test_capping_wang.py Github

copy

Full Screen

1from sys import stderr2import unittest3from fragment_capping.helpers.types_helpers import Atom4from fragment_capping.helpers.molecule import Molecule, molecule_from_pdb_str5CAPPING_FUNCTION_NAME = 'get_best_capped_molecule_with_ILP'6class Test_Capping(unittest.TestCase):7 def test_example_0(self) -> None:8 molecule = Molecule(9 [10 Atom(index=1, element='C', valence=3, capped=True, coordinates=None),11 Atom(index=2, element='O', valence=1, capped=True, coordinates=None),12 Atom(index=3, element='O', valence=2, capped=True, coordinates=None),13 Atom(index=4, element='H', valence=1, capped=True, coordinates=None),14 Atom(index=5, element='H', valence=1, capped=True, coordinates=None),15 ],16 [17 (1, 2),18 (1, 3),19 (3, 4),20 (1, 5),21 ],22 name='methoanoic acid',23 )24 molecule.write_graph('raw_molecule')25 molecule.assign_bond_orders_and_charges_with_ILP()26 molecule.write_graph('molecule_with_electrons')27 def test_example_1(self) -> None:28 uncapped_molecule = Molecule(29 {30 1: Atom(index=1, element='C', valence=3, capped=False, coordinates=None),31 2: Atom(index=2, element='C', valence=3, capped=False, coordinates=None),32 },33 [34 (1, 2),35 ],36 name='example_1',37 )38 uncapped_molecule.write_graph('uncapped_molecule')39 for use_ILP in (True,):40 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)41 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))42 assert capped_molecule.formula(charge=True) == 'C2H4', capped_molecule.formula(charge=True)43 def test_example_2(self) -> None:44 uncapped_molecule = Molecule(45 {46 1: Atom(index=1, element='C', valence=3, capped=False, coordinates=None),47 2: Atom(index=2, element='O', valence=1, capped=False, coordinates=None),48 },49 [50 (1, 2),51 ],52 name='example_2',53 )54 uncapped_molecule.write_graph('uncapped_molecule')55 for use_ILP in (True,):56 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)57 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))58 assert capped_molecule.formula(charge=True) == 'CH2O', capped_molecule.formula(charge=True)59 def test_example_3(self) -> None:60 uncapped_molecule = Molecule(61 {62 1: Atom(index=1, element='C', valence=3, capped=False, coordinates=None),63 2: Atom(index=2, element='C', valence=3, capped=False, coordinates=None),64 3: Atom(index=3, element='C', valence=3, capped=False, coordinates=None),65 4: Atom(index=4, element='C', valence=3, capped=False, coordinates=None),66 5: Atom(index=5, element='C', valence=3, capped=False, coordinates=None),67 6: Atom(index=6, element='C', valence=3, capped=False, coordinates=None),68 },69 [70 (1, 2),71 (2, 3),72 (3, 4),73 (4, 5),74 (5, 6),75 (6, 1),76 ]77 )78 uncapped_molecule.write_graph('uncapped_molecule')79 for use_ILP in (True, False):80 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)81 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))82 assert capped_molecule.formula(charge=True) == 'C6H6', capped_molecule.formula(charge=True)83 def test_example_4(self) -> None:84 uncapped_molecule = Molecule(85 {86 1: Atom(index=1, element='C', valence=4, capped=False, coordinates=None),87 },88 [89 ],90 name='example_4',91 )92 uncapped_molecule.write_graph('uncapped_molecule')93 for use_ILP in (True, False):94 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)95 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))96 assert capped_molecule.formula(charge=True) == 'CH4', capped_molecule.formula(charge=True)97 def test_example_5(self) -> None:98 uncapped_molecule = Molecule(99 {100 1: Atom(index=1, element='C', valence=2, capped=True, coordinates=None),101 2: Atom(index=2, element='O', valence=1, capped=True, coordinates=None),102 3: Atom(index=3, element='O', valence=1, capped=True, coordinates=None),103 },104 [105 (1, 2),106 (1, 3),107 ],108 name='example_5',109 )110 uncapped_molecule.write_graph('uncapped_molecule')111 for use_ILP in (True, False):112 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)113 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))114 assert capped_molecule.formula(charge=True) == 'CO2', capped_molecule.formula(charge=True)115 def test_example_6(self) -> None:116 uncapped_molecule = Molecule(117 {118 1: Atom(index=1, element='C', valence=4, capped=False, coordinates=None),119 },120 [121 ],122 name='example_6',123 )124 uncapped_molecule.write_graph('uncapped_molecule')125 for use_ILP in (True, False):126 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)127 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))128 assert capped_molecule.formula(charge=True) == 'CH4', capped_molecule.formula(charge=True)129 def test_example_7(self) -> None:130 uncapped_molecule = Molecule(131 {132 1: Atom(index=1, element='C', valence=3, capped=False, coordinates=None),133 2: Atom(index=2, element='O', valence=2, capped=True, coordinates=None),134 3: Atom(index=3, element='O', valence=1, capped=True, coordinates=None),135 4: Atom(index=4, element='H', valence=1, capped=True, coordinates=None),136 },137 [138 (1, 2),139 (1, 3),140 (2, 4),141 ],142 name='example_7',143 )144 uncapped_molecule.write_graph('uncapped_molecule')145 for use_ILP in (True, False):146 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)147 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))148 assert capped_molecule.formula(charge=True) == 'CH2O2', capped_molecule.formula(charge=True)149 def test_example_8(self) -> None:150 uncapped_molecule = Molecule(151 {152 1: Atom(index=1, element='N', valence=None, capped=False, coordinates=None),153 2: Atom(index=2, element='H', valence=1, capped=True, coordinates=None),154 },155 [156 (1, 2),157 ],158 name='example_0',159 )160 uncapped_molecule.write_graph('uncapped_molecule')161 for use_ILP in (True,):162 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)163 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))164 assert capped_molecule.formula(charge=True) == 'H3N', capped_molecule.formula(charge=True)165 def test_example_9(self) -> None:166 uncapped_molecule = Molecule(167 {168 1: Atom(index=1, element='N', valence=None, capped=False, coordinates=None),169 2: Atom(index=2, element='H', valence=1, capped=True, coordinates=None),170 },171 [172 (1, 2),173 ],174 name='example_0',175 )176 uncapped_molecule.write_graph('uncapped_molecule')177 for use_ILP in (True,):178 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)179 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))180 assert capped_molecule.formula(charge=True) == 'H3N', capped_molecule.formula(charge=True)181 # Source: https://doi.org/10.1016/j.jmgm.2005.12.005182 def test_example_wang_1(self) -> None:183 uncapped_molecule = Molecule(184 {185 1: Atom(index=1, element='C', valence=3, capped=True, coordinates=None),186 2: Atom(index=2, element='C', valence=3, capped=True, coordinates=None),187 3: Atom(index=3, element='C', valence=3, capped=True, coordinates=None),188 4: Atom(index=4, element='C', valence=3, capped=True, coordinates=None),189 5: Atom(index=5, element='C', valence=3, capped=True, coordinates=None),190 6: Atom(index=6, element='C', valence=3, capped=True, coordinates=None),191 7: Atom(index=7, element='H', valence=1, capped=True, coordinates=None),192 8: Atom(index=8, element='H', valence=1, capped=True, coordinates=None),193 9: Atom(index=9, element='H', valence=1, capped=True, coordinates=None),194 10: Atom(index=10, element='H', valence=1, capped=True, coordinates=None),195 11: Atom(index=11, element='H', valence=1, capped=True, coordinates=None),196 12: Atom(index=12, element='O', valence=1, capped=True, coordinates=None),197 },198 [199 (1, 2),200 (2, 3),201 (3, 4),202 (4, 5),203 (5, 6),204 (6, 1),205 (7, 1),206 (8, 2),207 (9, 3),208 (10, 4),209 (11, 5),210 (12, 6),211 ],212 name='example_wang_1',213 )214 uncapped_molecule.write_graph('uncapped_molecule')215 for use_ILP in (True, False):216 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)217 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))218 assert capped_molecule.formula(charge=True) == 'C6H5O 1-', capped_molecule.formula(charge=True)219 def test_example_wang_2(self) -> None:220 uncapped_molecule = Molecule(221 {222 1: Atom(index=1, element='O', valence=1, capped=True, coordinates=None),223 2: Atom(index=2, element='C', valence=2, capped=True, coordinates=None),224 3: Atom(index=3, element='S', valence=3, capped=True, coordinates=None),225 4: Atom(index=4, element='C', valence=4, capped=False, coordinates=None),226 5: Atom(index=5, element='C', valence=4, capped=False, coordinates=None),227 },228 [229 (1, 2),230 (2, 3),231 (3, 4),232 (3, 5),233 ],234 name='example_wang_2',235 )236 uncapped_molecule.write_graph('uncapped_molecule')237 for use_ILP in (True, False):238 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)239 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))240 assert capped_molecule.formula(charge=True) == 'C3H6OS', capped_molecule.formula(charge=True)241 def test_example_wang_3(self) -> None:242 uncapped_molecule = Molecule(243 {244 1: Atom(index=1, element='C', valence=4, capped=False, coordinates=None),245 2: Atom(index=2, element='C', valence=4, capped=False, coordinates=None),246 3: Atom(index=3, element='C', valence=4, capped=False, coordinates=None),247 4: Atom(index=4, element='P', valence=4, capped=True, coordinates=None),248 5: Atom(index=5, element='O', valence=1, capped=True, coordinates=None),249 6: Atom(index=6, element='O', valence=2, capped=True, coordinates=None),250 7: Atom(index=7, element='O', valence=2, capped=True, coordinates=None),251 8: Atom(index=8, element='C', valence=4, capped=False, coordinates=None),252 9: Atom(index=9, element='C', valence=4, capped=False, coordinates=None),253 },254 [255 (1, 2),256 (2, 3),257 (2, 4),258 (4, 5),259 (4, 6),260 (4, 7),261 (6, 8),262 (7, 9),263 ],264 name='example_wang_3',265 )266 uncapped_molecule.write_graph('uncapped_molecule')267 for use_ILP in (True, False):268 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)269 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))270 assert capped_molecule.formula(charge=True) == 'C5H13O3P', capped_molecule.formula(charge=True)271 def test_example_wang_4(self) -> None:272 uncapped_molecule = Molecule(273 {274 1: Atom(index=1, element='O', valence=1, capped=True, coordinates=None),275 2: Atom(index=2, element='C', valence=3, capped=True, coordinates=None),276 3: Atom(index=3, element='C', valence=3, capped=False, coordinates=None),277 4: Atom(index=4, element='C', valence=3, capped=False, coordinates=None),278 5: Atom(index=5, element='C', valence=3, capped=False, coordinates=None),279 6: Atom(index=6, element='N', valence=2, capped=True, coordinates=None),280 },281 [282 (1, 2),283 (2, 3),284 (3, 4),285 (4, 5),286 (5, 6),287 (6, 2),288 ],289 name='example_wang_4',290 )291 uncapped_molecule.write_graph('uncapped_molecule')292 for use_ILP in (True, False):293 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)294 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))295 assert capped_molecule.formula(charge=True) == 'C4H3NO', capped_molecule.formula(charge=True)296 def test_example_wang_5(self) -> None:297 uncapped_molecule = Molecule(298 {299 1: Atom(index=1, element='C', valence=4, capped=False, coordinates=None),300 2: Atom(index=2, element='C', valence=4, capped=False, coordinates=None),301 3: Atom(index=3, element='C', valence=4, capped=False, coordinates=None),302 4: Atom(index=4, element='C', valence=2, capped=True, coordinates=None),303 5: Atom(index=5, element='N', valence=2, capped=True, coordinates=None),304 6: Atom(index=6, element='C', valence=4, capped=False, coordinates=None),305 },306 [307 (1, 2),308 (2, 3),309 (2, 4),310 (4, 5),311 (5, 6),312 ],313 name='example_wang_5',314 )315 uncapped_molecule.write_graph('uncapped_molecule')316 for use_ILP in (True, False):317 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)318 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))319 #assert capped_molecule.formula(charge=True) == 'C5H10N 1+', capped_molecule.formula(charge=True)320 def test_example_wang_6(self) -> None:321 uncapped_molecule = Molecule(322 {323 1: Atom(index=1, element='C', valence=3, capped=False, coordinates=None),324 2: Atom(index=2, element='C', valence=3, capped=False, coordinates=None),325 3: Atom(index=3, element='C', valence=3, capped=False, coordinates=None),326 4: Atom(index=4, element='C', valence=3, capped=False, coordinates=None),327 5: Atom(index=5, element='C', valence=3, capped=True, coordinates=None),328 6: Atom(index=6, element='C', valence=3, capped=False, coordinates=None),329 7: Atom(index=7, element='C', valence=3, capped=False, coordinates=None),330 8: Atom(index=8, element='C', valence=3, capped=False, coordinates=None),331 9: Atom(index=9, element='C', valence=3, capped=False, coordinates=None),332 10: Atom(index=10, element='C', valence=3, capped=True, coordinates=None),333 },334 [335 (1, 2),336 (2, 3),337 (3, 4),338 (4, 5),339 (5, 6),340 (6, 7),341 (7, 8),342 (8, 9),343 (9, 10),344 (10, 1),345 (10, 5),346 ],347 name='example_wang_6',348 )349 uncapped_molecule.write_graph('uncapped_molecule')350 for use_ILP in (True, False):351 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)352 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))353 assert capped_molecule.formula(charge=True) == 'C10H8', capped_molecule.formula(charge=True)354 def test_example_wang_7(self) -> None:355 uncapped_molecule = Molecule(356 {357 1: Atom(index=1, element='C', valence=4, capped=False, coordinates=None),358 2: Atom(index=2, element='C', valence=2, capped=True, coordinates=None),359 3: Atom(index=3, element='N', valence=2, capped=True, coordinates=None),360 4: Atom(index=4, element='S', valence=1, capped=True, coordinates=None),361 },362 [363 (1, 2),364 (2, 3),365 (3, 4),366 ],367 name='example_wang_7',368 )369 uncapped_molecule.write_graph('uncapped_molecule')370 for use_ILP in (True, False):371 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)372 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))373 assert capped_molecule.formula(charge=True) == 'C2H3NS', capped_molecule.formula(charge=True)374 def test_example_wang_8(self) -> None:375 uncapped_molecule = Molecule(376 {377 1: Atom(index=1, element='N', valence=1, capped=True, coordinates=None),378 2: Atom(index=2, element='N', valence=2, capped=True, coordinates=None),379 3: Atom(index=3, element='C', valence=3, capped=True, coordinates=None),380 4: Atom(index=4, element='C', valence=3, capped=False, coordinates=None),381 5: Atom(index=5, element='P', valence=2, capped=True, coordinates=None),382 6: Atom(index=6, element='N', valence=2, capped=True, coordinates=None),383 7: Atom(index=7, element='C', valence=3, capped=False, coordinates=None),384 },385 [386 (1, 2),387 (2, 3),388 (3, 4),389 (4, 5),390 (5, 6),391 (6, 7),392 (7, 3),393 ],394 name='example_wang_8',395 )396 uncapped_molecule.write_graph('uncapped_molecule')397 for use_ILP in (True, False):398 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)399 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))400 assert capped_molecule.formula(charge=True) == 'C3H2N3P', capped_molecule.formula(charge=True)401 def test_example_wang_9(self) -> None:402 uncapped_molecule = Molecule(403 {404 1: Atom(index=1, element='H', valence=1, capped=True, coordinates=None),405 2: Atom(index=2, element='N', valence=2, capped=True, coordinates=None),406 3: Atom(index=3, element='C', valence=3, capped=False, coordinates=None),407 4: Atom(index=4, element='C', valence=3, capped=True, coordinates=None),408 5: Atom(index=5, element='C', valence=3, capped=False, coordinates=None),409 6: Atom(index=6, element='P', valence=2, capped=True, coordinates=None),410 7: Atom(index=7, element='H', valence=1, capped=True, coordinates=None),411 8: Atom(index=8, element='N', valence=2, capped=True, coordinates=None),412 9: Atom(index=9, element='N', valence=1, capped=True, coordinates=None),413 },414 [415 (1, 2),416 (2, 3),417 (3, 4),418 (4, 5),419 (5, 6),420 (6, 7),421 (4, 8),422 (8, 9),423 ],424 name='example_wang_9',425 )426 uncapped_molecule.write_graph('uncapped_molecule')427 for use_ILP in (True, False):428 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)429 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))430 assert capped_molecule.formula(charge=True) == 'C3H4N3P', capped_molecule.formula(charge=True)431 def test_example_wang_10(self) -> None:432 uncapped_molecule = Molecule(433 {434 1: Atom(index=1, element='C', valence=3, capped=True, coordinates=None),435 2: Atom(index=2, element='C', valence=3, capped=True, coordinates=None),436 3: Atom(index=3, element='C', valence=3, capped=True, coordinates=None),437 4: Atom(index=4, element='C', valence=3, capped=True, coordinates=None),438 5: Atom(index=5, element='C', valence=3, capped=True, coordinates=None),439 6: Atom(index=6, element='C', valence=3, capped=True, coordinates=None),440 7: Atom(index=7, element='O', valence=1, capped=True, coordinates=None),441 8: Atom(index=8, element='H', valence=1, capped=True, coordinates=None),442 9: Atom(index=9, element='H', valence=1, capped=True, coordinates=None),443 10: Atom(index=10, element='O', valence=1, capped=True, coordinates=None),444 11: Atom(index=11, element='H', valence=1, capped=True, coordinates=None),445 12: Atom(index=12, element='H', valence=1, capped=True, coordinates=None),446 },447 [448 (1, 2),449 (2, 3),450 (3, 4),451 (4, 5),452 (5, 6),453 (6, 1),454 (7, 1),455 (8, 2),456 (9, 3),457 (10, 4),458 (11, 5),459 (12, 6),460 ],461 name='example_wang_10',462 )463 uncapped_molecule.write_graph('uncapped_molecule')464 for use_ILP in (True, False):465 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)466 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))467 assert capped_molecule.formula(charge=True) == 'C6H4O2', capped_molecule.formula(charge=True)468 def test_example_wang_11(self) -> None:469 uncapped_molecule = Molecule(470 {471 1: Atom(index=1, element='C', valence=3, capped=False, coordinates=None),472 2: Atom(index=2, element='N', valence=3, capped=True, coordinates=None),473 3: Atom(index=3, element='H', valence=1, capped=True, coordinates=None),474 4: Atom(index=4, element='C', valence=3, capped=True, coordinates=None),475 5: Atom(index=5, element='C', valence=3, capped=False, coordinates=None),476 6: Atom(index=6, element='N', valence=2, capped=True, coordinates=None),477 7: Atom(index=7, element='S', valence=2, capped=True, coordinates=None),478 8: Atom(index=8, element='C', valence=3, capped=True, coordinates=None),479 9: Atom(index=9, element='N', valence=3, capped=True, coordinates=None),480 10: Atom(index=10, element='H', valence=1, capped=True, coordinates=None),481 },482 [483 (1, 2),484 (2, 3),485 (2, 4),486 (4, 5),487 (5, 6),488 (6, 7),489 (7, 8),490 (8, 9),491 (9, 10),492 (9, 1),493 (4, 8),494 ],495 name='example_wang_11',496 )497 uncapped_molecule.write_graph('uncapped_molecule')498 for use_ILP in (True, False):499 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)500 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))501 assert capped_molecule.formula(charge=True) == 'C4H4N3S 1+', capped_molecule.formula(charge=True)502 def test_example_wang_12(self) -> None:503 uncapped_molecule = Molecule(504 {505 1: Atom(index=1, element='C', valence=3, capped=True, coordinates=None),506 2: Atom(index=2, element='C', valence=3, capped=False, coordinates=None),507 3: Atom(index=3, element='C', valence=3, capped=False, coordinates=None),508 4: Atom(index=4, element='C', valence=3, capped=False, coordinates=None),509 5: Atom(index=5, element='C', valence=3, capped=False, coordinates=None),510 6: Atom(index=6, element='P', valence=4, capped=True, coordinates=None),511 7: Atom(index=7, element='O', valence=2, capped=True, coordinates=None),512 8: Atom(index=8, element='H', valence=1, capped=True, coordinates=None),513 9: Atom(index=9, element='O', valence=2, capped=True, coordinates=None),514 10: Atom(index=10, element='H', valence=1, capped=True, coordinates=None),515 11: Atom(index=11, element='O', valence=1, capped=True, coordinates=None),516 },517 [518 (1, 2),519 (2, 3),520 (3, 4),521 (4, 5),522 (5, 1),523 (1, 6),524 (6, 7),525 (7, 8),526 (6, 9),527 (9, 10),528 (6, 11),529 ],530 name='example_wang_12',531 )532 uncapped_molecule.write_graph('uncapped_molecule')533 for use_ILP in (True, False):534 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)535 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'))536 assert capped_molecule.formula(charge=True) == 'C5H6O3P 1-', capped_molecule.formula(charge=True)537 def test_example_taxol_core(self) -> None:538 uncapped_molecule = Molecule(539 {5: Atom(index=5, element="C", valence=3, capped=False, coordinates=(0.746, 3.138, 0.794)), 7: Atom(index=7, element="O", valence=2, capped=True, coordinates=(1.175, 1.853, 0.61)), 8: Atom(index=8, element="C", valence=4, capped=True, coordinates=(1.672, 1.0, 1.641)), 9: Atom(index=9, element="C", valence=4, capped=True, coordinates=(2.696, 1.617, 2.644)), 10: Atom(index=10, element="H", valence=1, capped=True, coordinates=(2.871, 2.705, 2.545)), 11: Atom(index=11, element="H", valence=1, capped=True, coordinates=(3.667, 1.113, 2.766)), 12: Atom(index=12, element="O", valence=2, capped=True, coordinates=(1.805, 1.347, 3.756)), 13: Atom(index=13, element="C", valence=4, capped=True, coordinates=(0.741, 0.845, 2.897)), 14: Atom(index=14, element="H", valence=1, capped=True, coordinates=(-0.111, 1.567, 2.942)), 15: Atom(index=15, element="C", valence=4, capped=False, coordinates=(0.262, -0.558, 3.171)), 18: Atom(index=18, element="C", valence=4, capped=False, coordinates=(1.353, -1.632, 3.131)), 20: Atom(index=20, element="O", valence=2, capped=True, coordinates=(1.998, -1.605, 4.383)), 21: Atom(index=21, element="H", valence=1, capped=True, coordinates=(2.798, -2.116, 4.304)), 22: Atom(index=22, element="C", valence=4, capped=False, coordinates=(2.315, -1.541, 1.879)), 29: Atom(index=29, element="C", valence=4, capped=True, coordinates=(1.951, -0.352, 0.936)), 30: Atom(index=30, element="H", valence=1, capped=True, coordinates=(0.931, -0.608, 0.548)), 31: Atom(index=31, element="C", valence=4, capped=True, coordinates=(2.911, -0.285, -0.293)), 32: Atom(index=32, element="H", valence=1, capped=True, coordinates=(3.702, -1.082, -0.163)), 33: Atom(index=33, element="O", valence=2, capped=False, coordinates=(3.52, 1.006, -0.367)), 101: Atom(index=101, element="C", valence=4, capped=False, coordinates=(0.908, -3.278, 0.308)), 47: Atom(index=47, element="C", valence=4, capped=True, coordinates=(2.191, -0.548, -1.701)), 48: Atom(index=48, element="O", valence=2, capped=True, coordinates=(3.132, -0.275, -2.729)), 49: Atom(index=49, element="H", valence=1, capped=True, coordinates=(3.241, 0.668, -2.768)), 50: Atom(index=50, element="C", valence=4, capped=False, coordinates=(0.937, 0.345, -1.879)), 53: Atom(index=53, element="C", valence=4, capped=False, coordinates=(1.845, -2.08, -1.847)), 54: Atom(index=54, element="C", valence=3, capped=True, coordinates=(0.733, -2.32, -0.843)), 59: Atom(index=59, element="C", valence=3, capped=False, coordinates=(-0.388, -1.56, -0.899))},540 {frozenset({5, 7}), frozenset({13, 15}), frozenset({18, 20}), frozenset({18, 15}), frozenset({50, 47}), frozenset({18, 22}), frozenset({8, 29}), frozenset({8, 9}), frozenset({32, 31}), frozenset({48, 47}), frozenset({9, 10}), frozenset({29, 30}), frozenset({29, 31}), frozenset({9, 11}), frozenset({53, 54}), frozenset({9, 12}), frozenset({20, 21}), frozenset({48, 49}), frozenset({29, 22}), frozenset({33, 31}), frozenset({31, 47}), frozenset({12, 13}), frozenset({13, 14}), frozenset({59, 54}), frozenset({8, 7}), frozenset({53, 47}), frozenset({101, 54}), frozenset({8, 13})},541 name='example_taxol_core',542 )543 uncapped_molecule.write_graph('uncapped_molecule', output_size=(1200, 1200))544 for use_ILP in (True,):545 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)546 capped_molecule.write_graph('capped_molecule_with_{0}'.format('ILP' if use_ILP else 'bruteforce'), output_size=(1200, 1200))547 assert capped_molecule.formula(charge=True) == 'C16H26O5', capped_molecule.formula(charge=True)548 def test_example_porphyrin(self, use_ILP: bool = True) -> None:549 with open('pdbs/tetraphenylporphyrin.pdb') as fh:550 uncapped_molecule = molecule_from_pdb_str(551 fh.read(),552 name='porphyrin',553 )554 _, _, pos = uncapped_molecule.write_graph(555 'input',556 output_size=(1200, 1200),557 graph_kwargs={'include_atom_index': False},558 )559 capped_molecule = getattr(uncapped_molecule, CAPPING_FUNCTION_NAME)(debug=None)560 capped_molecule.write_graph(561 'output',562 output_size=(1200, 1200),563 graph_kwargs={'include_atom_index': False},564 pos=None,565 )566if __name__ == '__main__':...

Full Screen

Full Screen

LennardJonesCapped.py

Source:LennardJonesCapped.py Github

copy

Full Screen

1# Copyright (C) 2012,20132# Max Planck Institute for Polymer Research3# Copyright (C) 2008,2009,2010,20114# Max-Planck-Institute for Polymer Research & Fraunhofer SCAI5# 6# This file is part of ESPResSo++.7# 8# ESPResSo++ is free software: you can redistribute it and/or modify9# it under the terms of the GNU General Public License as published by10# the Free Software Foundation, either version 3 of the License, or11# (at your option) any later version.12# 13# ESPResSo++ is distributed in the hope that it will be useful,14# but WITHOUT ANY WARRANTY; without even the implied warranty of15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16# GNU General Public License for more details.17# 18# You should have received a copy of the GNU General Public License19# along with this program. If not, see <http://www.gnu.org/licenses/>. 20r"""21*****************************************22espressopp.interaction.LennardJonesCapped23*****************************************24.. math::25 V(r) = 4 \varepsilon \left[ \left( \frac{\sigma}{r} \right)^{12} -26 \left( \frac{\sigma}{r} \right)^{6} \right]27where `r` is either the distance or the capped distance, depending on which is28greater.29.. function:: espressopp.interaction.LennardJonesCapped(epsilon, sigma, cutoff, caprad, shift)30 :param epsilon: (default: 1.0)31 :param sigma: (default: 1.0)32 :param cutoff: (default: infinity)33 :param caprad: (default: 0.0)34 :param shift: (default: "auto")35 :type epsilon: real36 :type sigma: real37 :type cutoff: 38 :type caprad: real39 :type shift: 40.. function:: espressopp.interaction.VerletListLennardJonesCapped(vl)41 :param vl: 42 :type vl: 43.. function:: espressopp.interaction.VerletListLennardJonesCapped.getPotential(type1, type2)44 :param type1: 45 :param type2: 46 :type type1: 47 :type type2: 48 :rtype: 49.. function:: espressopp.interaction.VerletListLennardJonesCapped.setPotential(type1, type2, potential)50 :param type1: 51 :param type2: 52 :param potential: 53 :type type1: 54 :type type2: 55 :type potential: 56.. function:: espressopp.interaction.VerletListAdressLennardJonesCapped(vl, fixedtupleList)57 :param vl: 58 :param fixedtupleList: 59 :type vl: 60 :type fixedtupleList: 61.. function:: espressopp.interaction.VerletListAdressLennardJonesCapped.getPotentialAT(type1, type2)62 :param type1: 63 :param type2: 64 :type type1: 65 :type type2: 66 :rtype: 67.. function:: espressopp.interaction.VerletListAdressLennardJonesCapped.getPotentialCG(type1, type2)68 :param type1: 69 :param type2: 70 :type type1: 71 :type type2: 72 :rtype: 73.. function:: espressopp.interaction.VerletListAdressLennardJonesCapped.setPotentialAT(type1, type2, potential)74 :param type1: 75 :param type2: 76 :param potential: 77 :type type1: 78 :type type2: 79 :type potential: 80.. function:: espressopp.interaction.VerletListAdressLennardJonesCapped.setPotentialCG(type1, type2, potential)81 :param type1: 82 :param type2: 83 :param potential: 84 :type type1: 85 :type type2: 86 :type potential: 87.. function:: espressopp.interaction.VerletListHadressLennardJonesCapped(vl, fixedtupleList)88 :param vl: 89 :param fixedtupleList: 90 :type vl: 91 :type fixedtupleList: 92.. function:: espressopp.interaction.VerletListHadressLennardJonesCapped.getPotentialAT(type1, type2)93 :param type1: 94 :param type2: 95 :type type1: 96 :type type2: 97 :rtype: 98.. function:: espressopp.interaction.VerletListHadressLennardJonesCapped.getPotentialCG(type1, type2)99 :param type1: 100 :param type2: 101 :type type1: 102 :type type2: 103 :rtype: 104.. function:: espressopp.interaction.VerletListHadressLennardJonesCapped.setPotentialAT(type1, type2, potential)105 :param type1: 106 :param type2: 107 :param potential: 108 :type type1: 109 :type type2: 110 :type potential: 111.. function:: espressopp.interaction.VerletListHadressLennardJonesCapped.setPotentialCG(type1, type2, potential)112 :param type1: 113 :param type2: 114 :param potential: 115 :type type1: 116 :type type2: 117 :type potential: 118.. function:: espressopp.interaction.CellListLennardJonesCapped(stor)119 :param stor: 120 :type stor: 121.. function:: espressopp.interaction.CellListLennardJonesCapped.getPotential(type1, type2)122 :param type1: 123 :param type2: 124 :type type1: 125 :type type2: 126 :rtype: 127.. function:: espressopp.interaction.CellListLennardJonesCapped.setPotential(type1, type2, potential)128 :param type1: 129 :param type2: 130 :param potential: 131 :type type1: 132 :type type2: 133 :type potential: 134.. function:: espressopp.interaction.FixedPairListLennardJonesCapped(system, vl, potential)135 :param system: 136 :param vl: 137 :param potential: 138 :type system: 139 :type vl: 140 :type potential: 141.. function:: espressopp.interaction.FixedPairListLennardJonesCapped.getPotential()142 :rtype: 143.. function:: espressopp.interaction.FixedPairListLennardJonesCapped.setPotential(potential)144 :param potential: 145 :type potential: 146"""147from espressopp import pmi, infinity148from espressopp.esutil import *149from espressopp.interaction.Potential import *150from espressopp.interaction.Interaction import *151from _espressopp import interaction_LennardJonesCapped, \152 interaction_VerletListLennardJonesCapped, \153 interaction_VerletListAdressLennardJonesCapped, \154 interaction_VerletListHadressLennardJonesCapped, \155 interaction_CellListLennardJonesCapped, \156 interaction_FixedPairListLennardJonesCapped157class LennardJonesCappedLocal(PotentialLocal, interaction_LennardJonesCapped):158 def __init__(self, epsilon=1.0, sigma=1.0, 159 cutoff=infinity, caprad=0.0, shift="auto"):160 """Initialize the local Lennard Jones object."""161 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():162 if shift =="auto":163 cxxinit(self, interaction_LennardJonesCapped, 164 epsilon, sigma, cutoff, caprad)165 else:166 cxxinit(self, interaction_LennardJonesCapped, 167 epsilon, sigma, cutoff, caprad, shift)168class VerletListLennardJonesCappedLocal(InteractionLocal, interaction_VerletListLennardJonesCapped):169 def __init__(self, vl):170 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():171 cxxinit(self, interaction_VerletListLennardJonesCapped, vl)172 def setPotential(self, type1, type2, potential):173 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():174 self.cxxclass.setPotential(self, type1, type2, potential)175 def getPotential(self, type1, type2):176 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():177 return self.cxxclass.getPotential(self, type1, type2)178class VerletListAdressLennardJonesCappedLocal(InteractionLocal, interaction_VerletListAdressLennardJonesCapped):179 def __init__(self, vl, fixedtupleList):180 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():181 cxxinit(self, interaction_VerletListAdressLennardJonesCapped, vl, fixedtupleList)182 def setPotentialAT(self, type1, type2, potential):183 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():184 self.cxxclass.setPotentialAT(self, type1, type2, potential)185 def setPotentialCG(self, type1, type2, potential):186 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():187 self.cxxclass.setPotentialCG(self, type1, type2, potential)188 def getPotentialAT(self, type1, type2):189 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():190 return self.cxxclass.getPotentialAT(self, type1, type2)191 def getPotentialCG(self, type1, type2):192 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():193 return self.cxxclass.getPotentialCG(self, type1, type2)194 195class VerletListHadressLennardJonesCappedLocal(InteractionLocal, interaction_VerletListHadressLennardJonesCapped):196 def __init__(self, vl, fixedtupleList):197 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():198 cxxinit(self, interaction_VerletListHadressLennardJonesCapped, vl, fixedtupleList)199 def setPotentialAT(self, type1, type2, potential):200 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():201 self.cxxclass.setPotentialAT(self, type1, type2, potential)202 def setPotentialCG(self, type1, type2, potential):203 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():204 self.cxxclass.setPotentialCG(self, type1, type2, potential)205 def getPotentialAT(self, type1, type2):206 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():207 return self.cxxclass.getPotentialAT(self, type1, type2)208 def getPotentialCG(self, type1, type2):209 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():210 return self.cxxclass.getPotentialCG(self, type1, type2)211class CellListLennardJonesCappedLocal(InteractionLocal, interaction_CellListLennardJonesCapped):212 def __init__(self, stor):213 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():214 cxxinit(self, interaction_CellListLennardJonesCapped, stor)215 216 def setPotential(self, type1, type2, potential):217 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():218 self.cxxclass.setPotential(self, type1, type2, potential)219 def getPotential(self, type1, type2):220 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():221 return self.cxxclass.getPotential(self, type1, type2)222class FixedPairListLennardJonesCappedLocal(InteractionLocal, interaction_FixedPairListLennardJonesCapped):223 def __init__(self, system, vl, potential):224 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():225 cxxinit(self, interaction_FixedPairListLennardJonesCapped, system, vl, potential)226 227 def setPotential(self, potential):228 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():229 self.cxxclass.setPotential(self, potential)230 def getPotential(self):231 if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():232 return self.cxxclass.getPotential(self)233if pmi.isController:234 class LennardJonesCapped(Potential):235 'The Lennard-Jones potential.'236 pmiproxydefs = dict(237 cls = 'espressopp.interaction.LennardJonesCappedLocal',238 pmiproperty = ['epsilon', 'sigma', 'cutoff', 'caprad']239 )240 class VerletListLennardJonesCapped(Interaction):241 __metaclass__ = pmi.Proxy242 pmiproxydefs = dict(243 cls = 'espressopp.interaction.VerletListLennardJonesCappedLocal',244 pmicall = ['setPotential', 'getPotential']245 )246 class VerletListAdressLennardJonesCapped(Interaction):247 __metaclass__ = pmi.Proxy248 pmiproxydefs = dict(249 cls = 'espressopp.interaction.VerletListAdressLennardJonesCappedLocal',250 pmicall = ['setPotentialAT', 'setPotentialCG', 'getPotentialAT', 'getPotentialCG']251 )252 253 class VerletListHadressLennardJonesCapped(Interaction):254 __metaclass__ = pmi.Proxy255 pmiproxydefs = dict(256 cls = 'espressopp.interaction.VerletListHadressLennardJonesCappedLocal',257 pmicall = ['setPotentialAT', 'setPotentialCG', 'getPotentialAT', 'getPotentialCG']258 )259 class CellListLennardJonesCapped(Interaction):260 __metaclass__ = pmi.Proxy261 pmiproxydefs = dict(262 cls = 'espressopp.interaction.CellListLennardJonesCappedLocal',263 pmicall = ['setPotential', 'getPotential']264 )265 266 class FixedPairListLennardJonesCapped(Interaction):267 __metaclass__ = pmi.Proxy268 pmiproxydefs = dict(269 cls = 'espressopp.interaction.FixedPairListLennardJonesCappedLocal',270 pmicall = ['setPotential']...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful