Best Python code snippet using AutoItDriverServer_python
factor.py
Source:factor.py  
1import pandas as pd2class Factor(object):3    def __init__(self, name, max_window, dependencies):4        self.name = name5        self.max_window = max_window6        self.dependencies = dependencies7    def calc(self):8        pass9def calc_factors(universe, factor_list, date):10    factor_dict = dict({})11    for fac in factor_list:12        factor_dict[fac.name] = fac.calc(universe, date)13    return factor_dict14######################################## å å对象 ###############################################15class gb(Factor):16    def __init__(self,name = 'gb',max_window = 1,dependencies = ['alpham5am10']):17        Factor.__init__(self,name,max_window,dependencies)18    19    def calc(self,):20        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')21        return data22class rf(Factor):23    def __init__(self,name = 'rf',max_window = 1,dependencies = ['alpham5am10']):24        Factor.__init__(self,name,max_window,dependencies)25    26    def calc(self,):27        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')28        return data29class knn(Factor):30    def __init__(self,name = 'knn',max_window = 1,dependencies = ['alpham5am10']):31        Factor.__init__(self,name,max_window,dependencies)32    33    def calc(self,):34        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')35        return data36class svr(Factor):37    def __init__(self,name = 'svr',max_window = 1,dependencies = ['alpham5am10']):38        Factor.__init__(self,name,max_window,dependencies)39    40    def calc(self,):41        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')42        return data43class mlp(Factor):44    def __init__(self,name = 'mlp',max_window = 1,dependencies = ['alpham5am10']):45        Factor.__init__(self,name,max_window,dependencies)46    47    def calc(self,):48        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')49        return data50class lr(Factor):51    def __init__(self,name = 'lr',max_window = 1,dependencies = ['alpham5am10']):52        Factor.__init__(self,name,max_window,dependencies)53    54    def calc(self,):55        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')56        return data57class varm5am10(Factor):58    def __init__(self,name = 'varm5am10',max_window = 1,dependencies = ['alpham5am10']):59        Factor.__init__(self,name,max_window,dependencies)60    61    def calc(self,):62        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')63        return data64class varm10am10(Factor):65    def __init__(self,name = 'varm10am10',max_window = 1,dependencies = ['alpham5am10']):66        Factor.__init__(self,name,max_window,dependencies)67    68    def calc(self,):69        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')70        return data71class varm15am10(Factor):72    def __init__(self,name = 'varm15am10',max_window = 1,dependencies = ['alpham5am10']):73        Factor.__init__(self,name,max_window,dependencies)74    75    def calc(self,):76        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')77        return data78class varm20am10(Factor):79    def __init__(self,name = 'varm20am10',max_window = 1,dependencies = ['alpham5am10']):80        Factor.__init__(self,name,max_window,dependencies)81    82    def calc(self,):83        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')84        return data85class lgb_factor_intraday(Factor):86    def __init__(self,name = 'lgb_factor_intraday',max_window = 1,dependencies = ['alpham5am10']):87        Factor.__init__(self,name,max_window,dependencies)88    89    def calc(self,):90        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')91        return data92class lgb_factor_daily(Factor):93    def __init__(self,name = 'lgb_factor_daily',max_window = 1,dependencies = ['alpham5am10']):94        Factor.__init__(self,name,max_window,dependencies)95    96    def calc(self,):97        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')98        return data99class lgb_factor_daily_test(Factor):100    def __init__(self,name = 'lgb_factor_daily_test',max_window = 1,dependencies = ['alpham5am10']):101        Factor.__init__(self,name,max_window,dependencies)102    103    def calc(self,):104        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')105        return data106class lgb_1519(Factor):107    def __init__(self,name = 'lgb_1519',max_window = 1,dependencies = ['alpham5am10']):108        Factor.__init__(self,name,max_window,dependencies)109    110    def calc(self,):111        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')112        return data113class alpham5am10(Factor):114    def __init__(self,name = 'alpham5am10',max_window = 1,dependencies = ['alpham5am10']):115        Factor.__init__(self,name,max_window,dependencies)116    117    def calc(self,):118        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')119        return data120class alpham10am10(Factor):121    def __init__(self,name = 'alpham10am10',max_window = 1,dependencies = ['alpham10am10']):122        Factor.__init__(self,name,max_window,dependencies)123    124    def calc(self,):125        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')126        return data127class alpham15am10(Factor):128    def __init__(self,name = 'alpham15am10',max_window = 1,dependencies = ['alpham15am10']):129        Factor.__init__(self,name,max_window,dependencies)130    131    def calc(self,):132        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')133        return data134class alpham20am10(Factor):135    def __init__(self,name = 'alpham20am10',max_window = 1,dependencies = ['alpham20am10']):136        Factor.__init__(self,name,max_window,dependencies)137    138    def calc(self,):139        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')140        return data141class alphad30_vard30(Factor):142    def __init__(self,name = 'alphad30_vard30',max_window = 1,dependencies = ['vard1']):143        Factor.__init__(self,name,max_window,dependencies)144    145    def calc(self,):146        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')147        # ans = data.loc[date, universe]148        return data149class vard1(Factor):150    def __init__(self,name = 'vard1',max_window = 1,dependencies = ['vard1']):151        Factor.__init__(self,name,max_window,dependencies)152    153    def calc(self,):154        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')155        # ans = data.loc[date, universe]156        return data157class vard2(Factor):158    def __init__(self,name = 'vard2',max_window = 1,dependencies = ['vard1']):159        Factor.__init__(self,name,max_window,dependencies)160    161    def calc(self,):162        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')163        # ans = data.loc[date, universe]164        return data165class vard3(Factor):166    def __init__(self,name = 'vard3',max_window = 1,dependencies = ['vard3']):167        Factor.__init__(self,name,max_window,dependencies)168    169    def calc(self,):170        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')171        return data172class vard4(Factor):173    def __init__(self,name = 'vard4',max_window = 1,dependencies = ['vard4']):174        Factor.__init__(self,name,max_window,dependencies)175    176    def calc(self,):177        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')178        return data179class vard5(Factor):180    def __init__(self,name = 'vard5',max_window = 1,dependencies = ['vard5']):181        Factor.__init__(self,name,max_window,dependencies)182    183    def calc(self,):184        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')185        return data186class vard10(Factor):187    def __init__(self,name = 'vard10',max_window = 1,dependencies = ['vard10']):188        Factor.__init__(self,name,max_window,dependencies)189    190    def calc(self,):191        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')192        return data193class vard20(Factor):194    def __init__(self,name = 'vard20',max_window = 1,dependencies = ['vard20']):195        Factor.__init__(self,name,max_window,dependencies)196    197    def calc(self,):198        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')199        return data200class vard30(Factor):201    def __init__(self,name = 'vard30',max_window = 1,dependencies = ['vard30']):202        Factor.__init__(self,name,max_window,dependencies)203    204    def calc(self,):205        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')206        return data207class vard60(Factor):208    def __init__(self,name = 'vard60',max_window = 1,dependencies = ['vard60']):209        Factor.__init__(self,name,max_window,dependencies)210    def calc(self,):211        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')212        return data213class vard120(Factor):214    def __init__(self,name = 'vard120',max_window = 1,dependencies = ['alphad120']):215        Factor.__init__(self,name,max_window,dependencies)216    def calc(self,):217        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')218        return data219class vard240(Factor):220    def __init__(self,name = 'vard240',max_window = 1,dependencies = ['alphad240']):221        Factor.__init__(self,name,max_window,dependencies)222    def calc(self,):223        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')224        return data225class alphad1(Factor):226    def __init__(self,name = 'alphad1',max_window = 1,dependencies = ['alphad1']):227        Factor.__init__(self,name,max_window,dependencies)228    229    def calc(self,):230        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')231        # ans = data.loc[date, universe]232        return data233class alphad2(Factor):234    def __init__(self,name = 'alphad2',max_window = 1,dependencies = ['alphad2']):235        Factor.__init__(self,name,max_window,dependencies)236    237    def calc(self,):238        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')239        return data240class alphad3(Factor):241    def __init__(self,name = 'alphad3',max_window = 1,dependencies = ['alphad3']):242        Factor.__init__(self,name,max_window,dependencies)243    244    def calc(self,):245        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')246        return data247class alphad4(Factor):248    def __init__(self,name = 'alphad4',max_window = 1,dependencies = ['alphad4']):249        Factor.__init__(self,name,max_window,dependencies)250    251    def calc(self,):252        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')253        return data254class alphad5(Factor):255    def __init__(self,name = 'alphad5',max_window = 1,dependencies = ['alphad5']):256        Factor.__init__(self,name,max_window,dependencies)257    258    def calc(self,):259        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')260        return data261class alphad10(Factor):262    def __init__(self,name = 'alphad10',max_window = 1,dependencies = ['alphad10']):263        Factor.__init__(self,name,max_window,dependencies)264    265    def calc(self,):266        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')267        return data268class alphad20(Factor):269    def __init__(self,name = 'alphad20',max_window = 1,dependencies = ['alphad20']):270        Factor.__init__(self,name,max_window,dependencies)271    272    def calc(self,):273        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')274        return data275class alphad30(Factor):276    def __init__(self,name = 'alphad30',max_window = 1,dependencies = ['alphad30']):277        Factor.__init__(self,name,max_window,dependencies)278    279    def calc(self,):280        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')281        return data282class alphad60(Factor):283    def __init__(self,name = 'alphad60',max_window = 1,dependencies = ['alphad60']):284        Factor.__init__(self,name,max_window,dependencies)285    def calc(self,):286        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')287        return data288class alphad120(Factor):289    def __init__(self,name = 'alphad120',max_window = 1,dependencies = ['alphad120']):290        Factor.__init__(self,name,max_window,dependencies)291    def calc(self,):292        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')293        return data294class alphad240(Factor):295    def __init__(self,name = 'alphad240',max_window = 1,dependencies = ['alphad240']):296        Factor.__init__(self,name,max_window,dependencies)297    def calc(self,):298        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')299        return data300class alphard240_md5(Factor):301    def __init__(self,name = 'alphard240_md5',max_window = 1,dependencies = ['alphad240']):302        Factor.__init__(self,name,max_window,dependencies)303    def calc(self,):304        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')305        return data306class pctd1(Factor):307    def __init__(self,name = 'pctd1',max_window = 1,dependencies = ['pctd1']):308        Factor.__init__(self,name,max_window,dependencies)309    310    def calc(self):311        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')312        # ans = data.loc[date, universe]313        return data314class pctd60(Factor):315    def __init__(self,name = 'pctd60',max_window = 1,dependencies = ['pctd60']):316        Factor.__init__(self,name,max_window,dependencies)317    def calc(self):318        data = pd.read_pickle('../data/factors/'+self.name+'.pkl')319        # ans = data.loc[date, universe]320        return data...Longest Substring With Without Repeating Characters.py
Source:Longest Substring With Without Repeating Characters.py  
1def longestSubStringWithoutRepeating(string):2    n = len(string)3    hashMap = {}4    max_window = 05    i = j = 06    FLAG = False7    while j < n:8        FLAG = False9        char = string[j]10        if char not in hashMap:11            hashMap[char] = 112            j += 113            FLAG = True14        else:15            max_window = max(max_window, j - i)16            while string[i] != char:17                if hashMap[string[i]] == 1:18                    del hashMap[string[i]]19                i += 120            del hashMap[char]21            i += 122    if FLAG:23        max_window = max(max_window, j - i)24    return max_window25def longestSubStringWithoutRepeating2(string):26    n = len(string)27    hashMap = {}28    i = j = 029    max_window = -130    current_window = 031    while j < n:32        current_window = j - i + 133        char = string[j]34        if char not in hashMap:35            hashMap[char] = 136        else:37            hashMap[char] += 138        39        if len(hashMap) > current_window:40            j += 141        42        elif len(hashMap) == current_window:43            max_window = max(max_window, current_window)44            j += 145        46        elif len(hashMap) < current_window:47            while len(hashMap) and len(hashMap) < current_window:48                char = string[i]49                hashMap[char] -= 150                if hashMap[char] == 0:51                    del hashMap[char]52                i += 153            max_window = max(max_window, current_window)54            j += 155            56    return max_window57if __name__ == "__main__":58    s = "pwwkew"59    print(longestSubStringWithoutRepeating(s))...2096.py
Source:2096.py  
1from .. import util2example = """3341 2 354 5 664 9 07"""8util.setinput(example)9import sys10input = sys.stdin.readline11N = int(input())12min_window = [[0 for _ in range(3)] for _ in range(2)]13max_window = [[0 for _ in range(3)] for _ in range(2)]14for n in range(N):15    num = list(map(int, input().split()))16    current = n % 217    next = (n + 1) % 218    min_window[next][0] = min(19        min_window[current][0] + num[0], min_window[current][1] + num[0]20    )21    min_window[next][1] = min(22        min_window[current][0] + num[1],23        min_window[current][1] + num[1],24        min_window[current][2] + num[1],25    )26    min_window[next][2] = min(27        min_window[current][1] + num[2], min_window[current][2] + num[2]28    )29    max_window[next][0] = max(30        max_window[current][0] + num[0], max_window[current][1] + num[0]31    )32    max_window[next][1] = max(33        max_window[current][0] + num[1],34        max_window[current][1] + num[1],35        max_window[current][2] + num[1],36    )37    max_window[next][2] = max(38        max_window[current][1] + num[2], max_window[current][2] + num[2]39    )...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
