How to use load_in method in Selene

Best Python code snippet using selene_python

gen_OD_matrix.py

Source:gen_OD_matrix.py Github

copy

Full Screen

1from pyDOE import *2import numpy as np3import os4def generate_matrix(inputs):5 UB_1 = inputs["UB_1"]6 UB_2 = inputs["UB_2"]7 UB_3 = inputs["UB_3"]8 9 LB_1 = inputs["LB_1"]10 LB_2 = inputs["LB_2"]11 LB_3 = inputs["LB_3"]12 UB = [UB_1,UB_2,UB_3]13 LB = [LB_1,LB_2,LB_3]14 num_inputs = inputs["num_inputs"]15 numdata = inputs["numdata"]16 LHS = lhs(num_inputs,samples=numdata,criterion='maximin')17 for i in range(LHS.shape[0]):18 for j in range(LHS.shape[1]):19 val = LHS[i,j]20 ub = UB[j]21 lb = LB[j]22 real_val = val * (ub - lb) + lb23 LHS[i,j] = real_val24 trainingdir = inputs["trainingdir"]25 if not os.path.exists(trainingdir):26 os.makedirs(trainingdir)27 np.savetxt("%s/OD_matrix.csv"%(trainingdir),LHS,delimiter=",")28 29 f = open("%s/OD_matrix.csv"%(trainingdir),"a")30 f.write("%s,%s,%s\n"%(inputs["T_HTF_des"],inputs["load_des"],inputs["T_amb_des"]))31 f.close()32def generate_matrix_factorial(inputs):33 T_in_ref_blk = inputs["T_HTF_des"]34 load_des = inputs["load_des"]35 T_amb_des = inputs["T_amb_des"]36 T_in = np.linspace(T_in_ref_blk-50,T_in_ref_blk+5,50)37 load_in = np.linspace(0.45,load_des+0.25,50)38 T_amb_in = np.linspace(-20,50,50)39 res_matrix = []40 #OAT MATRIX ==> 75 data41 for i in range(len(T_in)):42 a = [T_in[i],load_des,T_amb_des]43 res_matrix.append(a)44 for i in range(len(load_in)):45 a = [T_in_ref_blk,load_in[i],T_amb_des]46 res_matrix.append(a)47 for i in range(len(T_amb_in)):48 a = [T_in_ref_blk,load_des,T_amb_in[i]]49 res_matrix.append(a)50 51 #Varying two variables ==> 12552 T_in = np.linspace(T_in_ref_blk-50,T_in_ref_blk+5,7)53 load_in = np.linspace(0.45,load_des+0.25,6)54 T_amb_in = np.linspace(-20,50,6)55 for t_amb in T_amb_in:56 for load in load_in:57 for T in T_in:58 a = [T,load,t_amb]59 res_matrix.append(a)60 61 #Appending design point at the very end of the OD matrix62 a = [T_in_ref_blk,load_des,T_amb_des]63 res_matrix.append(a)64 #Save the list of list as CSV65 res_matrix = np.array(res_matrix)66 trainingdir = inputs["trainingdir"]67 if not os.path.exists(trainingdir):68 os.makedirs(trainingdir)69 np.savetxt("%s/OD_matrix.csv"%(trainingdir),res_matrix,delimiter=",")70 return71def generate_matrix_validation(inputs):72 T_in_ref_blk = inputs["T_HTF_des"]73 load_des = inputs["load_des"]74 T_amb_des = inputs["T_amb_des"]75 T_in = np.linspace(T_in_ref_blk-50,T_in_ref_blk+5,5)76 load_in = np.linspace(0.45,load_des+0.25,5)77 T_amb_in = np.linspace(-20,50,5)78 res_matrix = []79 #OAT MATRIX ==> 15 data80 '''for i in range(len(T_in)):81 a = [T_in[i],load_des,T_amb_des]82 res_matrix.append(a)83 for i in range(len(load_in)):84 a = [T_in_ref_blk,load_in[i],T_amb_des]85 res_matrix.append(a)86 for i in range(len(T_amb_in)):87 a = [T_in_ref_blk,load_des,T_amb_in[i]]88 res_matrix.append(a)'''89 90 #Varying two variables ==> 2791 T_in = np.linspace(T_in_ref_blk-50,T_in_ref_blk+5,3)92 load_in = np.linspace(0.45,load_des+0.25,3)93 T_amb_in = [-5,10,30]94 for t_amb in T_amb_in:95 for load in load_in:96 for T in T_in:97 a = [T,load,t_amb]98 res_matrix.append(a)99 100 #Appending design point at the very end of the OD matrix101 a = [T_in_ref_blk,load_des,T_amb_des]102 res_matrix.append(a)103 #Save the list of list as CSV104 res_matrix = np.array(res_matrix)105 trainingdir = inputs["trainingdir"]106 if not os.path.exists(trainingdir):107 os.makedirs(trainingdir)108 np.savetxt("%s/OD_matrix.csv"%(trainingdir),res_matrix,delimiter=",")109 return110if __name__ == "__main__":111 inputs = {}112 inputs["UB_1"] = 1100 + 25113 inputs["UB_2"] = 1.25114 inputs["UB_3"] = 50115 inputs["LB_1"] = 950116 inputs["LB_2"] = 0.45117 inputs["LB_3"] = -20118 inputs["T_HTF_des"] = 1000119 inputs["load_des"] = 1120 inputs["T_amb_des"] = 41121 inputs["num_inputs"] = 3122 inputs["numdata"] = 500123 inputs["trainingdir"] = "."124 generate_matrix_factorial(inputs)...

