How to use render_table method in yandex-tank

Best Python code snippet using yandex-tank

advanced_condition.py

Source:advanced_condition.py Github

copy

Full Screen

...16 db.create_all()17@app.route('/')18def bismillah():19 return "Flask SQLAlchemy Advanced Condition Tutorial"20def render_table(data):21 response = "<table><tr><th>Name</th><th>Email</th><th>Age</th><th>Income</th></tr>"22 for person in data:23 response += "<tr>" + "<td>" + person.first_name + "</td>" + "<td>" + person.email + "</td>"24 response += "<td>" + str(person.age) + "</td>" + "<td>" + str(person.income) + "</td>" + "</tr>"25 response += "</table>"26 return response27def render_details(data):28 if not data:29 return ""30 response = "Name : " + data.first_name + "<br>"31 response += "Email : " + data.email + "<br>"32 response += "Age : " + str(data.age) + "<br>"33 response += "Income : " + str(data.income) + "<br>"34 return response35@app.route('/init-sample-data')36def init_sample_data():37 model_list = []38 for person_number in range(20):39 person = Person(40 first_name="Person " + str(person_number),41 email="person-" + str(person_number) + "@email.loc",42 age=13 + person_number,43 income=13 * person_number,44 )45 model_list.append(person)46 db.session.add_all(model_list)47 db.session.commit()48 return "Successfully Initialized"49@app.route('/list')50def list():51 return render_table(Person.query.all())52@app.route('/query-by-session')53def query_by_session():54 person = db.session.query(Person).first()55 return render_details(person)56@app.route('/equal')57def equal():58 person = Person.query.filter(Person.first_name == "Person 0").one()59 return render_details(person)60@app.route('/not-equal')61def mpt_equal():62 person = Person.query.filter(Person.first_name != "Person 0").all()63 return render_table(person)64@app.route('/less-than')65def less_than():66 person = Person.query.filter(Person.age < 20).all()67 return render_table(person)68@app.route('/less-than-equal')69def less_than_equal():70 person = Person.query.filter(Person.age <= 20).all()71 return render_table(person)72@app.route('/greater-than')73def greater_than():74 person = Person.query.filter(Person.age > 20).all()75 return render_table(person)76@app.route('/greater-than-equal')77def greater_than_equal():78 person = Person.query.filter(Person.age >= 20).all()79 return render_table(person)80@app.route('/like-case-sensitive')81def like_case_sensitive():82 person = Person.query.filter(Person.first_name.like("Person%")).all()83 return render_table(person)84@app.route('/like-case-insensitive')85def like_case_insensitive():86 person = Person.query.filter(Person.first_name.ilike("person%")).all()87 return render_table(person)88@app.route('/in-list')89def in_list():90 person = Person.query.filter(Person.id.in_([12, 13, 18, 1])).all()91 return render_table(person)92@app.route('/not-in-list')93def not_in_list():94 person = Person.query.filter(Person.id.not_in([12, 13, 18, 1])).all()95 return render_table(person)96@app.route('/is-null')97def is_null():98 person = Person.query.filter(Person.last_name == None).all()99 # OR100 person = Person.query.filter(Person.last_name.is_(None)).all()101 return render_table(person)102@app.route('/is-not-null')103def is_not_null():104 person = Person.query.filter(Person.last_name != None).all()105 # OR106 person = Person.query.filter(Person.last_name.is_not(None)).all()107 return render_table(person)108@app.route('/and-condition')109def and_condition():110 person_type1 = Person.query.filter(and_(Person.first_name != "Person 0", Person.first_name != "Person 1")).all()111 # OR112 person_type2 = Person.query.filter(Person.first_name != "Person 0", Person.first_name != "Person 1").all()113 # OR114 person_type3 = Person.query.filter(Person.first_name != "Person 0").filter(Person.first_name != "Person 1").all()115 response = "<h1>Type 1 </h1>"116 response += render_table(person_type1)117 response += "<br/><br/>"118 response += "<h1>Type 2 </h1>"119 response += render_table(person_type2)120 response += "<br/><br/>"121 response += "<h1>Type 3 </h1>"122 response += render_table(person_type3)123 response += "<br/><br/>"124 return response125@app.route('/or-condition')126def or_condition():127 person = Person.query.filter(or_(Person.first_name == "Person 0", Person.first_name == "Person 1")).all()128 return render_table(person)129@app.route('/order-by')130def order_by():131 person = Person.query.order_by(Person.age.asc()).all()132 # OR133 person = Person.query.order_by(Person.age.desc()).all()134 return render_table(person)135if __name__ == '__main__':...

