How to use assemble method in wpt

Best JavaScript code snippet using wpt

MC_MatchSimSimple.py

Source:MC_MatchSimSimple.py Github

copy

Full Screen

1# Copyright : @TacticsBadger, TacticsNotAntics: https://tacticsnotantics.org2# Version 1.0 : November 17, 20213# Last Updated: January 08, 20224'''5Brief: Monte Carlo simulations for predicting match outcomes.6Needs user input: keyboard or csv. 7'''8import sys9import math10import time11import pandas as pd12import numpy as np13from prettytable import PrettyTable1415print("***************** Tactics Not Antics ******************")16print("***** Monte Carlo Match Simulator *****")17print("***** Version 1.0: November 17, 2021 *****")18print("***** Last Update: January 08, 2021 *****")19print("*******************************************************")20print("******************* PL TEAMS 2021-22 ******************")21print("* Arsenal | Aston Villa | Brentford | Brighton *")22print("* Burnley | Chelsea | Crystal Palace| Everton *")23print("* Leeds | Leicester | Liverpool | Man City *")24print("* Man Utd | Newcastle | Norwich City | Southampton *")25print("* West Ham| Tottenham | Watford | Wolves *")26print("*******************************************************")2728num_simulations = 2000029choice = input("* Keyboard or csv: ")30if choice == "Keyboard":31 print ("Reading data from the keyboard.")32 input_home_team = input("* Add home team: ")33 input_home_team_xg_str = input("* Add home team xG: ")34 input_home_team_xg = float(input_home_team_xg_str)35 input_away_team = input("* Add away team: ")36 input_away_team_xg_str = input("* Add away team xG: ")37 input_away_team_xg = float(input_away_team_xg_str)38 #print the simulation table and run simulations39 print ("********************")40 print ("* *")41 print ("* SIMULATION TABLE *")42 print ("* *")43 print ("********************")44 count_home_wins = 045 count_home_loss = 046 count_away_wins = 047 count_away_loss = 048 count_draws = 049 score_mat = []50 tot_sim_time = 051 sim_table = PrettyTable(["SIMULATION #", "SIMULATION TIME (s)", input_home_team, input_away_team, "HOME WIN", "AWAY WIN", "DRAW", "SCORE MARGIN"])52 for i in range(num_simulations):53 #get simulation start time54 start_time = time.time()55 #run the sim - generate a random Poisson distribution56 target_home_goals_scored = np.random.poisson(input_home_team_xg)57 target_away_goals_scored = np.random.poisson(input_away_team_xg)58 home_win = 059 away_win = 060 draw = 061 margin = 062 # if more goals for home team => home team wins63 if target_home_goals_scored > target_away_goals_scored:64 count_home_wins += 165 count_away_loss += 166 home_win = 167 margin = target_home_goals_scored - target_away_goals_scored68 # if more goals for away team => away team wins69 elif target_home_goals_scored < target_away_goals_scored:70 count_away_wins += 171 count_home_loss += 172 away_win = 173 margin = target_away_goals_scored - target_home_goals_scored74 elif target_home_goals_scored == target_away_goals_scored:75 draw = 176 count_draws += 177 margin = target_away_goals_scored - target_home_goals_scored78 # add score to score matrix79 score_mat.append((target_home_goals_scored, target_away_goals_scored))80 #get end time81 end_time = time.time()82 #add the time to the total simulation time83 tot_sim_time += round((end_time - start_time),5)84 #add the info to the simulation table85 sim_table.add_row([i+1, round((end_time - start_time),5), target_home_goals_scored, target_away_goals_scored, home_win, away_win, draw, margin])86 print(sim_table)8788 # calculate probabilities to win/lose/draw89 home_win_probability = round((count_home_wins/num_simulations * 100),2)90 away_win_probability = round((count_away_wins/num_simulations * 100),2)91 draw_probability = round((count_draws/num_simulations * 100),2)92 93 # print the simulation statistics94 print ("*************")95 print ("* *")96 print ("* SIM STATS *")97 print ("* *")98 print ("*************")99 sim_table_stats = PrettyTable(["Total # of sims", "Total time (s) for sims", "HOME WINS", "AWAY WINS", "DRAWS"])100 sim_table_stats.add_row([num_simulations, round(tot_sim_time,3), count_home_wins, count_away_wins, count_draws])101 sim_table_stats.add_row(["-", "-", str(home_win_probability)+"%", str(away_win_probability)+"%", str(draw_probability)+"%"])102 print(sim_table_stats)103 104 # get the score matrix105 total_scores = len(score_mat)106 max_score = 5107 assemble_scores = [[0 for x in range(max_score)] for y in range(max_score)]108 for i in range(total_scores):109 if score_mat[i][0] == 0 and score_mat[i][1] == 0:110 assemble_scores[0][0] += 1111 elif score_mat[i][0] == 0 and score_mat[i][1] == 1:112 assemble_scores[0][1] += 1113 elif score_mat[i][0] == 0 and score_mat[i][1] == 2:114 assemble_scores[0][2] += 1 115 elif score_mat[i][0] == 0 and score_mat[i][1] == 3:116 assemble_scores[0][3] += 1 117 elif score_mat[i][0] == 0 and score_mat[i][1] == 4:118 assemble_scores[0][4] += 1 119 elif score_mat[i][0] == 1 and score_mat[i][1] == 0:120 assemble_scores[1][0] += 1121 elif score_mat[i][0] == 1 and score_mat[i][1] == 1:122 assemble_scores[1][1] += 1 123 elif score_mat[i][0] == 1 and score_mat[i][1] == 2:124 assemble_scores[1][2] += 1 125 elif score_mat[i][0] == 1 and score_mat[i][1] == 3:126 assemble_scores[1][3] += 1 127 elif score_mat[i][0] == 1 and score_mat[i][1] == 4:128 assemble_scores[1][4] += 1129 elif score_mat[i][0] == 2 and score_mat[i][1] == 0:130 assemble_scores[2][0] += 1131 elif score_mat[i][0] == 2 and score_mat[i][1] == 1:132 assemble_scores[2][1] += 1 133 elif score_mat[i][0] == 2 and score_mat[i][1] == 2:134 assemble_scores[2][2] += 1 135 elif score_mat[i][0] == 2 and score_mat[i][1] == 3:136 assemble_scores[2][3] += 1 137 elif score_mat[i][0] == 2 and score_mat[i][1] == 4:138 assemble_scores[2][4] += 1139 elif score_mat[i][0] == 3 and score_mat[i][1] == 0:140 assemble_scores[3][0] += 1141 elif score_mat[i][0] == 3 and score_mat[i][1] == 1:142 assemble_scores[3][1] += 1 143 elif score_mat[i][0] == 3 and score_mat[i][1] == 2:144 assemble_scores[3][2] += 1 145 elif score_mat[i][0] == 3 and score_mat[i][1] == 3:146 assemble_scores[3][3] += 1 147 elif score_mat[i][0] == 3 and score_mat[i][1] == 4:148 assemble_scores[3][4] += 1 149 elif score_mat[i][0] == 4 and score_mat[i][1] == 0:150 assemble_scores[4][0] += 1151 elif score_mat[i][0] == 4 and score_mat[i][1] == 1:152 assemble_scores[4][1] += 1 153 elif score_mat[i][0] == 4 and score_mat[i][1] == 2:154 assemble_scores[4][2] += 1 155 elif score_mat[i][0] == 4 and score_mat[i][1] == 3:156 assemble_scores[4][3] += 1 157 elif score_mat[i][0] == 4 and score_mat[i][1] == 4:158 assemble_scores[4][4] += 1 159 160 #calculate percentages and print the score matrix161 print ("**********************************") 162 print ("* *") 163 print ("* SCORE MATRIX (% PROBABILITY) *")164 print ("* *")165 print ("**********************************")166 score_matrix = PrettyTable([" ", 0, 1, 2, 3, 4])167 score_matrix.add_row([0,round(assemble_scores[0][0]/num_simulations*100,2),round(assemble_scores[0][1]/num_simulations*100,2),round(assemble_scores[0][2]/num_simulations*100,2),round(assemble_scores[0][3]/num_simulations*100,2),round(assemble_scores[0][4]/num_simulations*100,2)])168 score_matrix.add_row([1,round(assemble_scores[1][0]/num_simulations*100,2),round(assemble_scores[1][1]/num_simulations*100,2),round(assemble_scores[1][2]/num_simulations*100,2),round(assemble_scores[1][3]/num_simulations*100,2),round(assemble_scores[1][4]/num_simulations*100,2)])169 score_matrix.add_row([2,round(assemble_scores[2][0]/num_simulations*100,2),round(assemble_scores[2][1]/num_simulations*100,2),round(assemble_scores[2][2]/num_simulations*100,2),round(assemble_scores[2][3]/num_simulations*100,2),round(assemble_scores[2][4]/num_simulations*100,2)])170 score_matrix.add_row([3,round(assemble_scores[3][0]/num_simulations*100,2),round(assemble_scores[3][1]/num_simulations*100,2),round(assemble_scores[3][2]/num_simulations*100,2),round(assemble_scores[3][3]/num_simulations*100,2),round(assemble_scores[3][4]/num_simulations*100,2)])171 score_matrix.add_row([4,round(assemble_scores[4][0]/num_simulations*100,2),round(assemble_scores[4][1]/num_simulations*100,2),round(assemble_scores[4][2]/num_simulations*100,2),round(assemble_scores[4][3]/num_simulations*100,2),round(assemble_scores[4][4]/num_simulations*100,2)])172 print(score_matrix) 173 174 #calculate expected Pts and print a summary175 home_xPts = (home_win_probability / 100) * 3.0 + (draw_probability / 100) * 1.0 + (away_win_probability / 100) * 0.0176 away_xPts = (away_win_probability / 100) * 3.0 + (draw_probability / 100) * 1.0 + (home_win_probability / 100) * 0.0177 print ("**********************************") 178 print ("* *") 179 print ("* SUMMARY *")180 print ("* *")181 print ("**********************************")182 print(input_home_team, "win probability %:", home_win_probability, "xPts =", round(home_xPts,2))183 print(input_away_team, "win probability %:", away_win_probability, "xPts =", round(away_xPts,2))184 print("Draw probability %:", draw_probability)185 186elif choice == "csv":187 print ("Reading data from csv file.")188 csv_filename = input("* Add csv filename: ")189 df = pd.read_csv(csv_filename)190 print("**********************************")191 for i in range(0, len(df)):192 print("* Game #", i+1, "*")193 print("* Home team:", df.iloc[i]['Team-H'])194 print("* Away team:", df.iloc[i]['Team-A'])195 print("* Home team xG:", df.iloc[i]['xG-H'])196 print("* Away team xG:", df.iloc[i]['xG-A'])197 input_home_team = df.iloc[i]['Team-H']198 input_home_team_xg = df.iloc[i]['xG-H']199 input_away_team = df.iloc[i]['Team-A']200 input_away_team_xg = df.iloc[i]['xG-A']201 #print the simulation table and run simulations202 print ("********************")203 print ("* *")204 print ("* SIMULATION TABLE *")205 print ("* *")206 print ("********************")207 count_home_wins = 0208 count_home_loss = 0209 count_away_wins = 0210 count_away_loss = 0211 count_draws = 0212 score_mat = []213 tot_sim_time = 0214 sim_table = PrettyTable(["SIMULATION #", "SIMULATION TIME (s)", input_home_team, input_away_team, "HOME WIN", "AWAY WIN", "DRAW", "SCORE MARGIN"])215 for i in range(num_simulations):216 #get simulation start time217 start_time = time.time()218 #run the sim - generate a random Poisson distribution219 target_home_goals_scored = np.random.poisson(input_home_team_xg)220 target_away_goals_scored = np.random.poisson(input_away_team_xg)221 home_win = 0222 away_win = 0223 draw = 0224 margin = 0225 # if more goals for home team => home team wins226 if target_home_goals_scored > target_away_goals_scored:227 count_home_wins += 1228 count_away_loss += 1229 home_win = 1230 margin = target_home_goals_scored - target_away_goals_scored231 # if more goals for away team => away team wins232 elif target_home_goals_scored < target_away_goals_scored:233 count_away_wins += 1234 count_home_loss += 1235 away_win = 1236 margin = target_away_goals_scored - target_home_goals_scored237 elif target_home_goals_scored == target_away_goals_scored:238 draw = 1239 count_draws += 1240 margin = target_away_goals_scored - target_home_goals_scored241 # add score to score matrix242 score_mat.append((target_home_goals_scored, target_away_goals_scored))243 #get end time244 end_time = time.time()245 #add the time to the total simulation time246 tot_sim_time += round((end_time - start_time),5)247 #add the info to the simulation table248 sim_table.add_row([i+1, round((end_time - start_time),5), target_home_goals_scored, target_away_goals_scored, home_win, away_win, draw, margin])249 print(sim_table)250251 # calculate probabilities to win/lose/draw252 home_win_probability = round((count_home_wins/num_simulations * 100),2)253 away_win_probability = round((count_away_wins/num_simulations * 100),2)254 draw_probability = round((count_draws/num_simulations * 100),2)255 256 # print the simulation statistics257 print ("*************")258 print ("* *")259 print ("* SIM STATS *")260 print ("* *")261 print ("*************")262 sim_table_stats = PrettyTable(["Total # of sims", "Total time (s) for sims", "HOME WINS", "AWAY WINS", "DRAWS"])263 sim_table_stats.add_row([num_simulations, round(tot_sim_time,3), count_home_wins, count_away_wins, count_draws])264 sim_table_stats.add_row(["-", "-", str(home_win_probability)+"%", str(away_win_probability)+"%", str(draw_probability)+"%"])265 print(sim_table_stats)266 267 # get the score matrix268 total_scores = len(score_mat)269 max_score = 5270 assemble_scores = [[0 for x in range(max_score)] for y in range(max_score)]271 for i in range(total_scores):272 if score_mat[i][0] == 0 and score_mat[i][1] == 0:273 assemble_scores[0][0] += 1274 elif score_mat[i][0] == 0 and score_mat[i][1] == 1:275 assemble_scores[0][1] += 1276 elif score_mat[i][0] == 0 and score_mat[i][1] == 2:277 assemble_scores[0][2] += 1 278 elif score_mat[i][0] == 0 and score_mat[i][1] == 3:279 assemble_scores[0][3] += 1 280 elif score_mat[i][0] == 0 and score_mat[i][1] == 4:281 assemble_scores[0][4] += 1 282 elif score_mat[i][0] == 1 and score_mat[i][1] == 0:283 assemble_scores[1][0] += 1284 elif score_mat[i][0] == 1 and score_mat[i][1] == 1:285 assemble_scores[1][1] += 1 286 elif score_mat[i][0] == 1 and score_mat[i][1] == 2:287 assemble_scores[1][2] += 1 288 elif score_mat[i][0] == 1 and score_mat[i][1] == 3:289 assemble_scores[1][3] += 1 290 elif score_mat[i][0] == 1 and score_mat[i][1] == 4:291 assemble_scores[1][4] += 1292 elif score_mat[i][0] == 2 and score_mat[i][1] == 0:293 assemble_scores[2][0] += 1294 elif score_mat[i][0] == 2 and score_mat[i][1] == 1:295 assemble_scores[2][1] += 1 296 elif score_mat[i][0] == 2 and score_mat[i][1] == 2:297 assemble_scores[2][2] += 1 298 elif score_mat[i][0] == 2 and score_mat[i][1] == 3:299 assemble_scores[2][3] += 1 300 elif score_mat[i][0] == 2 and score_mat[i][1] == 4:301 assemble_scores[2][4] += 1302 elif score_mat[i][0] == 3 and score_mat[i][1] == 0:303 assemble_scores[3][0] += 1304 elif score_mat[i][0] == 3 and score_mat[i][1] == 1:305 assemble_scores[3][1] += 1 306 elif score_mat[i][0] == 3 and score_mat[i][1] == 2:307 assemble_scores[3][2] += 1 308 elif score_mat[i][0] == 3 and score_mat[i][1] == 3:309 assemble_scores[3][3] += 1 310 elif score_mat[i][0] == 3 and score_mat[i][1] == 4:311 assemble_scores[3][4] += 1 312 elif score_mat[i][0] == 4 and score_mat[i][1] == 0:313 assemble_scores[4][0] += 1314 elif score_mat[i][0] == 4 and score_mat[i][1] == 1:315 assemble_scores[4][1] += 1 316 elif score_mat[i][0] == 4 and score_mat[i][1] == 2:317 assemble_scores[4][2] += 1 318 elif score_mat[i][0] == 4 and score_mat[i][1] == 3:319 assemble_scores[4][3] += 1 320 elif score_mat[i][0] == 4 and score_mat[i][1] == 4:321 assemble_scores[4][4] += 1 322 323 #calculate percentages and print the score matrix324 print ("**********************************") 325 print ("* *") 326 print ("* SCORE MATRIX (% PROBABILITY) *")327 print ("* *")328 print ("**********************************")329 score_matrix = PrettyTable([" ", 0, 1, 2, 3, 4])330 score_matrix.add_row([0,round(assemble_scores[0][0]/num_simulations*100,2),round(assemble_scores[0][1]/num_simulations*100,2),round(assemble_scores[0][2]/num_simulations*100,2),round(assemble_scores[0][3]/num_simulations*100,2),round(assemble_scores[0][4]/num_simulations*100,2)])331 score_matrix.add_row([1,round(assemble_scores[1][0]/num_simulations*100,2),round(assemble_scores[1][1]/num_simulations*100,2),round(assemble_scores[1][2]/num_simulations*100,2),round(assemble_scores[1][3]/num_simulations*100,2),round(assemble_scores[1][4]/num_simulations*100,2)])332 score_matrix.add_row([2,round(assemble_scores[2][0]/num_simulations*100,2),round(assemble_scores[2][1]/num_simulations*100,2),round(assemble_scores[2][2]/num_simulations*100,2),round(assemble_scores[2][3]/num_simulations*100,2),round(assemble_scores[2][4]/num_simulations*100,2)])333 score_matrix.add_row([3,round(assemble_scores[3][0]/num_simulations*100,2),round(assemble_scores[3][1]/num_simulations*100,2),round(assemble_scores[3][2]/num_simulations*100,2),round(assemble_scores[3][3]/num_simulations*100,2),round(assemble_scores[3][4]/num_simulations*100,2)])334 score_matrix.add_row([4,round(assemble_scores[4][0]/num_simulations*100,2),round(assemble_scores[4][1]/num_simulations*100,2),round(assemble_scores[4][2]/num_simulations*100,2),round(assemble_scores[4][3]/num_simulations*100,2),round(assemble_scores[4][4]/num_simulations*100,2)])335 print(score_matrix) 336 337 #calculate expected Pts and print a summary338 home_xPts = (home_win_probability / 100) * 3.0 + (draw_probability / 100) * 1.0 + (away_win_probability / 100) * 0.0339 away_xPts = (away_win_probability / 100) * 3.0 + (draw_probability / 100) * 1.0 + (home_win_probability / 100) * 0.0340 print ("**********************************") 341 print ("* *") 342 print ("* SUMMARY *")343 print ("* *")344 print ("**********************************")345 print(input_home_team, "win probability %:", home_win_probability, "xPts =", round(home_xPts,2))346 print(input_away_team, "win probability %:", away_win_probability, "xPts =", round(away_xPts,2))347 print("Draw probability %:", draw_probability)348 print("**********************************")349 result_tuple_csv = (input_home_team, round(home_win_probability,2), round(home_xPts,2), input_away_team, round(away_win_probability,2), round(away_xPts,2), "\n")350 with open("MonteCarloMatchSimResults.csv", "a+") as myfile:351 myfile.write(",".join(map(str, result_tuple_csv)))352else:353 print("Not a valid option. Exiting.")354 sys.exit()355356 ...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1'use strict';2require('mocha');3var assert = require('assert');4var gh = require('./');5describe('parse-github-url', function() {6 it('should get the user:', function() {7 assert.equal(gh(''), null);8 assert.equal(gh('https://github.com/jonschlinkert/micromatch').owner, 'jonschlinkert');9 assert.equal(gh('git@github.com:assemble/verb.git').owner, 'assemble');10 assert.equal(gh('assemble/verb#branch').owner, 'assemble');11 assert.equal(gh('assemble/verb#dev').owner, 'assemble');12 assert.equal(gh('assemble/verb').owner, 'assemble');13 assert.equal(gh('git+https://github.com/assemble/verb.git').owner, 'assemble');14 assert.equal(gh('git+ssh://github.com/assemble/verb.git').owner, 'assemble');15 assert.equal(gh('git://gh.pages.com/assemble/verb.git').owner, 'assemble');16 assert.equal(gh('git://github.com/assemble/verb').owner, 'assemble');17 assert.equal(gh('git://github.com/assemble/verb.git').owner, 'assemble');18 assert.equal(gh('git://github.com/foo/bar.git').owner, 'foo');19 assert.equal(gh('git://github.one.com/assemble/verb.git').owner, 'assemble');20 assert.equal(gh('git://github.one.two.com/assemble/verb.git').owner, 'assemble');21 assert.equal(gh('git@gh.pages.com:assemble/verb.git').owner, 'assemble');22 assert.equal(gh('git@gist.github.com:9284722.git'), null);23 assert.equal(gh('git@github.com:assemble/verb.git#0.6.0').owner, 'assemble');24 assert.equal(gh('git@github.com:assemble/verb.git#v0.6.0').owner, 'assemble');25 assert.equal(gh('git@github.com:assemble/verb.git').owner, 'assemble');26 assert.equal(gh('github:user/repo').owner, 'user');27 assert.equal(gh('http://github.com/assemble/verb').owner, 'assemble');28 assert.equal(gh('http://github.com/assemble/verb.git').owner, 'assemble');29 assert.equal(gh('http://github.com/assemble/verb/tree').owner, 'assemble');30 assert.equal(gh('http://github.com/assemble/verb/tree/master').owner, 'assemble');31 assert.equal(gh('http://github.com/assemble/verb/tree/master/foo/bar').owner, 'assemble');32 assert.equal(gh('https://assemble@github.com/assemble/verb.git').owner, 'assemble');33 assert.equal(gh('https://foo.github.com/assemble/verb/bar.tar.gz').owner, 'assemble');34 assert.equal(gh('https://foo.github.com/assemble/verb/bar.zip').owner, 'assemble');35 assert.equal(gh('https://gh.pages.com/assemble/verb.git').owner, 'assemble');36 assert.equal(gh('https://gist.github.com/9284722.git'), null);37 assert.equal(gh('https://github.com/assemble/verb').owner, 'assemble');38 assert.equal(gh('https://github.com/assemble/verb.git').owner, 'assemble');39 assert.equal(gh('https://github.com/assemble/verb/blob/249b21a86400b38969cee3d5df6d2edf8813c137/README.md').owner, 'assemble');40 assert.equal(gh('https://github.com/assemble/verb/blob/master/assemble/index.js').owner, 'assemble');41 assert.equal(gh('https://github.com/assemble/verb/blob/master/foo/index.js').owner, 'assemble');42 assert.equal(gh('https://github.com/assemble/verb/blob/v1.0.0/README.md').owner, 'assemble');43 assert.equal(gh('https://github.com/assemble/verb/tree/0.2.0').owner, 'assemble');44 assert.equal(gh('https://github.com/assemble/verb/tree/dev').owner, 'assemble');45 assert.equal(gh('https://github.com/assemble/verb/tree/feature/dev').owner, 'assemble');46 assert.equal(gh('https://github.com/repos/assemble/verb/tarball').owner, 'assemble');47 assert.equal(gh('https://github.com/repos/assemble/verb/zipball').owner, 'assemble');48 assert.equal(gh('foo:bar'), null);49 assert.equal(gh(), null);50 assert.equal(gh(null), null);51 assert.equal(gh(undefined), null);52 });53 it('should get the branch:', function() {54 assert.equal(gh('assemble/verb#branch').branch, 'branch');55 assert.equal(gh('assemble/verb#dev').branch, 'dev');56 assert.equal(gh('git@github.com:assemble/verb.git#0.6.0').branch, '0.6.0');57 assert.equal(gh('git@github.com:assemble/verb.git#v0.6.0').branch, 'v0.6.0');58 assert.equal(gh('https://github.com/assemble/verb/blob/foo/README.md').branch, 'foo');59 assert.equal(gh('https://github.com/assemble/verb/tree/dev').branch, 'dev');60 assert.equal(gh('https://github.com/assemble/verb/tree/feature/dev').branch, 'feature');61 assert.equal(gh('https://github.com/assemble/verb/tree/foo').branch, 'foo');62 assert.equal(gh('https://raw.githubusercontent.com/assemble/verb/dev').branch, 'dev');63 assert.equal(gh('https://raw.githubusercontent.com/assemble/verb/4d0ebde055557a0d1d988c01e0f070df8cc8fa07').branch, '4d0ebde055557a0d1d988c01e0f070df8cc8fa07');64 assert.equal(gh('https://raw.githubusercontent.com/assemble/verb/4d0ebde055557a0d1d988c01e0f070df8cc8fa07/README.md').branch, '4d0ebde055557a0d1d988c01e0f070df8cc8fa07');65 assert.equal(gh('https://raw.githubusercontent.com/assemble/verb/dev/README.md').branch, 'dev');66 });67 it('should get the filepath:', function() {68 assert.equal(gh('assemble/verb#branch').filepath, null);69 assert.equal(gh('git@github.com:assemble/verb.git#0.6.0').filepath, null);70 assert.equal(gh('https://github.com/assemble/verb/blob/foo/README.md').filepath, 'README.md');71 assert.equal(gh('https://github.com/assemble/verb/blob/foo/').filepath, null);72 assert.equal(gh('https://github.com/assemble/verb/blob/foo').filepath, null);73 assert.equal(gh('https://github.com/assemble/verb/blob/foo/bar/README.md').filepath, 'bar/README.md');74 assert.equal(gh('https://github.com/assemble/verb/tree/dev').filepath, null);75 assert.equal(gh('https://raw.githubusercontent.com/assemble/verb/dev/README.md').filepath, 'README.md');76 assert.equal(gh('https://raw.githubusercontent.com/assemble/verb/dev/bar/README.md').filepath, 'bar/README.md');77 });78 it('should use master branch when another branch is not defined:', function() {79 assert.equal(gh('assemble/verb').branch, 'master');80 assert.equal(gh('git://github.com/foo/bar.git').branch, 'master');81 assert.equal(gh('git@github.com:assemble/verb.git').branch, 'master');82 assert.equal(gh('github:assemble/verb').branch, 'master');83 assert.equal(gh('http://github.com/assemble/verb/tree/master').branch, 'master');84 assert.equal(gh('http://github.com/assemble/verb/tree/master/foo/bar').branch, 'master');85 assert.equal(gh('https://github.com/assemble/verb').branch, 'master');86 assert.equal(gh('https://raw.githubusercontent.com/assemble/verb').branch, 'master');87 assert.equal(gh('https://github.com/assemble/verb/blob/master/foo/index.js').branch, 'master');88 });89 it('should get a full repo path:', function() {90 assert.equal(gh('assemble/verb#dev').repo, 'assemble/verb');91 assert.equal(gh('assemble/verb').repo, 'assemble/verb');92 assert.equal(gh('git+https://github.com/assemble/verb.git').repo, 'assemble/verb');93 assert.equal(gh('git+ssh://github.com/assemble/verb.git').repo, 'assemble/verb');94 assert.equal(gh('git://github.com/assemble/verb').repo, 'assemble/verb');95 assert.equal(gh('git://github.com/assemble/verb.git').repo, 'assemble/verb');96 assert.equal(gh('git://github.one.com/assemble/verb.git').repo, 'assemble/verb');97 assert.equal(gh('git://github.one.two.com/assemble/verb.git').repo, 'assemble/verb');98 });99 it('should know when repo is not defined:', function() {100 assert.equal(gh('git+https://github.com/assemble').name, null);101 assert.equal(gh('git+https://github.com/assemble').repo, null);102 assert.equal(gh('git+https://github.com/assemble').owner, 'assemble');103 assert.equal(gh('git+ssh://github.com/assemble').name, null);104 assert.equal(gh('git+ssh://github.com/assemble').repo, null);105 assert.equal(gh('git+ssh://github.com/assemble').owner, 'assemble');106 assert.equal(gh('git://github.com/assemble').name, null);107 assert.equal(gh('git://github.com/assemble').repo, null);108 assert.equal(gh('git://github.com/assemble').owner, 'assemble');109 assert.equal(gh('git://github.one.com/assemble').name, null);110 assert.equal(gh('git://github.one.com/assemble').repo, null);111 assert.equal(gh('git://github.one.com/assemble').owner, 'assemble');112 assert.equal(gh('git://github.one.two.com/assemble').name, null);113 assert.equal(gh('git://github.one.two.com/assemble').repo, null);114 assert.equal(gh('git://github.one.two.com/assemble').owner, 'assemble');115 assert.equal(gh('http://github.com/assemble').name, null);116 assert.equal(gh('http://github.com/assemble').repo, null);117 assert.equal(gh('http://github.com/assemble').repo, null);118 assert.equal(gh('http://github.com/assemble').owner, 'assemble');119 assert.equal(gh('https://github.com').name, null);120 assert.equal(gh('https://github.com').repo, null);121 assert.equal(gh('http://github.com/assemble').owner, 'assemble');122 assert.equal(gh('https://github.com').owner, null);123 });124 it('should get the repo:', function() {125 assert.equal(gh('assemble/verb#branch').name, 'verb');126 assert.equal(gh('assemble/dot.repo#branch').name, 'dot.repo');127 assert.equal(gh('assemble/verb#dev').name, 'verb');128 assert.equal(gh('assemble/dot.repo#dev').name, 'dot.repo');129 assert.equal(gh('assemble/verb').name, 'verb');130 assert.equal(gh('assemble/dot.repo').name, 'dot.repo');131 assert.equal(gh('git+https://github.com/assemble/verb.git').name, 'verb');132 assert.equal(gh('git+https://github.com/assemble/dot.repo.git').name, 'dot.repo');133 assert.equal(gh('git+ssh://github.com/assemble/verb.git').name, 'verb');134 assert.equal(gh('git+ssh://github.com/assemble/dot.repo.git').name, 'dot.repo');135 assert.equal(gh('git://gh.pages.com/assemble/verb.git').name, 'verb');136 assert.equal(gh('git://gh.pages.com/assemble/dot.repo.git').name, 'dot.repo');137 assert.equal(gh('git://github.com/assemble/verb').name, 'verb');138 assert.equal(gh('git://github.com/assemble/dot.repo').name, 'dot.repo');139 assert.equal(gh('git://github.com/assemble/verb.git').name, 'verb');140 assert.equal(gh('git://github.com/assemble/dot.repo.git').name, 'dot.repo');141 assert.equal(gh('git://github.com/foo/bar.git').name, 'bar');142 assert.equal(gh('git://github.com/foo/dot.repo.git').name, 'dot.repo');143 assert.equal(gh('git://github.one.com/assemble/verb.git').name, 'verb');144 assert.equal(gh('git://github.one.com/assemble/dot.repo.git').name, 'dot.repo');145 assert.equal(gh('git://github.one.two.com/assemble/verb.git').name, 'verb');146 assert.equal(gh('git://github.one.two.com/assemble/dot.repo.git').name, 'dot.repo');147 assert.equal(gh('git@gh.pages.com:assemble/verb.git').name, 'verb');148 assert.equal(gh('git@gh.pages.com:assemble/dot.repo.git').name, 'dot.repo');149 assert.equal(gh('git@github.com:assemble/verb.git#0.6.0').name, 'verb');150 assert.equal(gh('git@github.com:assemble/dot.repo.git#0.6.0').name, 'dot.repo');151 assert.equal(gh('git@github.com:assemble/verb.git#v0.6.0').name, 'verb');152 assert.equal(gh('git@github.com:assemble/dot.repo.git#v0.6.0').name, 'dot.repo');153 assert.equal(gh('git@github.com:assemble/verb.git').name, 'verb');154 assert.equal(gh('git@github.com:assemble/dot.repo.git').name, 'dot.repo');155 assert.equal(gh('github:assemble/verb').name, 'verb');156 assert.equal(gh('github:assemble/dot.repo').name, 'dot.repo');157 assert.equal(gh('http://github.com/assemble/verb').name, 'verb');158 assert.equal(gh('http://github.com/assemble/dot.repo').name, 'dot.repo');159 assert.equal(gh('http://github.com/assemble/verb.git').name, 'verb');160 assert.equal(gh('http://github.com/assemble/dot.repo.git').name, 'dot.repo');161 assert.equal(gh('http://github.com/assemble/verb/tree').name, 'verb');162 assert.equal(gh('http://github.com/assemble/dot.repo/tree').name, 'dot.repo');163 assert.equal(gh('http://github.com/assemble/verb/tree/master').name, 'verb');164 assert.equal(gh('http://github.com/assemble/dot.repo/tree/master').name, 'dot.repo');165 assert.equal(gh('http://github.com/assemble/verb/tree/master/foo/dev').name, 'verb');166 assert.equal(gh('http://github.com/assemble/dot.repo/tree/master/foo/dev').name, 'dot.repo');167 assert.equal(gh('https://assemble.github.io/assemble/verb/dev.tar.gz').name, 'verb');168 assert.equal(gh('https://assemble.github.io/assemble/dot.repo/dev.tar.gz').name, 'dot.repo');169 assert.equal(gh('https://assemble.github.io/assemble/verb/dev.zip').name, 'verb');170 assert.equal(gh('https://assemble.github.io/assemble/dot.repo/dev.zip').name, 'dot.repo');171 assert.equal(gh('https://assemble@github.com/assemble/verb.git').name, 'verb');172 assert.equal(gh('https://assemble@github.com/assemble/dot.repo.git').name, 'dot.repo');173 assert.equal(gh('https://gh.pages.com/assemble/verb.git').name, 'verb');174 assert.equal(gh('https://gh.pages.com/assemble/dot.repo.git').name, 'dot.repo');175 assert.equal(gh('https://github.com/assemble/verb').name, 'verb');176 assert.equal(gh('https://github.com/assemble/dot.repo').name, 'dot.repo');177 assert.equal(gh('https://github.com/assemble/verb.git').name, 'verb');178 assert.equal(gh('https://github.com/assemble/dot.repo.git').name, 'dot.repo');179 assert.equal(gh('https://github.com/assemble/verb/blob/249b21a86400b38969cee3d5df6d2edf8813c137/README.md').name, 'verb');180 assert.equal(gh('https://github.com/assemble/dot.repo/blob/249b21a86400b38969cee3d5df6d2edf8813c137/README.md').name, 'dot.repo');181 assert.equal(gh('https://github.com/assemble/verb/blob/master/foo/index.js').name, 'verb');182 assert.equal(gh('https://github.com/assemble/dot.repo/blob/master/foo/index.js').name, 'dot.repo');183 assert.equal(gh('https://github.com/repos/assemble/verb/tarball').name, 'verb');184 assert.equal(gh('https://github.com/repos/assemble/dot.repo/tarball').name, 'dot.repo');185 assert.equal(gh('https://github.com/repos/assemble/verb/zipball').name, 'verb');186 assert.equal(gh('https://github.com/repos/assemble/dot.repo/zipball').name, 'dot.repo');187 });188 it('should get the host:', function() {189 assert.equal(gh('git+https://github.com/assemble/verb.git').host, 'github.com');190 assert.equal(gh('git+ssh://github.com/assemble/verb.git').host, 'github.com');191 assert.equal(gh('git://github.com/assemble/verb').host, 'github.com');192 assert.equal(gh('git://github.com/assemble/verb.git').host, 'github.com');193 assert.equal(gh('git://github.one.com/assemble/verb.git').host, 'github.one.com');194 assert.equal(gh('git://github.one.two.com/assemble/verb.git').host, 'github.one.two.com');195 assert.equal(gh('https://github.com/assemble/verb').host, 'github.com');196 assert.equal(gh('https://github.one.com/assemble/verb').host, 'github.one.com');197 assert.equal(gh('https://github.one.two.com/assemble/verb').host, 'github.one.two.com');198 assert.equal(gh('git@gh.pages.com:assemble/verb.git').host, 'gh.pages.com');199 assert.equal(gh('git@gh.pages.com:assemble/dot.repo.git').host, 'gh.pages.com');200 assert.equal(gh('git@bitbucket.org:atlassian/atlaskit.git').host, 'bitbucket.org');201 assert.equal(gh('git@gitlab.com:gitlab-org/gitlab-ce.git').host, 'gitlab.com');202 });203 it('should assume github.com is the host when not provided:', function() {204 assert.equal(gh('assemble/verb').host, 'github.com');205 });...

