Best Python code snippet using lemoncheesecake
test_autoplot.py
Source:test_autoplot.py
...43# @viz_reg_test44# def test_autoplot_{n}():45# return ar.autoplot(data.head({nrows}), columns={vars})46#47# show_test(test_autoplot_{n})48# """.format(49# nrows=nrows, vars=vars, n=n50# )51# )52#' <h3> Test autoplot #1</h3>53@viz_reg_test54def test_autoplot_1():55 return ar.autoplot(data.head(10), columns=["x"])56show_test(test_autoplot_1)57#' <h3> Test autoplot #2</h3>58@viz_reg_test59def test_autoplot_2():60 return ar.autoplot(data.head(50), columns=["x"])61show_test(test_autoplot_2)62#' <h3> Test autoplot #3</h3>63@viz_reg_test64def test_autoplot_3():65 return ar.autoplot(data.head(250), columns=["x"])66show_test(test_autoplot_3)67#' <h3> Test autoplot #4</h3>68@viz_reg_test69def test_autoplot_4():70 return ar.autoplot(data.head(1000), columns=["x"])71show_test(test_autoplot_4)72#' <h3> Test autoplot #5</h3>73@viz_reg_test74def test_autoplot_5():75 return ar.autoplot(data.head(5000), columns=["x"])76show_test(test_autoplot_5)77#' <h3> Test autoplot #6</h3>78@viz_reg_test79def test_autoplot_6():80 return ar.autoplot(data.head(10), columns=["x_cat"])81show_test(test_autoplot_6)82#' <h3> Test autoplot #7</h3>83@viz_reg_test84def test_autoplot_7():85 return ar.autoplot(data.head(50), columns=["x_cat"])86show_test(test_autoplot_7)87#' <h3> Test autoplot #8</h3>88@viz_reg_test89def test_autoplot_8():90 return ar.autoplot(data.head(250), columns=["x_cat"])91show_test(test_autoplot_8)92#' <h3> Test autoplot #9</h3>93@viz_reg_test94def test_autoplot_9():95 return ar.autoplot(data.head(1000), columns=["x_cat"])96show_test(test_autoplot_9)97#' <h3> Test autoplot #10</h3>98@viz_reg_test99def test_autoplot_10():100 return ar.autoplot(data.head(5000), columns=["x_cat"])101show_test(test_autoplot_10)102#' <h3> Test autoplot #11</h3>103@viz_reg_test104def test_autoplot_11():105 return ar.autoplot(data.head(10), columns=["x", "y"])106show_test(test_autoplot_11)107#' <h3> Test autoplot #12</h3>108@viz_reg_test109def test_autoplot_12():110 return ar.autoplot(data.head(50), columns=["x", "y"])111show_test(test_autoplot_12)112#' <h3> Test autoplot #13</h3>113@viz_reg_test114def test_autoplot_13():115 return ar.autoplot(data.head(250), columns=["x", "y"])116show_test(test_autoplot_13)117#' <h3> Test autoplot #14</h3>118@viz_reg_test119def test_autoplot_14():120 return ar.autoplot(data.head(1000), columns=["x", "y"])121show_test(test_autoplot_14)122#' <h3> Test autoplot #15</h3>123@viz_reg_test124def test_autoplot_15():125 return ar.autoplot(data.head(5000), columns=["x", "y"])126show_test(test_autoplot_15)127#' <h3> Test autoplot #16</h3>128@viz_reg_test129def test_autoplot_16():130 return ar.autoplot(data.head(10), columns=["x_cat", "y"])131show_test(test_autoplot_16)132#' <h3> Test autoplot #17</h3>133@viz_reg_test134def test_autoplot_17():135 return ar.autoplot(data.head(50), columns=["x_cat", "y"])136show_test(test_autoplot_17)137#' <h3> Test autoplot #18</h3>138@viz_reg_test139def test_autoplot_18():140 return ar.autoplot(data.head(250), columns=["x_cat", "y"])141show_test(test_autoplot_18)142#' <h3> Test autoplot #19</h3>143@viz_reg_test144def test_autoplot_19():145 return ar.autoplot(data.head(1000), columns=["x_cat", "y"])146show_test(test_autoplot_19)147#' <h3> Test autoplot #20</h3>148@viz_reg_test149def test_autoplot_20():150 return ar.autoplot(data.head(5000), columns=["x_cat", "y"])151show_test(test_autoplot_20)152#' <h3> Test autoplot #21</h3>153@viz_reg_test154def test_autoplot_21():155 return ar.autoplot(data.head(10), columns=["x_cat", "y_cat"])156show_test(test_autoplot_21)157#' <h3> Test autoplot #22</h3>158@viz_reg_test159def test_autoplot_22():160 return ar.autoplot(data.head(50), columns=["x_cat", "y_cat"])161show_test(test_autoplot_22)162#' <h3> Test autoplot #23</h3>163@viz_reg_test164def test_autoplot_23():165 return ar.autoplot(data.head(250), columns=["x_cat", "y_cat"])166show_test(test_autoplot_23)167#' <h3> Test autoplot #24</h3>168@viz_reg_test169def test_autoplot_24():170 return ar.autoplot(data.head(1000), columns=["x_cat", "y_cat"])171show_test(test_autoplot_24)172#' <h3> Test autoplot #25</h3>173@viz_reg_test174def test_autoplot_25():175 return ar.autoplot(data.head(5000), columns=["x_cat", "y_cat"])176show_test(test_autoplot_25)177#' <h3> Test autoplot #26</h3>178@viz_reg_test179def test_autoplot_26():180 return ar.autoplot(data.head(10), columns=["x", "y", "z"])181show_test(test_autoplot_26)182#' <h3> Test autoplot #27</h3>183@viz_reg_test184def test_autoplot_27():185 return ar.autoplot(data.head(50), columns=["x", "y", "z"])186show_test(test_autoplot_27)187#' <h3> Test autoplot #28</h3>188@viz_reg_test189def test_autoplot_28():190 return ar.autoplot(data.head(250), columns=["x", "y", "z"])191show_test(test_autoplot_28)192#' <h3> Test autoplot #29</h3>193@viz_reg_test194def test_autoplot_29():195 return ar.autoplot(data.head(1000), columns=["x", "y", "z"])196show_test(test_autoplot_29)197#' <h3> Test autoplot #30</h3>198@viz_reg_test199def test_autoplot_30():200 return ar.autoplot(data.head(5000), columns=["x", "y", "z"])201show_test(test_autoplot_30)202#' <h3> Test autoplot #31</h3>203@viz_reg_test204def test_autoplot_31():205 return ar.autoplot(data.head(10), columns=["x_cat", "y", "z"])206show_test(test_autoplot_31)207#' <h3> Test autoplot #32</h3>208@viz_reg_test209def test_autoplot_32():210 return ar.autoplot(data.head(50), columns=["x_cat", "y", "z"])211show_test(test_autoplot_32)212#' <h3> Test autoplot #33</h3>213@viz_reg_test214def test_autoplot_33():215 return ar.autoplot(data.head(250), columns=["x_cat", "y", "z"])216show_test(test_autoplot_33)217#' <h3> Test autoplot #34</h3>218@viz_reg_test219def test_autoplot_34():220 return ar.autoplot(data.head(1000), columns=["x_cat", "y", "z"])221show_test(test_autoplot_34)222#' <h3> Test autoplot #35</h3>223@viz_reg_test224def test_autoplot_35():225 return ar.autoplot(data.head(5000), columns=["x_cat", "y", "z"])226show_test(test_autoplot_35)227#' <h3> Test autoplot #36</h3>228@viz_reg_test229def test_autoplot_36():230 return ar.autoplot(data.head(10), columns=["x_cat", "y_cat", "z"])231show_test(test_autoplot_36)232#' <h3> Test autoplot #37</h3>233@viz_reg_test234def test_autoplot_37():235 return ar.autoplot(data.head(50), columns=["x_cat", "y_cat", "z"])236show_test(test_autoplot_37)237#' <h3> Test autoplot #38</h3>238@viz_reg_test239def test_autoplot_38():240 return ar.autoplot(data.head(250), columns=["x_cat", "y_cat", "z"])241show_test(test_autoplot_38)242#' <h3> Test autoplot #39</h3>243@viz_reg_test244def test_autoplot_39():245 return ar.autoplot(data.head(1000), columns=["x_cat", "y_cat", "z"])246show_test(test_autoplot_39)247#' <h3> Test autoplot #40</h3>248@viz_reg_test249def test_autoplot_40():250 return ar.autoplot(data.head(5000), columns=["x_cat", "y_cat", "z"])251show_test(test_autoplot_40)252#' <h3> Test autoplot #41</h3>253@viz_reg_test254def test_autoplot_41():255 return ar.autoplot(data.head(10), columns=["x_cat", "y_cat", "z_cat"])256show_test(test_autoplot_41)257#' <h3> Test autoplot #42</h3>258@viz_reg_test259def test_autoplot_42():260 return ar.autoplot(data.head(50), columns=["x_cat", "y_cat", "z_cat"])261show_test(test_autoplot_42)262#' <h3> Test autoplot #43</h3>263@viz_reg_test264def test_autoplot_43():265 return ar.autoplot(data.head(250), columns=["x_cat", "y_cat", "z_cat"])266show_test(test_autoplot_43)267#' <h3> Test autoplot #44</h3>268@viz_reg_test269def test_autoplot_44():270 return ar.autoplot(data.head(1000), columns=["x_cat", "y_cat", "z_cat"])271show_test(test_autoplot_44)272#' <h3> Test autoplot #45</h3>273@viz_reg_test274def test_autoplot_45():275 return ar.autoplot(data.head(5000), columns=["x_cat", "y_cat", "z_cat"])276show_test(test_autoplot_45)277#' To finish three corner cases when there's no overlap with categorical vars only278w = pd.Series(range(10))279no_overlap_data = pd.DataFrame(280 dict(281 x=pd.concat([w, w - 3]).astype(str),282 y=pd.concat([w, w]).astype(str),283 z=pd.concat([w, w]).astype(str),284 )285)286@viz_reg_test287def test_autoplot_CCC():288 return ar.autoplot(no_overlap_data)289show_test(test_autoplot_CCC)290@viz_reg_test291def test_autoplot_CC():292 return ar.autoplot(no_overlap_data, columns=["x", "y"])293show_test(test_autoplot_CC)294@viz_reg_test295def test_autoplot_C():296 return ar.autoplot(no_overlap_data.head(10), columns=["x"])...
kernel_utils.py
Source:kernel_utils.py
1import logging2import numpy as np3from eval_pd import get_evaluation_results4from itertools import combinations5from global_constants import *6from global_utils import *7def run_config(c, dataset, resulting_matrices, labels,show_test=True, probability=False,8 skip_all_positives_and_all_negatives=True):9 cs = set(c)10 label = " + ".join(cs)11 matrix = dict()12 for mode in ALL_MODES:13 matrix[mode] = sum([v[mode] for k, v in resulting_matrices.items() if k in cs])14 predictions = train_and_predict(matrix, labels, kernel='precomputed', probability=probability)15 dev_results = get_evaluation_results(dataset[DEV], predictions[DEV],16 skip_all_positives_and_all_negatives=skip_all_positives_and_all_negatives)17 test_results = get_evaluation_results(dataset[TEST], predictions[TEST],18 skip_all_positives_and_all_negatives=skip_all_positives_and_all_negatives)19 message = "%s\t%s\t%s" % (label, "\t".join(["%.2f" % (x) for x in list(dev_results)]),20 "\t".join(["%.2f" % (x) for x in list(test_results)]))21 logging.info("DEV:\t%s\t%s" % (label, "\t".join(["%.2f" % (x) for x in list(dev_results)])))22 if show_test:23 logging.info("TEST:\t%s\t%s" % (label, "\t".join(["%.2f" % (x) for x in list(test_results)])))24 return message25def run_experiments(dataset, configurations, resulting_matrices, labels, predefined=False, show_test=True, min_length=1,26 max_length=-1, probability=False, skip_all_positives_and_all_negatives=True):27 messages = []28 if predefined:29 for c in configurations:30 message = run_config(c, dataset, resulting_matrices, labels, show_test=show_test, probability=probability,31 skip_all_positives_and_all_negatives= skip_all_positives_and_all_negatives)32 messages.append(message)33 else:34 start = min_length - 135 end = max_length if max_length > 0 else len(configurations)36 for l in range(start, end):37 for c in combinations(configurations, l + 1):38 message = run_config(c, dataset, resulting_matrices, labels, show_test=show_test,39 probability=probability,40 skip_all_positives_and_all_negatives= skip_all_positives_and_all_negatives)41 messages.append(message)42 return messages43def convert_svm_light_vector_to_np_array(x,array_size,zero_vector):44 aa = zero_vector45# print type(x),x46 if not isinstance(x,str):47 logging.debug("Substituting %s with zero vector" % (str(x)))48 return aa49# if isinstance(x,np.ndarray):50# return x51 aa = np.zeros(shape=(1,array_size))52 if len(x.strip())==0:53 return aa54 for tuplesa in x.strip().split(" "):55 if not ":" in tuplesa:56 logging.error("Wrong format: %s" % (str(x)))57 indexa,valuea=tuplesa.strip().split(":")58 if int(indexa)-1>=array_size:59 print x60 aa[0,int(indexa)-1]=np.float64(valuea)61# print aa[0]...
urls.py
Source:urls.py
1from django.conf.urls import url2from booktest import views3urlpatterns = [4 url(r'^$', views.index, name='index'),5 url(r'^show_test', views.show_test, name='show_test'),6 url(r'^index2/$', views.index2, name='index2'),7 url(r'^user1/$', views.user1, name='user1'),8 url(r'^user2/$', views.user2, name='user2'),9 url(r'^zhuanyi/$', views.zhuanyi, name='zhuanyi'),10 url(r'^csrf1/$', views.csrf1, name='csrf1'),11 url(r'^csrf2/$', views.csrf2, name='csrf2'),12 url(r'^verify1/$', views.verify1, name='verify1'),13 url(r'^verify2/$', views.verify2, name='verify2'),14 url(r'^show_verify/$', views.show_verify, name='show_verify'),...
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!!