Full Screen

Full Screen

anova.py

Source:anova.py Github

copy

Full Screen

1from matplotlib import pyplot as plt2import pandas as pd3import numpy as np4import math5import scipy.stats as stats6from scipy.stats import norm7import statsmodels.api as sm8import statsmodels.stats.api as sms9import statsmodels.formula.api as smf10def shapiro(df, treatment_name_list, treatment_name, value_name):11 """12 check normal distribution13 """14 for i, name in enumerate(treatment_name_list):15 data = df[value_name][df[treatment_name] == name]16 stat, p = stats.shapiro(data)17 print(f'{i + 1}: Statistics={stat:.4f}, p={p:.4f}')18 return19def qq_plot(row, col, df, treatment_name_list, treatment_name, value_name, figsize=(8, 3), hspace=0.4, wspace=4):20 """21 check normal distribution22 """23 fig = plt.figure(figsize=figsize)24 fig.subplots_adjust(hspace=hspace, wspace=wspace)25 for i, name in enumerate(treatment_name_list):26 ax = fig.add_subplot(row, col, i + 1)27 data = df[value_name][df[treatment_name] == name]28 sm.qqplot(data, stats.norm, fit=True, line='45', ax=ax)29 ax.set_title(treatment_name_list[i])30 fig.tight_layout()31 plt.show()32 return33def bartlett(df, treatment_name_list, treatment_name, value_name):34 """35 Equal Variances (barlett's Test)36 """37 data = []38 for i, name in enumerate(treatment_name_list):39 data.append(df[value_name][df[treatment_name] == name])40 stat = stats.bartlett(*data)41 print(f'p-value: {stat[1]}')42 return stat43def f_oneway(data, treatment_name, value_name):44 """45 return results, aov_table, render_table, f_stat, p_value46 """47 results = smf.ols(f'{value_name} ~ C({treatment_name})', data=data).fit()48 aov_table = sms.anova_lm(results, typ=2)49 f_stat, p_value = aov_table['F'][0], aov_table['PR(>F)'][0]50 render_table = aov_table.copy()51 render_table.columns = ['Sum of Squares',52 'Degree of Freedom', 'F', 'p-value']53 # render_table.index = ['Treatment', 'Error']54 render_table.loc['Total'] = render_table.sum()55 print(f'p-value: {p_value}')56 return results, aov_table, render_table, f_stat, p_value57def f_random_block(data, treatment_name, block_name, value_name, precision=4):58 """59 return results, aov_table, render_table, treatment_f_stat, treatment_p_value, block_f_stat, block_p_value60 """61 results = smf.ols(62 f'{value_name} ~ C({treatment_name}) + C({block_name})', data=data).fit()63 aov_table = sms.anova_lm(results, typ=2)64 treatment_f_stat, treatment_p_value = aov_table['F'][0], aov_table['PR(>F)'][0]65 block_f_stat, block_p_value = aov_table['F'][1], aov_table['PR(>F)'][1]66 render_table = aov_table.copy()67 render_table.columns = ['Sum of Squares',68 'Degree of Freedom', 'F', 'p-value']69 render_table.index = ['Treatment', 'Block', 'Error']70 render_table.loc['Total'] = render_table.sum()71 render_table.loc['Total', ['F', 'p-value']] = np.nan72 print(73 f'Treatment p-value (main): {treatment_p_value:.{precision}f}\nBlock p-value: {block_p_value:.{precision}f}')74 return results, aov_table, render_table, treatment_f_stat, treatment_p_value, block_f_stat, block_p_value75def f_twoway(data, factorA_name, factorB_name, value_name, precision=4):76 """77 return results, aov_table, render_table, factorA_f_stat, factorA_p_value, factorB_f_stat, factorB_p_value, inter_f_stat, inter_p_value78 """79 results = smf.ols(80 f'{value_name} ~ C({factorA_name}) + C({factorB_name}) + C({factorA_name}):C({factorB_name})', data=data).fit()81 aov_table = sms.anova_lm(results, typ=2)82 factorA_f_stat, factorA_p_value = aov_table['F'][0], aov_table['PR(>F)'][0]83 factorB_f_stat, factorB_p_value = aov_table['F'][1], aov_table['PR(>F)'][1]84 inter_f_stat, inter_p_value = aov_table['F'][2], aov_table['PR(>F)'][2]85 render_table = aov_table.copy()86 render_table.columns = ['Sum of Squares',87 'Degree of Freedom', 'F', 'p-value']88 render_table.index = ['Factor A', 'Factor B', 'Interaction', 'Error']89 render_table.loc['Total'] = render_table.sum()90 render_table.loc['Total', ['F', 'p-value']] = np.nan91 print(92 f'Factor A\'s p-value: {factorA_p_value:.{precision}f}\nFactor B\'s p-value: {factorB_p_value:.{precision}f}\nInteraction p-value: {inter_p_value:.{precision}f}')...

