How to use before method in qawolf

Best JavaScript code snippet using qawolf

day7_input.py

Source:day7_input.py Github

copy

Full Screen

1test_step = """Step C must be finished before step A can begin.2Step C must be finished before step F can begin.3Step A must be finished before step B can begin.4Step A must be finished before step D can begin.5Step B must be finished before step E can begin.6Step D must be finished before step E can begin.7Step F must be finished before step E can begin."""8real_step = """Step F must be finished before step P can begin.9Step R must be finished before step J can begin.10Step X must be finished before step H can begin.11Step L must be finished before step N can begin.12Step U must be finished before step Z can begin.13Step B must be finished before step C can begin.14Step S must be finished before step C can begin.15Step N must be finished before step Y can begin.16Step I must be finished before step J can begin.17Step H must be finished before step K can begin.18Step G must be finished before step Z can begin.19Step Q must be finished before step V can begin.20Step E must be finished before step P can begin.21Step P must be finished before step W can begin.22Step J must be finished before step D can begin.23Step V must be finished before step W can begin.24Step T must be finished before step D can begin.25Step Z must be finished before step A can begin.26Step K must be finished before step A can begin.27Step Y must be finished before step O can begin.28Step O must be finished before step W can begin.29Step C must be finished before step M can begin.30Step D must be finished before step A can begin.31Step W must be finished before step M can begin.32Step M must be finished before step A can begin.33Step C must be finished before step A can begin.34Step F must be finished before step Z can begin.35Step I must be finished before step A can begin.36Step W must be finished before step A can begin.37Step T must be finished before step C can begin.38Step S must be finished before step K can begin.39Step B must be finished before step J can begin.40Step O must be finished before step A can begin.41Step Q must be finished before step P can begin.42Step G must be finished before step M can begin.43Step R must be finished before step T can begin.44Step B must be finished before step G can begin.45Step J must be finished before step O can begin.46Step X must be finished before step E can begin.47Step X must be finished before step C can begin.48Step H must be finished before step Y can begin.49Step Y must be finished before step A can begin.50Step X must be finished before step W can begin.51Step H must be finished before step A can begin.52Step X must be finished before step A can begin.53Step I must be finished before step M can begin.54Step G must be finished before step J can begin.55Step N must be finished before step G can begin.56Step D must be finished before step M can begin.57Step L must be finished before step D can begin.58Step V must be finished before step T can begin.59Step I must be finished before step Y can begin.60Step S must be finished before step J can begin.61Step K must be finished before step Y can begin.62Step F must be finished before step R can begin.63Step U must be finished before step T can begin.64Step Z must be finished before step M can begin.65Step T must be finished before step Z can begin.66Step B must be finished before step I can begin.67Step E must be finished before step K can begin.68Step N must be finished before step J can begin.69Step X must be finished before step Q can begin.70Step F must be finished before step Y can begin.71Step H must be finished before step P can begin.72Step Z must be finished before step D can begin.73Step V must be finished before step O can begin.74Step E must be finished before step C can begin.75Step V must be finished before step C can begin.76Step P must be finished before step A can begin.77Step B must be finished before step N can begin.78Step S must be finished before step W can begin.79Step P must be finished before step D can begin.80Step L must be finished before step W can begin.81Step D must be finished before step W can begin.82Step K must be finished before step C can begin.83Step L must be finished before step M can begin.84Step R must be finished before step O can begin.85Step F must be finished before step L can begin.86Step R must be finished before step H can begin.87Step K must be finished before step O can begin.88Step T must be finished before step W can begin.89Step R must be finished before step K can begin.90Step C must be finished before step W can begin.91Step N must be finished before step T can begin.92Step R must be finished before step P can begin.93Step E must be finished before step M can begin.94Step G must be finished before step T can begin.95Step U must be finished before step K can begin.96Step Q must be finished before step D can begin.97Step U must be finished before step S can begin.98Step J must be finished before step V can begin.99Step P must be finished before step Y can begin.100Step X must be finished before step Z can begin.101Step U must be finished before step H can begin.102Step H must be finished before step M can begin.103Step I must be finished before step C can begin.104Step V must be finished before step M can begin.105Step N must be finished before step I can begin.106Step B must be finished before step K can begin.107Step R must be finished before step Q can begin.108Step O must be finished before step C can begin."""109step_list = real_step.splitlines()110adjustment = 60111alpha_value = {112 "A": 1 + adjustment,113 "B": 2 + adjustment,114 "C": 3 + adjustment,115 "D": 4 + adjustment,116 "E": 5 + adjustment,117 "F": 6 + adjustment,118 "G": 7 + adjustment,119 "H": 8 + adjustment,120 "I": 9 + adjustment,121 "J": 10 + adjustment,122 "K": 11 + adjustment,123 "L": 12 + adjustment,124 "M": 13 + adjustment,125 "N": 14 + adjustment,126 "O": 15 + adjustment,127 "P": 16 + adjustment,128 "Q": 17 + adjustment,129 "R": 18 + adjustment,130 "S": 19 + adjustment,131 "T": 20 + adjustment,132 "U": 21 + adjustment,133 "V": 22 + adjustment,134 "W": 23 + adjustment,135 "X": 24 + adjustment,136 "Y": 25 + adjustment,137 "Z": 26 + adjustment,...

Full Screen

Full Screen

test_target.py

Source:test_target.py Github

copy

Full Screen

1"""2 weasyprint.tests.test_target3 ----------------------------4 Test the CSS cross references using target-*() functions.5"""6from .testing_utils import FakeHTML, assert_no_logs7@assert_no_logs8def test_target_counter():9 document = FakeHTML(string='''10 <style>11 div:first-child { counter-reset: div }12 div { counter-increment: div }13 #id1::before { content: target-counter('#id4', div) }14 #id2::before { content: 'test ' target-counter('#id1' div) }15 #id3::before { content: target-counter(url(#id4), div, lower-roman) }16 #id4::before { content: target-counter('#id3', div) }17 </style>18 <body>19 <div id="id1"></div>20 <div id="id2"></div>21 <div id="id3"></div>22 <div id="id4"></div>23 ''')24 page, = document.render().pages25 html, = page._page_box.children26 body, = html.children27 div1, div2, div3, div4 = body.children28 before = div1.children[0].children[0].children[0]29 assert before.text == '4'30 before = div2.children[0].children[0].children[0]31 assert before.text == 'test 1'32 before = div3.children[0].children[0].children[0]33 assert before.text == 'iv'34 before = div4.children[0].children[0].children[0]35 assert before.text == '3'36@assert_no_logs37def test_target_counter_attr():38 document = FakeHTML(string='''39 <style>40 div:first-child { counter-reset: div }41 div { counter-increment: div }42 div::before { content: target-counter(attr(data-count), div) }43 #id2::before { content: target-counter(attr(data-count, url), div) }44 #id4::before {45 content: target-counter(attr(data-count), div, lower-alpha) }46 </style>47 <body>48 <div id="id1" data-count="#id4"></div>49 <div id="id2" data-count="#id1"></div>50 <div id="id3" data-count="#id2"></div>51 <div id="id4" data-count="#id3"></div>52 ''')53 page, = document.render().pages54 html, = page._page_box.children55 body, = html.children56 div1, div2, div3, div4 = body.children57 before = div1.children[0].children[0].children[0]58 assert before.text == '4'59 before = div2.children[0].children[0].children[0]60 assert before.text == '1'61 before = div3.children[0].children[0].children[0]62 assert before.text == '2'63 before = div4.children[0].children[0].children[0]64 assert before.text == 'c'65@assert_no_logs66def test_target_counters():67 document = FakeHTML(string='''68 <style>69 div:first-child { counter-reset: div }70 div { counter-increment: div }71 #id1-2::before { content: target-counters('#id4-2', div, '.') }72 #id2-1::before { content: target-counters(url(#id3), div, '++') }73 #id3::before {74 content: target-counters('#id2-1', div, '.', lower-alpha) }75 #id4-2::before {76 content: target-counters(attr(data-count, url), div, '') }77 </style>78 <body>79 <div id="id1"><div></div><div id="id1-2"></div></div>80 <div id="id2"><div id="id2-1"></div><div></div></div>81 <div id="id3"></div>82 <div id="id4">83 <div></div><div id="id4-2" data-count="#id1-2"></div>84 </div>85 ''')86 page, = document.render().pages87 html, = page._page_box.children88 body, = html.children89 div1, div2, div3, div4 = body.children90 before = div1.children[1].children[0].children[0].children[0]91 assert before.text == '4.2'92 before = div2.children[0].children[0].children[0].children[0]93 assert before.text == '3'94 before = div3.children[0].children[0].children[0]95 assert before.text == 'b.a'96 before = div4.children[1].children[0].children[0].children[0]97 assert before.text == '12'98@assert_no_logs99def test_target_text():100 document = FakeHTML(string='''101 <style>102 a { display: block; color: red }103 div:first-child { counter-reset: div }104 div { counter-increment: div }105 #id2::before { content: 'wow' }106 #link1::before { content: 'test ' target-text('#id4') }107 #link2::before { content: target-text(attr(data-count, url), before) }108 #link3::before { content: target-text('#id3', after) }109 #link4::before { content: target-text(url(#id1), first-letter) }110 </style>111 <body>112 <a id="link1"></a>113 <div id="id1">1 Chapter 1</div>114 <a id="link2" data-count="#id2"></a>115 <div id="id2">2 Chapter 2</div>116 <div id="id3">3 Chapter 3</div>117 <a id="link3"></a>118 <div id="id4">4 Chapter 4</div>119 <a id="link4"></a>120 ''')121 page, = document.render().pages122 html, = page._page_box.children123 body, = html.children124 a1, div1, a2, div2, div3, a3, div4, a4 = body.children125 before = a1.children[0].children[0].children[0]126 assert before.text == 'test 4 Chapter 4'127 before = a2.children[0].children[0].children[0]128 assert before.text == 'wow'129 assert len(a3.children[0].children[0].children) == 0130 before = a4.children[0].children[0].children[0]131 assert before.text == '1'132@assert_no_logs133def test_target_float():134 document = FakeHTML(string='''135 <style>136 a::after {137 content: target-counter('#h', page);138 float: right;139 }140 </style>141 <div><a id="span">link</a></div>142 <h1 id="h">abc</h1>143 ''')144 page, = document.render().pages145 html, = page._page_box.children146 body, = html.children147 div, h1 = body.children148 line, = div.children149 inline, = line.children150 text_box, after = inline.children151 assert text_box.text == 'link'...

Full Screen

Full Screen

cy.py

Source:cy.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2info = {3 "%spellout-cardinal-feminine": {4 "0": "dim;",5 "1": "un;",6 "2": "dwy;",7 "3": "tair;",8 "4": "pedair;",9 "5": "pump;",10 "6": "chwech;",11 "7": "saith;",12 "8": "wyth;",13 "9": "naw;",14 "(10, 19)": "un deg[ >>];",15 "(20, 29)": "dau ddeg[ >>];",16 "(30, 99)": "<%spellout-cardinal-masculine-before-consonant< deg[ >>];",17 "(100, 999)": "<%spellout-cardinal-masculine-before-consonant< cant[ >>];",18 "(1000, 999999)": "<%spellout-cardinal-masculine-before-consonant< mil[ >>];",19 "(1000000, 999999999)": "<%spellout-cardinal-masculine-before-consonant< miliwn[ >>];",20 "(1000000000, 999999999999)": "<%spellout-cardinal-masculine-before-consonant< biliwn[ >>];",21 "(1000000000000, 999999999999999)": "<%spellout-cardinal-masculine-before-consonant< triliwn[ >>];",22 "(1000000000000000, 999999999999999999)": "<%spellout-cardinal-masculine-before-consonant< kwadriliwn[ >>];",23 "(1000000000000000000, 'inf')": "=#,##0=;"24 },25 "%spellout-cardinal-feminine-before-consonant": {26 "0": "dim;",27 "1": "un;",28 "2": "dwy;",29 "3": "tair;",30 "4": "pedair;",31 "5": "pum;",32 "6": "chwe;",33 "7": "saith;",34 "8": "wyth;",35 "9": "naw;",36 "(10, 19)": "un deg[ >>];",37 "(20, 29)": "dau ddeg[ >>];",38 "(30, 99)": "<%spellout-cardinal-masculine-before-consonant< deg[ >>];",39 "(100, 999)": "<%spellout-cardinal-masculine-before-consonant< cant[ >>];",40 "(1000, 999999)": "<%spellout-cardinal-masculine-before-consonant< mil[ >>];",41 "(1000000, 999999999)": "<%spellout-cardinal-masculine-before-consonant< miliwn[ >>];",42 "(1000000000, 999999999999)": "<%spellout-cardinal-masculine-before-consonant< biliwn[ >>];",43 "(1000000000000, 999999999999999)": "<%spellout-cardinal-masculine-before-consonant< triliwn[ >>];",44 "(1000000000000000, 999999999999999999)": "<%spellout-cardinal-masculine-before-consonant< kwadriliwn[ >>];",45 "(1000000000000000000, 'inf')": "=#,##0=;"46 },47 "%spellout-cardinal-masculine": {48 "0": "dim;",49 "1": "un;",50 "2": "dau;",51 "3": "tri;",52 "4": "pedwar;",53 "5": "pump;",54 "6": "chwech;",55 "7": "saith;",56 "8": "wyth;",57 "9": "naw;",58 "(10, 19)": "un deg[ >>];",59 "(20, 29)": "dau ddeg[ >>];",60 "(30, 99)": "<%spellout-cardinal-masculine-before-consonant< deg[ >>];",61 "(100, 999)": "<%spellout-cardinal-masculine-before-consonant< cant[ >>];",62 "(1000, 999999)": "<%spellout-cardinal-masculine-before-consonant< mil[ >>];",63 "(1000000, 999999999)": "<%spellout-cardinal-masculine-before-consonant< miliwn[ >>];",64 "(1000000000, 999999999999)": "<%spellout-cardinal-masculine-before-consonant< biliwn[ >>];",65 "(1000000000000, 999999999999999)": "<%spellout-cardinal-masculine-before-consonant< triliwn[ >>];",66 "(1000000000000000, 999999999999999999)": "<%spellout-cardinal-masculine-before-consonant< kwadriliwn[ >>];",67 "(1000000000000000000, 'inf')": "=#,##0=;"68 },69 "%spellout-cardinal-masculine-before-consonant": {70 "0": "dim;",71 "1": "un;",72 "2": "dau;",73 "3": "tri;",74 "4": "pedwar;",75 "5": "pum;",76 "6": "chwe;",77 "7": "saith;",78 "8": "wyth;",79 "9": "naw;",80 "(10, 19)": "un deg[ >>];",81 "(20, 29)": "dau ddeg[ >>];",82 "(30, 99)": "<%spellout-cardinal-masculine-before-consonant< deg[ >>];",83 "(100, 999)": "<%spellout-cardinal-masculine-before-consonant< cant[ >>];",84 "(1000, 999999)": "<%spellout-cardinal-masculine-before-consonant< mil[ >>];",85 "(1000000, 999999999)": "<%spellout-cardinal-masculine-before-consonant< miliwn[ >>];",86 "(1000000000, 999999999999)": "<%spellout-cardinal-masculine-before-consonant< biliwn[ >>];",87 "(1000000000000, 999999999999999)": "<%spellout-cardinal-masculine-before-consonant< triliwn[ >>];",88 "(1000000000000000, 999999999999999999)": "<%spellout-cardinal-masculine-before-consonant< kwadriliwn[ >>];",89 "(1000000000000000000, 'inf')": "=#,##0=;"90 },91 "%spellout-numbering": {92 "(0, 'inf')": "=%spellout-cardinal-masculine=;"93 },94 "%spellout-numbering-year": {95 "(0, 'inf')": "=%spellout-numbering=;"96 }...

Full Screen

Full Screen

moodRatingTime.py

Source:moodRatingTime.py Github

copy

Full Screen

1import pandas2import matplotlib.pyplot as plt3import numpy as np4import math5import cv26from PIL import Image7import datetime8df = pandas.read_csv('../data/moodLogFinal.csv')9df2after = pandas.read_csv('../data/moodLogFinalAfter.csv')10# 22. april 16.46 shift from no light control to light control11getEnergy = True12def reverse(n): 13 return 160 - n14timestamps = df["Timestamp"]15if(getEnergy):16 energyLevel = df["y"]17 energyLevel = map(reverse, energyLevel)18else:19 energyLevel = df["x"]20minutes = []21timestampsAfter = df2after["Timestamp"]22if(getEnergy):23 energyLevelAfter = df2after["y"]24 energyLevelAfter = map(reverse, energyLevelAfter)25else:26 energyLevelAfter = df2after["x"]27minutesAfter = []28for i in range(len(df)):29 date = datetime.datetime.fromtimestamp(df['Timestamp'][i] / 1e3)30 thisMinute = int(date.strftime("%M"))31 thisHour = int(date.strftime("%H"))32 minute = thisHour * 60 + thisMinute33 minutes.append(minute)34for i in range(len(df2after)):35 date = datetime.datetime.fromtimestamp(df['Timestamp'][i] / 1e3)36 thisMinute = int(date.strftime("%M"))37 thisHour = int(date.strftime("%H"))38 minute = thisHour * 60 + thisMinute39 minutesAfter.append(minute)40# AVG morning before41avgMorningBefore = 042avgMorningBeforeEnergy = 043counter = 044counter2 = 045while(counter < len(minutes)):46 if(minutes[counter] < 800):47 avgMorningBefore = avgMorningBefore + minutes[counter]48 avgMorningBeforeEnergy = avgMorningBeforeEnergy + energyLevel[counter]49 counter2 = counter2 + 150 counter = counter + 151avgMorningBefore = avgMorningBefore / counter252avgMorningBeforeEnergy = avgMorningBeforeEnergy / counter253# AVG evening before54avgEveningBefore = 055avgEveningBeforeEnergy = 056counter = 057counter2 = 058while(counter < len(minutes)):59 if(minutes[counter] > 800):60 avgEveningBefore = avgEveningBefore + minutes[counter]61 avgEveningBeforeEnergy = avgEveningBeforeEnergy + energyLevel[counter]62 counter2 = counter2 + 163 counter = counter + 164 print(counter2)65avgEveningBefore = avgEveningBefore / counter266avgEveningBeforeEnergy = avgEveningBeforeEnergy / counter267print(avgMorningBefore, avgMorningBeforeEnergy)68 69# AVG morning after70avgMorningAfter = 071avgMorningAfterEnergy = 072counter = 073counter2 = 074while(counter < len(minutesAfter)):75 if(minutes[counter] < 800):76 avgMorningAfter = avgMorningAfter + minutesAfter[counter]77 avgMorningAfterEnergy = avgMorningAfterEnergy + energyLevelAfter[counter]78 counter2 = counter2 + 179 counter = counter + 180avgMorningAfter = avgMorningAfter / counter281avgMorningAfterEnergy = avgMorningAfterEnergy / counter282# AVG evening after83avgEveningAfter = 084avgEveningAfterEnergy = 085counter = 086counter2 = 087while(counter < len(minutesAfter)):88 if(minutes[counter] > 800):89 avgEveningAfter = avgEveningAfter + minutesAfter[counter]90 avgEveningAfterEnergy = avgEveningAfterEnergy + energyLevelAfter[counter]91 counter2 = counter2 + 192 counter = counter + 193avgEveningAfter = avgEveningAfter / counter294avgEveningAfterEnergy = avgEveningAfterEnergy / counter295# From 0 to 16096area = np.pi*597# Plot98plt.grid(color='#eeeeee', linestyle='-', linewidth=1)99plt.scatter(minutes, energyLevel, s=area, color="#ff4040", label="Before")100plt.scatter(minutesAfter, energyLevelAfter, s=area, color="#4040ff", label="After")101#plt.scatter(avgMorningBefore, avgMorningBeforeEnergy, s=area, color="#00ff00", label="Before avg")102#plt.scatter(avgEveningBefore, avgEveningBeforeEnergy, s=area, color="#00ff00", label="Before avg")103#plt.scatter(avgMorningAfter, avgMorningAfterEnergy, s=area, color="#ffff00", label="After avg")104#plt.scatter(avgEveningAfter, avgEveningAfterEnergy, s=area, color="#ffff00", label="After avg")105plt.plot([avgMorningBefore, avgEveningBefore], [avgMorningBeforeEnergy, avgEveningBeforeEnergy], color="#ff4040", label="Before (avg)")106plt.plot([avgMorningAfter, avgEveningAfter], [avgMorningAfterEnergy, avgEveningAfterEnergy], color="#4040ff", label="After (avg)")107plt.title('Time of mood rating and energy level')108plt.xlabel('Time of day in minutes')109if(getEnergy):110 plt.ylabel('Energy level')111else:112 plt.ylabel('Happiness')113plt.ylim(0, 160)114plt.legend()...

Full Screen

Full Screen

test_bits.py

Source:test_bits.py Github

copy

Full Screen

...86 assert_equal(b.after(45), 50)87 assert_equal(b.after(47), 50)88 assert_equal(b.after(50), 80)89 assert_equal(b.after(80), None)90 assert_equal(b.before(0), None)91 assert_equal(b.before(99), 80)92 assert_equal(b.before(81), 80)93 assert_equal(b.before(80), 50)94 assert_equal(b.before(50), 30)95 assert_equal(b.before(48), 30)96 assert_equal(b.before(46), 30)97 assert_equal(b.before(45), 30)98 assert_equal(b.before(44), 30)99 assert_equal(b.before(42), 30)100 assert_equal(b.before(38), 30)101 assert_equal(b.before(36), 30)102 assert_equal(b.before(34), 30)103 assert_equal(b.before(33), 30)104 assert_equal(b.before(32), 30)105 assert_equal(b.before(30), 11)106 assert_equal(b.before(11), 10)107 assert_equal(b.before(10), None)108 b = c([7])109 assert_equal(b.after(0), 7)110 b = c([8])111 assert_equal(b.after(0), 8)112 b = c([9])113 assert_equal(b.after(0), 9)114 b = c([7])115 assert_equal(b.before(16), 7)116 b = c([8])117 assert_equal(b.before(16), 8)118 b = c([9])119 assert_equal(b.before(16), 9)120 b = c([49])121 assert_equal(b.after(0), 49)122def test_sortedintset():123 test_bit_basics(SortedIntSet)124 test_len(SortedIntSet)125 test_union(SortedIntSet)126 test_intersection(SortedIntSet)127 test_difference(SortedIntSet)128 test_copy(SortedIntSet)129 test_clear(SortedIntSet)130 test_isdisjoint(SortedIntSet)...

Full Screen

Full Screen

final_p8.py

Source:final_p8.py Github

copy

Full Screen

1class Frob(object):2 def __init__(self, name):3 self.name = name4 self.before = None5 self.after = None6 def setBefore(self, before):7 self.before = before8 def setAfter(self, after):9 self.after = after10 def getBefore(self):11 return self.before12 def getAfter(self):13 return self.after14 def myName(self):15 return self.name16 def __repr__(self):17 before = self.getBefore()18 before = before.myName() if before else '*'19 me = self.name.upper()20 after = self.getAfter()21 after = after.myName() if after else '*'22 return '%s--%s--%s' % (before, me, after)23def get_ins_pos(p, q):24 # FIXME: should return a ternary.25 '''Return new pair of Frobs to mutate.26 27 p: current Frob.28 q: new Frob to insert.29 '''30 # To put q before p31 if q.myName() < p.myName():32 # p does not have a head33 if p.getBefore() is None:34 return (q, p)35 # p has a head36 else:37 return get_ins_pos(p.getBefore(), q)38 # To put q after p39 else:40 # p does not have a tail41 if p.getAfter() is None:42 return (p, q)43 else:44 return get_ins_pos(p.getAfter(), q)45def get_ins_pos_bisect(p, l):46 '''Return a ternary of Frobs to mutate in the order they are to be47 appearing in the linkedlist.48 49 p: current Frob.50 q: new Frob to insert.51 '''52 from bisect import bisect53 bisect(p)54def insert(atMe, newFrob):55 """56 atMe: a Frob that is part of a doubly linked list57 newFrob: a Frob with no links58 This procedure appropriately inserts newFrob into the linked list that atMe59 is a part of. 60 """61 from bisect import bisect62 p, q = atMe, newFrob63 frobs = get_all_frobs(p)64 frob_names = [f.myName() for f in frobs]65 index = bisect(frob_names, q.myName())66 frobs.insert(index, q)67 #print index68 #print len(frobs)69 try:70 p = frobs[index - 1]71 except IndexError:72 p = None73 c = frobs[index]74 try:75 q = frobs[index + 1]76 except IndexError:77 q = None78 #print p, c, q79 # FIXME: this is buggy. But I quit here. Jun 1 201380 p.setAfter(c)81 c.setBefore(p)82 c.setAfter(q)83 q.setBefore(c)84 #b, a = get_ins_pos(atMe, newFrob)85 #b.setAfter(a)86 #a.setBefore(b)87def get_all_frobs(f):88 from collections import deque89 l = deque([f])90 b = f.getBefore()91 # Not at the head of the linkedlist92 while b is not None:93 l.appendleft(b)94 b = b.getBefore()95 a = f.getAfter()96 while a is not None:97 l.append(a)98 a = a.getAfter()99 return list(l)100def findFront(start):101 """102 start: a Frob that is part of a doubly linked list103 returns: the Frob at the beginning of the linked list 104 """105 if start.getBefore() is None:106 return start107 else:108 return findFront(start.getBefore())109if __name__ == '__main__':110 eric = Frob('eric')111 andrew = Frob('andrew')112 ruth = Frob('ruth')113 fred = Frob('fred')114 martha = Frob('martha')115 zed = Frob('zed')116 def print_list():117 for frob in andrew, eric, fred, martha, ruth, zed:118 print frob119 insert(eric, andrew)120 print_list()121 insert(eric, ruth)122 print_list()123 #insert(eric, fred)124 #print_list()125 #insert(ruth, martha)126 #print_list()127 #insert(andrew, zed)128 #print_list()129 print '***'130 #print findFront(ruth)...

Full Screen

Full Screen

moodBoxPlot.py

Source:moodBoxPlot.py Github

copy

Full Screen

1import pandas2import matplotlib.pyplot as plt3import numpy as np4import math5import cv26from PIL import Image7import datetime8df = pandas.read_csv('../data/moodLogFinal.csv')9df2after = pandas.read_csv('../data/moodLogFinalAfter.csv')10# 22. april 16.46 shift from no light control to light control11getEnergy = True12def reverse(n): 13 return 160 - n14timestamps = df["Timestamp"]15energyLevel = df["y"]16energyLevel = map(reverse, energyLevel)17happinessLevel = df["x"]18minutes = []19timestampsAfter = df2after["Timestamp"]20energyLevelAfter = df2after["y"]21energyLevelAfter = map(reverse, energyLevelAfter)22happinessLevelAfter = df2after["x"]23minutesAfter = []24for i in range(len(df)):25 date = datetime.datetime.fromtimestamp(df['Timestamp'][i] / 1e3)26 thisMinute = int(date.strftime("%M"))27 thisHour = int(date.strftime("%H"))28 minute = thisHour * 60 + thisMinute29 minutes.append(minute)30for i in range(len(df2after)):31 date = datetime.datetime.fromtimestamp(df['Timestamp'][i] / 1e3)32 thisMinute = int(date.strftime("%M"))33 thisHour = int(date.strftime("%H"))34 minute = thisHour * 60 + thisMinute35 minutesAfter.append(minute)36# AVG morning before37avgMorningBefore = 038avgMorningBeforeEnergy = 039counter = 040counter2 = 041while(counter < len(minutes)):42 if(minutes[counter] < 800):43 avgMorningBefore = avgMorningBefore + minutes[counter]44 avgMorningBeforeEnergy = avgMorningBeforeEnergy + energyLevel[counter]45 counter2 = counter2 + 146 counter = counter + 147avgMorningBefore = avgMorningBefore / counter248avgMorningBeforeEnergy = avgMorningBeforeEnergy / counter249# AVG evening before50avgEveningBefore = 051avgEveningBeforeEnergy = 052counter = 053counter2 = 054while(counter < len(minutes)):55 if(minutes[counter] > 800):56 avgEveningBefore = avgEveningBefore + minutes[counter]57 avgEveningBeforeEnergy = avgEveningBeforeEnergy + energyLevel[counter]58 counter2 = counter2 + 159 counter = counter + 160 print(counter2)61avgEveningBefore = avgEveningBefore / counter262avgEveningBeforeEnergy = avgEveningBeforeEnergy / counter263print(avgMorningBefore, avgMorningBeforeEnergy)64 65# AVG morning after66avgMorningAfter = 067avgMorningAfterEnergy = 068counter = 069counter2 = 070while(counter < len(minutesAfter)):71 if(minutes[counter] < 800):72 avgMorningAfter = avgMorningAfter + minutesAfter[counter]73 avgMorningAfterEnergy = avgMorningAfterEnergy + energyLevelAfter[counter]74 counter2 = counter2 + 175 counter = counter + 176avgMorningAfter = avgMorningAfter / counter277avgMorningAfterEnergy = avgMorningAfterEnergy / counter278# AVG evening after79avgEveningAfter = 080avgEveningAfterEnergy = 081counter = 082counter2 = 083while(counter < len(minutesAfter)):84 if(minutes[counter] > 800):85 avgEveningAfter = avgEveningAfter + minutesAfter[counter]86 avgEveningAfterEnergy = avgEveningAfterEnergy + energyLevelAfter[counter]87 counter2 = counter2 + 188 counter = counter + 189avgEveningAfter = avgEveningAfter / counter290avgEveningAfterEnergy = avgEveningAfterEnergy / counter291box_plot_data=[energyLevel, energyLevelAfter, happinessLevel, happinessLevelAfter]92plt.boxplot(box_plot_data, labels=['Energy before', 'Energy after', 'Happiness before', 'Happiness after'])...

Full Screen

Full Screen

eval_utils.py

Source:eval_utils.py Github

copy

Full Screen

1import numpy as np2from keras import backend as K3from sklearn.metrics import roc_auc_score456def pairwise_precision_recall_f1(preds, truths):7 tp = 08 fp = 09 fn = 010 n_samples = len(preds)11 for i in range(n_samples - 1):12 pred_i = preds[i]13 for j in range(i + 1, n_samples):14 pred_j = preds[j]15 if pred_i == pred_j:16 if truths[i] == truths[j]:17 tp += 118 else:19 fp += 120 elif truths[i] == truths[j]:21 fn += 122 tp_plus_fp = tp + fp23 tp_plus_fn = tp + fn24 if tp_plus_fp == 0:25 precision = 0.26 else:27 precision = tp / tp_plus_fp28 if tp_plus_fn == 0:29 recall = 0.30 else:31 recall = tp / tp_plus_fn3233 if not precision or not recall:34 f1 = 0.35 else:36 f1 = (2 * precision * recall) / (precision + recall)37 return precision, recall, f1383940def cal_f1(prec, rec):41 return 2*prec*rec/(prec+rec)424344def get_hidden_output(model, inp):45 get_activations = K.function(model.inputs[:1] + [K.learning_phase()], [model.layers[5].get_output_at(0), ])46 activations = get_activations([inp, 0])47 return activations[0]484950def predict(anchor_emb, test_embs):51 score1 = np.linalg.norm(anchor_emb-test_embs[0])52 score2 = np.linalg.norm(anchor_emb-test_embs[1])53 return [score1, score2]545556def full_auc(model, test_triplets):57 """58 Measure AUC for model and ground truth on all items.5960 Returns:61 - float AUC62 """6364 grnds = []65 preds = []66 preds_before = []67 embs_anchor, embs_pos, embs_neg = test_triplets6869 inter_embs_anchor = get_hidden_output(model, embs_anchor)70 inter_embs_pos = get_hidden_output(model, embs_pos)71 inter_embs_neg = get_hidden_output(model, embs_neg)72 # print(inter_embs_pos.shape)7374 accs = []75 accs_before = []7677 for i, e in enumerate(inter_embs_anchor):78 if i % 10000 == 0:79 print('test', i)8081 emb_anchor = e82 emb_pos = inter_embs_pos[i]83 emb_neg = inter_embs_neg[i]84 test_embs = np.array([emb_pos, emb_neg])8586 emb_anchor_before = embs_anchor[i]87 emb_pos_before = embs_pos[i]88 emb_neg_before = embs_neg[i]89 test_embs_before = np.array([emb_pos_before, emb_neg_before])9091 predictions = predict(emb_anchor, test_embs)92 predictions_before = predict(emb_anchor_before, test_embs_before)9394 acc_before = 1 if predictions_before[0] < predictions_before[1] else 095 acc = 1 if predictions[0] < predictions[1] else 096 accs_before.append(acc_before)97 accs.append(acc)9899 grnd = [0, 1]100 grnds += grnd101 preds += predictions102 preds_before += predictions_before103104 auc_before = roc_auc_score(grnds, preds_before)105 auc = roc_auc_score(grnds, preds)106 print('test accuracy before', np.mean(accs_before))107 print('test accuracy after', np.mean(accs))108109 print('test AUC before', auc_before)110 print('test AUC after', auc) ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { before } = require("qawolf");2const { after } = require("qawolf");3const { create } = require("qawolf");4const { launch } = require("qawolf");5const { type } = require("qawolf");6const { click } = require("qawolf");7const { select } = require("qawolf");8const { check } = require("qawolf");9const { uncheck } = require("qawolf");10const { fill } = require("qawolf");11const { press } = require("qawolf");12const { hover } = require("qawolf");13const { scroll } = require("qawolf");14const { waitForText } = require("qawolf");15const { waitFor } = require("qawolf");16let browser;17let page;18beforeAll(async () => {19 browser = await before();20 page = await launch(browser);21});22afterAll(async () => {23 await after(browser);24});25describe("test", () => {26 it("test", async () => {27 const context = await create(browser);28 await type(page, "#email", "test");29 await click(page, "#create-account");30 await type(page, "#password", "test

Full Screen

Using AI Code Generation

copy

Full Screen

1const { before } = require('qawolf');2const { after } = require('qawolf');3const { create } = require('qawolf');4const { launch } = require('qawolf');5const { context } = require('qawolf');6const { click } = require('qawolf');7const { type } = require('qawolf');8const { select } = require('qawolf');9const { check } = require('qawolf');10const { uncheck } = require('qawolf');11const { press } = require('qawolf');12const { scrollTo } = require('qawolf');13const { waitFor } = require('qawolf');14const { waitForText } = require('qawolf');15const { waitForSelector } = require('qawolf');16const { waitForXPath } = require('qawolf');17const { hover } = require('qawolf');18const { dragAndDrop } = require('qawolf');19const { selectOption } = require('qawolf');20const { selectOptions } = require('qawolf');21const { deselectOption } = require('qawolf');22const { deselectOptions } = require('qawolf');

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const selectors = require("../selectors/test.json");3let browser;4let page;5beforeAll(async () => {6 browser = await qawolf.launch();7 page = await qawolf.createPage(browser);8});9afterAll(async () => {10 await qawolf.stopVideos();11 await browser.close();12});13test("test", async () => {14 await page.click(selectors["q"]);15 await page.fill(selectors["q"], "qawolf");16 await page.click(selectors["btnK"]);17 await page.click(selectors["div"]);18 await page.click(selectors["div"]);19});20const qawolf = require("qawolf");21const selectors = require("../selectors/test.json");22let browser;23let page;24afterAll(async () => {25 await qawolf.stopVideos();26 await browser.close();27});28test("test", async () => {29 browser = await qawolf.launch();30 page = await qawolf.createPage(browser);31 await page.click(selectors["q"]);32 await page.fill(selectors["q"], "qawolf");33 await page.click(selectors["btnK"]);34 await page.click(selectors["div"]);35 await page.click(selectors["div"]);36});37const qawolf = require("qawolf");38const selectors = require("../selectors/test.json");39let browser;40let page;41beforeEach(async () => {42 browser = await qawolf.launch();43 page = await qawolf.createPage(browser);44});45afterEach(async () => {46 await qawolf.stopVideos();47 await browser.close();48});49test("test", async () => {50 await page.click(selectors["q"]);51 await page.fill(selectors["q"], "qawolf");52 await page.click(selectors["btnK"]);53 await page.click(selectors["div"]);54 await page.click(selectors["div"]);55});56const qawolf = require("qawolf");57const selectors = require("../selectors/test.json");58let browser;59let page;60afterEach(async () => {61 await qawolf.stopVideos();

Full Screen

Using AI Code Generation

copy

Full Screen

1beforeEach(async () => {2 await qawolf.create();3});4afterEach(async () => {5 await qawolf.stop();6});7test("Test", async () => {8 await qawolf.test("test", async () => {9 await qawolf.click("text=Sign in");10 await qawolf.type("input[name=email]", "test");11 await qawolf.type("input[name=password]", "test");12 await qawolf.click("button[type=submit]");13 await qawolf.click("text=Sign out");14 });15});16Please read [CONTRIBUTING.md](

Full Screen

Using AI Code Generation

copy

Full Screen

1const { before } = require('qawolf');2beforeAll(async () => {3});4const { after } = require('qawolf');5afterAll(async () => {6 await after();7});8const { create } = require('qawolf');9it('test', async () => {10 const browser = await create();11 const page = await browser.newPage();12 await page.click('button');13 await page.click('button');14 await page.click('button');15 await browser.close();16});17const { before } = require('qawolf');18beforeAll(async () => {19});20const { after } = require('qawolf');21afterAll(async () => {22 await after();23});24const { create } = require('qawolf');25it('test', async () => {26 const browser = await create();27 const page = await browser.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { before } = require("qawolf");2const selectors = require("../selectors/test.json");3const { after } = require("qawolf");4const selectors = require("../selectors/test.json");5const { create } = require("qawolf");6const selectors = require("../selectors/test.json");7const { type } = require("qawolf");8const selectors = require("../selectors/test.json");9const { click } = require("qawolf");10const selectors = require("../selectors/test.json");11const { check } = require("qawolf");12const selectors = require("../selectors/test.json");13const { uncheck } = require("qawolf");14const selectors = require("../selectors/test.json");15const { select } = require("qawolf");16const selectors = require("../selectors/test.json");17const { waitFor } = require("qawolf");18const selectors = require("../selectors/test.json");19const { press } = require("qawolf");20const selectors = require("../selectors/test.json");21const { hover } = require("qawolf");22const selectors = require("../selectors/test.json");23const { focus } = require("qawolf");24const selectors = require("../selectors/test.json");25const { scroll } = require("qawolf");26const selectors = require("../selectors/test.json");27const { waitForNavigation } = require("qawolf");28const selectors = require("../selectors/test.json");29const { close } = require("qawolf");30const selectors = require("../selectors/test.json");31const { launch } = require("qawolf");32const selectors = require("../selectors/test.json");

Full Screen

Using AI Code Generation

copy

Full Screen

1beforeAll(async () => {2 await qawolf.create();3});4afterAll(async () => {5 await qawolf.stop();6});7test('test', async () => {8 const page = await qawolf.context().newPage();9 await page.click('[name="q"]');10 await page.type('[name="q"]', 'qawolf');11 await page.click('[value="Google Search"]');12 await page.waitForSelector('text="QAWolf: Automated browser testing tool"]');13 await page.click('text="QAWolf: Automated browser testing tool"');14 await page.waitForSelector('text="Get started for free"');15});

Full Screen

Using AI Code Generation

copy

Full Screen

1before(async () => {2 await qawolf.register()3})4after(async () => {5 await qawolf.create()6})

Full Screen

Using AI Code Generation

copy

Full Screen

1await after();2const { before, after, click, type, page } = require('qawolf');3describe('google', () => {4 beforeAll(async () => {5 });6 afterAll(async () => {7 await after();8 });9 it('searches', async () => {10 await type(page, 'input[name="q"]', 'qawolf');11 await click(page, 'input[value="Google Search"]');12 });13});14### `before({ url })`15### `after()`16### `click(page, selector, options)`17- `page` - [Puppeteer Page](

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