Full Screen

Full Screen

assemble.js

Source:assemble.js Github

copy

Full Screen

1var fixup_kinds = require ( './fixup_kinds.js' );2var lookup = require ( './lookup.js' );3var misc = require ( './misc.js' );4var string_map = require ( './string_map.js' );5var root = {6 setupScopes: function setupScopes ( scopes ) {7 var statement_text_table = string_map.make ( {8 '=': assemble_assignment,9 'while': assemble_while,10 'return': assemble_return,11 '(': assemble_paren,12 } );13 statement_text_table.each ( function ( key, val ) {14 // Add the assemble method to the object prototypes.15 scopes.get ( 'statement' ).field_text ( key, 'assemble', val );16 } );17 var statement_type_table = string_map.make ( {18 'block': assemble_block,19 } );20 statement_type_table.each ( function ( key, val ) {21 // Add the assemble method to the object prototypes.22 scopes.get ( 'statement' ).field_type ( key, 'assemble', val );23 } );24 var expression_type_table = string_map.make ( {25 'number': assemble_number,26 'identifier': assemble_identifier,27 } );28 expression_type_table.each ( function ( key, val ) {29 // Add the assemble method to the object prototypes.30 scopes.get ( 'expression' ).field_type ( key, 'assemble', val );31 } );32 var expression_text_table = string_map.make ( {33 '!=' : infix ( [ 'eq', 'not' ] ),34 '==' : infix ( [ 'eq' ] ),35 '+' : infix ( [ 'fadd' ] ),36 // Can't use infix since - is also a prefix operator.37 '-' : assemble_sub,38 '*' : infix ( [ 'fmul' ] ),39 '/' : infix ( [ 'fdiv' ] ),40 '%' : infix ( [ 'fmod' ] ),41 'not' : prefix ( [ 'not' ] ),42 '(': assemble_paren,43 'fn': assemble_fn,44 'if': assemble_if,45 } );46 expression_text_table.each ( function ( key, val ) {47 // Add the assemble method to the object prototypes.48 scopes.get ( 'expression' ).field_text ( key, 'assemble', val );49 } );50 },51 assemble_objs : function assemble_objs ( objs ) {52 // THe main function of this module.53 var emitter = this.emitter;54 objs.forEach ( function ( obj ) {55 assemble ( obj, emitter );56 } );57 }58 };59function make ( emitter ) {60 return misc.obj_or ( {61 emitter : emitter,62 }, root );63 }64function assemble ( node, emitter ) {65 if ( typeof emitter !== 'object' ) {66 throw 'Assembler should be an object!';67 }68 if ( node.assemble !== undefined ) {69 node.assemble ( emitter );70 }71 else {72 misc.print ( node );73 throw 'Could not assemble node ' + node.text + '!';74 }75 }76function assemble_assignment ( emitter ) {77 if ( emitter.has_var ( this.left.text ) ) {78 assemble ( this.right, emitter );79 emitter.emit_cmd ( 'set_1', [ this.left.text ] );80 }81 else {82 assemble ( this.right, emitter );83 emitter.emit_result ( [ this.left.text ] );84 }85 }86function assemble_number ( emitter ) {87 return emitter.emit_li ( 'float', parseFloat ( this.text ) );88 }89function assemble_block ( emitter ) {90 var block = emitter.begin_block ( );91 this.children.forEach ( function ( child ) {92 assemble ( child, emitter );93 } );94 emitter.end_block ( block );95 }96function infix ( opseq ) {97 return function assemble_infix ( emitter ) {98 var left = assemble ( this.left, emitter );99 var right = assemble ( this.right, emitter );100 opseq.forEach ( function ( op ) {101 emitter.emit_cmd ( op );102 } );103 };104 }105function prefix ( postseq, prefunc ) {106 return function assemble ( emitter ) {107 if ( prefunc === undefined ) {108 prefunc ( emitter );109 }110 assemble ( this.right, emitter );111 postseq.forEach ( function ( op ) {112 emitter.emit_cmd ( op );113 } );114 };115 }116function assemble_sub ( emitter ) {117 // TODO(kzentner): Generalize this for all mixed prefix / infix operators.118 function load_0 ( emitter ) {119 emitter.emit_li ( 'float', 0 );120 }121 if ( this.left === undefined ) {122 return prefix ( [ 'fsub' ], load_0 ).apply ( this, [ emitter ] );123 }124 else {125 return infix ( [ 'fsub' ] ).apply ( this, [ emitter ] );126 }127 }128function assemble_while ( emitter ) {129 var start = emitter.emit_label ( );130 assemble ( this.condition, emitter );131 var end = emitter.reserve_label ( );132 emitter.emit_bz ( end );133 assemble ( this.block, emitter );134 emitter.emit_j ( start );135 emitter.emit_label ( end );136 }137function assemble_if ( emitter ) {138 assemble ( this.condition, emitter );139 var end = emitter.reserve_label ( );140 emitter.emit_bz ( end );141 assemble ( this.block, emitter );142 emitter.emit_label ( end );143 // TODO(kzentner): Add support for else blocks.144 }145function get_fixup_kind ( value ) {146 if ( value.text === 'fn' ) {147 return fixup_kinds.vm_func;148 }149 else {150 throw 'Could not determine fixup_kind of node!';151 }152 }153function assemble_identifier ( emitter ) {154 if ( this.variable === undefined ||155 this.variable.location === undefined ) {156 throw 'Cannot assemble un-analyzed variable ' + this.text;157 }158 var loc = this.variable.location;159 var value;160 var name;161 var fixup_kind;162 var id;163 if ( loc === 'stack' ) {164 // If this is a local variable, a later compiler pass will actually expand165 // the stack address of the variable.166 emitter.emit_cmd ( 'dup_1', [ this.text ] );167 }168 else if ( loc === 'global' ) {169 value = this.variable.canonical_value;170 name = value.canonical_name;171 fixup_kind = get_fixup_kind ( value );172 id = value.object_id;173 emitter.emit_li ( 'lookup',174 lookup.make ( name, fixup_kind, id ) );175 }176 else if ( loc === 'external' ) {177 value = this.variable.canonical_value;178 name = value.name;179 fixup_kind = fixup_kinds.external;180 id = value.object_id;181 emitter.emit_li ( 'lookup',182 lookup.make ( name, fixup_kind, id ) );183 }184 else {185 throw 'Could not find location of variable ' + this.text + '.';186 }187 }188function assemble_paren ( emitter ) {189 // Could be a function call.190 if ( this.type === 'call' ) {191 assemble ( this.func, emitter );192 this.args.forEach ( function ( arg ) {193 assemble ( arg, emitter );194 } );195 emitter.emit_cmd ( 'call_1', [ this.args.length ] );196 if ( this.ctxt === 'statement' ) {197 // Remove the function's return value from the stack, since it won't be needed.198 emitter.emit_cmd ( 'pop' );199 }200 }201 else {202 // TODO(kzentner): Make other uses of parentheses work.203 throw 'Parentheses besides function calls not currently supported.';204 }205 }206function assemble_return ( emitter ) {207 assemble ( this.expr, emitter );208 emitter.emit_cmd ( 'ret' );209 }210// Function call stack interface:211// First, push the function.212// Then, push all the arguments from left to right.213// The call stack should look like:214// [ ..., func, arg0, arg1, ..., argk ]215// Then, perform the call opcode, with a single arg, the number of function216// arguments being used. The call opcode is responsible for removing the217// function from the stack, adding the return address to the call stack,218// growing the stack if necessary, and jumping into the function's code body.219//220// Note that the call opcode is also responsible for determining if the221// function on the top of the stack is an external function, in which case it222// passes the arguments from the stack to the external function.223// If this is in javascript, that involves using apply.224function assemble_fn ( emitter ) {225 emitter.begin_obj ( this.canonical_name, this.object_id );226 this.args.forEach ( function ( arg ) {227 emitter.add_var ( arg.text );228 } );229 assemble ( this.body, emitter );230 // TODO(kzentner): Is this the right place to put this logic?231 if ( this.canonical_name === 'main' ) {232 emitter.emit_cmd ( 'end' );233 }234 else {235 emitter.emit_cmd ( 'ret' );236 }237 emitter.end_obj ( );238 }...

Full Screen

Full Screen

run_result_assembly.py

Source:run_result_assembly.py Github

copy

Full Screen

...38 to_assemble_list.append(line.strip())39 return to_assemble_list40 def _create_result_list(self, to_assemble_list):41 pass42 def assemble(self):43 """44 Main file assembly logic45 """46 to_assemble_list = self.create_assembly_file_list(self.to_assemble_input)47 self._assert(to_assemble_list)48 results = self._create_result_list(to_assemble_list)49 combined_result = Result.combine_result(results)50 return combined_result51 def _assert(self, to_assemble_list):52 """53 Perform necessary assertions before parsing any of the files.54 """55 # check that the number of files is greater than 056 assert len(to_assemble_list) > 057 # check that the file formats match58 assemble_format_list = [os.path.splitext(f)[1].split(".")[1] for f in to_assemble_list]59 assert len(set(assemble_format_list)) == 1, "The file formats for assembly do not much."60 # check that the file format is supported for assembly61 assert assemble_format_list[0] in self.SUPPORTED_FILE_TYPES, \62 "The assembly format is not consistent, use any of {fmts}".format(fmts=str(self.SUPPORTED_FILE_TYPES))63class XmlAssembler(FileAssembler):64 @staticmethod65 def _parse_files(to_assemble_list):66 to_assemble_xml_strings = []67 for to_assemble_xml in to_assemble_list:68 with open(to_assemble_xml, 'r') as f:69 to_assemble_xml_strings.append(f.read())70 return to_assemble_xml_strings71 def _create_result_list(self, to_assemble_list):72 to_assemble_xml_strings = self._parse_files(to_assemble_list)73 results = []74 for to_assemble_xml_string in to_assemble_xml_strings:75 results.append(Result.from_xml(to_assemble_xml_string))76 return results77class JsonAssembler(FileAssembler):78 @staticmethod79 def _parse_files(to_assemble_list):80 to_assemble_json_strings = []81 for json_file in to_assemble_list:82 with open(json_file, 'r') as f:83 to_assemble_json_strings.append(json.load(f))84 return to_assemble_json_strings85 def _create_result_list(self, to_assemble_list):86 to_assemble_jsons = self._parse_files(to_assemble_list)87 results = []88 for to_assemble_json in to_assemble_jsons:89 to_assemble_json_string = json.dumps(to_assemble_json)90 results.append(Result.from_json(to_assemble_json_string))91 return results92def main():93 if len(sys.argv) != 2:94 print_usage()95 return 296 files_to_assemble_list = sys.argv[1]97 desired_file_list = FileAssembler.create_assembly_file_list(files_to_assemble_list)98 if ".xml" in desired_file_list[0]:99 xml_output = XmlAssembler(files_to_assemble_list).assemble().to_xml()100 print(xml_output)101 elif ".json" in desired_file_list[0]:102 json_output = JsonAssembler(files_to_assemble_list).assemble().to_json()103 print(json_output)104 else:105 print_usage()106 return 2107if __name__ == "__main__":108 ret = main()...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('test id: %s', data.data.testId);5 test.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8 });9});10The MIT License (MIT)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org');3var options = {4};5api.runTest(options, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log('Test status:', data.statusCode);10 console.log('Test ID:', data.data.testId);11 console.log('Test URL:', data.data.summary);12 }13});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('webpagetest');2const wptClient = wpt('www.webpagetest.org');3 lighthouseConfig: {4 settings: {5 }6 }7}, (err, data) => {8 if (err) {9 console.error(err);10 } else {11 console.log(data);12 }13});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var path = require('path');4var config = require('./config.json');5var _ = require('lodash');6var async = require('async');7var request = require('request');8var cheerio = require('cheerio');9var natural = require('natural');10var tokenizer = new natural.WordTokenizer();11var stopwords = require('./stopwords.json');12var stemmer = natural.PorterStemmer;13var stemmer2 = natural.LancasterStemmer;14var stemmer3 = natural.PorterStemmerRu;15var stemmer4 = natural.PorterStemmerEs;16var stemmer5 = natural.PorterStemmerIt;17var stemmer6 = natural.PorterStemmerNo;18var stemmer7 = natural.PorterStemmerPt;19var stemmer8 = natural.PorterStemmerFi;20var stemmer9 = natural.PorterStemmerNl;21var stemmer10 = natural.PorterStemmerDa;22var stemmer11 = natural.PorterStemmerHu;23var stemmer12 = natural.PorterStemmerNb;24var stemmer13 = natural.PorterStemmerSv;25var stemmer14 = natural.PorterStemmerRo;26var stemmer15 = natural.PorterStemmerFr;27var stemmer16 = natural.PorterStemmerLt;28var stemmer17 = natural.PorterStemmerPl;29var stemmer18 = natural.PorterStemmerTr;30var stemmer19 = natural.PorterStemmerCs;31var stemmer20 = natural.PorterStemmerSk;32var stemmer21 = natural.PorterStemmerBg;33var stemmer22 = natural.PorterStemmerEl;34var stemmer23 = natural.PorterStemmerEt;35var stemmer24 = natural.PorterStemmerLv;36var stemmer25 = natural.PorterStemmerMk;37var stemmer26 = natural.PorterStemmerSl;38var stemmer27 = natural.PorterStemmerSrl;39var stemmer28 = natural.PorterStemmerSr;40var stemmer29 = natural.PorterStemmerLt;41var stemmer30 = natural.PorterStemmerLv;42var stemmer31 = natural.PorterStemmerMk;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var test = new wpt(options);5var params = {6};7test.runTest(url, params, function(err, data) {8 if (err) return console.error(err);9 console.log('Test started: ' + data.data.testId);10 test.getTestStatus(data.data.testId, function(err, data) {11 if (err) return console.error(err);12 console.log('Test status: ' + data.data.statusText);13 test.getTestResults(data.data.testId, function(err, data) {14 if (err) return console.error(err);15 console.log('Test results: ' + data.data.summary);16 });17 });18});19var wpt = require('webpagetest');20var options = {21};22var test = new wpt(options);23var params = {24};25test.runTest(url, params, function(err, data) {26 if (err) return console.error(err);27 console.log('Test started: ' + data.data.testId);28 test.getTestStatus(data.data.testId, function(err, data) {29 if (err) return console.error(err);30 console.log('Test status: ' + data.data.statusText);31 test.getTestResults(data.data.testId, function(err, data) {32 if (err) return console.error(err);33 console.log('Test results: ' + data.data.summary);34 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.1c0c6e3f6b3d3b3c6a2f2d2c6b2e2d2e');3var location = 'Dulles_MotoG4:Chrome.4G';4var runs = 1;5wpt.runTest(testUrl, { location: location, runs: runs }, function(err, data) {6 if (err) return console.error(err);7 var testId = data.data.testId;8 console.log('Test ID: ' + testId);9 wpt.getTestResults(testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Test results for ' + testId + ':');12 console.log(data.data);13 });14});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.0e8e8a8b1a1c7f0f8f9c8a0b0d9c7f0b');3 if (err) return console.error(err);4 wpt.getTestResults(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 console.log(data.data.median.firstView.SpeedIndex);7 });8});9### new WebPageTest(host, apiKey)10### .runTest(url, options, callback)11#### callback(err, data)12### .getTestResults(testId, callback)13#### callback(err, data)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('A.8b1b0c7d4e4e4b6f4b9d9e4e4b6f4b9d');3test.runTest(url, {4}, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 }10});11var wpt = require('webpagetest');12var test = new wpt('A.8b1b0c7d4e4e4b6f4b9d9e4e4b6f4b9d');13test.status(function(err, data) {14 if (err) {15 console.log(err);16 } else {17 console.log(data);18 }19});20var wpt = require('webpagetest');21var test = new wpt('A.8b1b0c7d4e4e4b6f4b9d9e4e4b6f4b9d');22test.results('150411_3X_3c2a2f2b0a3a0dcd7d6c8d7d1f9e9d7', function(err, data) {23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28});29var wpt = require('webpagetest');30var test = new wpt('A.8b1b0c7d4e4e4b6f4b9d9e4e4b6f4b9d');31test.locations(function(err, data) {32 if (err) {33 console.log(err);34 } else {35 console.log(data);36 }37});

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