Full Screen

Full Screen

remind.py

Source:remind.py Github

copy

Full Screen

...10async def one():11 bot = nonebot.get_bot()12 weday = time.gmtime()[6] # 今天是周几13 now = 014 dic = await load_in(f'./timeable/loadmmy/{weday}-{now}.json')15 for i in dic:16 if not dic[i][2]:17 del_in(f'./timeable/loadmmy/{weday}-{now}.json', i)18 return19 dic[i][2] -= 120 await bot.send_private_msg(user_id=i, message=f'叮铃铃~~检测到下节课为{dic[i][0]},起床准备上课啦!!!')21@nonebot.scheduler.scheduled_job('cron', day='*', hour='10', minute='05')22async def two():23 bot = nonebot.get_bot()24 weday = time.gmtime()[6] # 今天是周几25 now = 126 dic = await load_in(f'./timeable/loadmmy/{weday}-{now}.json')27 for i in dic:28 if not dic[i][2]:29 del_in(f'./timeable/loadmmy/{weday}-{now}.json', i)30 return31 dic[i][2] -= 132 await bot.send_private_msg(user_id=i, message=f'叮铃铃~~检测到下节课为{dic[i][0]},记得好好上课哟~')33@nonebot.scheduler.scheduled_job('cron', day='*', hour='13', minute='40')34async def three():35 bot = nonebot.get_bot()36 weday = time.gmtime()[6] # 今天是周几37 now = 238 dic = await load_in(f'./timeable/loadmmy/{weday}-{now}.json')39 for i in dic:40 if not dic[i][2]:41 del_in(f'./timeable/loadmmy/{weday}-{now}.json', i)42 return43 dic[i][2] -= 144 await bot.send_private_msg(user_id=i, message=f'叮铃铃~~检测到下节课为{dic[i][0]},准备好迎接一个清爽的下午了吗!')45@nonebot.scheduler.scheduled_job('cron', day='*', hour='15', minute='35')46async def four():47 bot = nonebot.get_bot()48 weday = time.gmtime()[6] # 今天是周几49 now = 350 dic = await load_in(f'./timeable/loadmmy/{weday}-{now}.json')51 for i in dic:52 if not dic[i][2]:53 del_in(f'./timeable/loadmmy/{weday}-{now}.json', i)54 return55 dic[i][2] -= 156 await bot.send_private_msg(user_id=i, message=f'叮铃铃~~检测到下节课为{dic[i][0]},这个下午过得还开心吗~')57@nonebot.scheduler.scheduled_job('cron', day='*', hour='18', minute='20')58async def five():59 bot = nonebot.get_bot()60 weday = time.gmtime()[6] # 今天是周几61 now = 462 dic = await load_in(f'./timeable/loadmmy/{weday}-{now}.json')63 for i in dic:64 if not dic[i][2]:65 del_in(f'./timeable/loadmmy/{weday}-{now}.json', i)66 return67 dic[i][2] -= 1...

Full Screen

Full Screen

givenpage.py

Source:givenpage.py Github

copy

Full Screen

...28class LoadingHtmlPage(object):29 def __init__(self, timeout=0, body=''):30 self._body = body31 self._timeout = timeout32 def load_in(self, driver):33 driver.get(EMPTY_PAGE_URL)34 return LoadedHtmlPage(driver).render_body(self._body, self._timeout)35class LoadedHtmlPage(object):36 def __init__(self, driver):37 self._driver = driver38 def render_body(self, body, timeout=0):39 self._driver.execute_script(40 'setTimeout(function() { document.getElementsByTagName("body")[0].innerHTML = "'41 + body.replace('\n', ' ').replace('"', '\\"')42 + '";}, '43 + str(timeout)44 + ');'45 )46 return self47 def execute_script(self, script):48 self._driver.execute_script(script)49 return self50 def execute_script_with_timeout(self, script, timeout):51 self._driver.execute_script(52 'setTimeout(function() { '53 + script.replace('\n', ' ')54 + ' }, '55 + str(timeout)56 + ');'57 )58 return self59 def render_body_with_timeout(self, body, timeout):60 return self.render_body(body, timeout)61class GivenPage(object):62 def __init__(self, driver):63 self._driver = driver64 def load_body_with_timeout(self, body, timeout):65 return LoadedHtmlPage(self._driver).render_body_with_timeout(66 body, timeout67 )68 def opened_with_body_with_timeout(self, body, timeout):69 return LoadingHtmlPage(timeout, body).load_in(self._driver)70 def opened_with_body(self, body):71 return self.opened_with_body_with_timeout(body, 0)72 def opened_empty(self):73 return LoadingHtmlPage().load_in(self._driver)74 def load_body(self, body):75 return LoadedHtmlPage(self._driver).render_body(body)76 def execute_script_with_timeout(self, script, timeout):77 LoadedHtmlPage(self._driver).execute_script_with_timeout(78 script, timeout...

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 Selene 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