Full Screen

Full Screen

test_h5showList.py

Source:test_h5showList.py Github

copy

Full Screen

...24class H5showListTest(unittest.TestCase):25 def test1(self):26 file_name = get_test_file('cadchftickdata.h5')27 with h5py.File(file_name) as loc:28 lst = render_table(loc, '/')29 self.assertEqual(len(lst), 8)30 def test2(self):31 file_name = get_test_file('compound.h5')32 with h5py.File(file_name) as loc:33 lst = render_table(loc, '/')34 self.assertEqual(len(lst), 3)35 def test3(self):36 file_name = get_test_file('compound_attr.h5')37 with h5py.File(file_name) as loc:38 lst = render_table(loc, '/')39 self.assertEqual(len(lst), 2)40 def test4(self):41 file_name = get_test_file('empty.h5')42 with h5py.File(file_name) as loc:43 lst = render_table(loc, '/')44 self.assertEqual(len(lst), 2)45 def test5(self):46 file_name = get_test_file('group100.h5')47 with h5py.File(file_name) as loc:48 lst = render_table(loc, '/')49 self.assertEqual(len(lst), 102)50 def test6(self):51 file_name = get_test_file('hdfeos5.h5')52 with h5py.File(file_name) as loc:53 lst = render_table(loc, '/')54 self.assertEqual(len(lst), 102)55 def test7(self):56 file_name = get_test_file('namedtype.h5')57 with h5py.File(file_name) as loc:58 lst = render_table(loc, '/')59 self.assertEqual(len(lst), 4)60 def test8(self):61 file_name = get_test_file('tall.h5')62 with h5py.File(file_name) as loc:63 lst = render_table(loc, '/')64 self.assertEqual(len(lst), 11)65 66 lst = render_table(loc, '/g1/g1.2/g1.2.1/slink')67 self.assertEqual(len(lst), 2)68 def test8(self):69 file_name = get_test_file('tall_with_udlink.h5')70 with h5py.File(file_name) as loc:71 lst = render_table(loc, '/')72 self.assertEqual(len(lst), 11)73 74 lst = render_table(loc, '/g1/g1.2/extlink')75 self.assertEqual(len(lst), 2)76 self.assertRaises(Exception, render_table, loc, '/g2/udlink')77 def test9(self):78 file_name = get_test_file('tgroup.h5')79 with h5py.File(file_name) as loc:80 lst = render_table(loc, '/')81 self.assertEqual(len(lst), 15)82 def test9(self):83 file_name = get_test_file('tref.h5')84 with h5py.File(file_name) as loc:85 lst = render_table(loc, '/')86 self.assertEqual(len(lst), 6)87 def test10(self):88 file_name = get_test_file('tstr.h5')89 with h5py.File(file_name) as loc:90 lst = render_table(loc, '/')91 self.assertEqual(len(lst), 7)92 def test11(self):93 file_name = get_test_file('zerodim.h5')94 with h5py.File(file_name) as loc:95 lst = render_table(loc, '/')96 self.assertEqual(len(lst), 3)97if __name__ == '__main__':98 logging.basicConfig(level=logging.INFO)99 #setup test files...

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 yandex-tank 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