Best JavaScript code snippet using tracetest
validate.py
Source:validate.py  
...93			return ann94## TESTING FUNCTIONS ######################################################95def testClaim(annotation, urn, label, exact, method, negation, rej_statement, rej_reason, rej_comment):96	print "[INFO] begin validating claim..."97	if isMatched("urn", urn, annotation.urn) and isMatched("label", label, annotation.label) and isMatched("exact text", exact, annotation.exact) and isMatched("user entered method", method, annotation.method) and isMatched("negation", negation, annotation.negation) and isMatched("rejected", rej_statement, annotation.rejected_statement) and isMatched("rejected", rej_reason, annotation.rejected_statement_reason) and isMatched("rejected", rej_comment, annotation.rejected_statement_comment):98		print "[TEST] claim is validated"		99	else:100		print "[ERROR] claim is not correct"101def testQualifier(qualifier, qvalue, subject, predicate, object, enantiomer, metabolite):102	print "[INFO] begin validating claim qualifiers..."	103	if isMatched("qualifier", qvalue, qualifier.qvalue) and isMatched("subject", subject, qualifier.subject) and isMatched("predicate", predicate, qualifier.predicate) and isMatched("object", object, qualifier.object) and isMatched("enantiomer", enantiomer, qualifier.enantiomer) and isMatched("metabolite", metabolite, qualifier.metabolite):104		print "[TEST] claim qualifier is validated"105	else:106		print "[ERROR] claim qualifier are not correct"107def testDataRatio(ratioItem, field, value, type, direction, exact):108	print "[INFO] begin validating %s..." % field109	if isMatched("field", field, ratioItem.field) and isMatched("value", value, ratioItem.value) and isMatched("type", type, ratioItem.type) and isMatched("direction", direction, ratioItem.direction) and isMatched("exact text", exact, ratioItem.exact):110		print "[TEST] %s is validated" % (field)111	else:112		print "[ERROR] %s is incorrect" % (field)113def testMaterialDose(doseItem, field, drugname, value, formulation, duration, regimens, exact):114	print "[INFO] begin validating %s..." % field115	if isMatched("dose type", field, doseItem.field) and isMatched("drugname", drugname, doseItem.drugname) and isMatched("value", value, doseItem.value) and isMatched("duration", duration, doseItem.duration) and isMatched("formulation", formulation, doseItem.formulation) and isMatched("regimens", regimens, doseItem.regimens) and isMatched("exact text", exact, doseItem.exact):116		print "[TEST] %s is validated" % (field)117	else:118		print "[ERROR] %s is incorrect" % (field)119def testParticipants(partItem, value, exact):120	print "[INFO] begin validating participants..."121	if isMatched("participants", value, partItem.value) and isMatched("exact", exact, partItem.exact):122		print "[TEST] participants is validated"123	else:124		print "[ERROR] participants is incorrect"125def testEvRelationship(dmRow, value):126	if isMatched("evidence relationship", value, dmRow.ev_supports):127		print "[TEST] evidence relationship is validated"128	else:129		print "[ERROR] evidence relationship is incorrect"		130def testPhenotype(phenoItem, ptype, value, metabolizer, population, exact):131	print "[INFO] begin validating phenotype..."132	if isMatched("phenotype", ptype, phenoItem.ptype) and isMatched("value", value, phenoItem.value) and isMatched("metabolizer", metabolizer, phenoItem.metabolizer) and isMatched("population", population, phenoItem.population) and isMatched("exact", exact, phenoItem.exact):133		print "[TEST] phenotype is validated"134	else:135		print "[ERROR] phenotype is incorrect"136def testDataReviewer(reviewerItem, reviewer, date, total, lackinfo):137	print "[INFO] begin validating data reviewer..."138	if isMatched("reviewer", reviewer, reviewerItem.reviewer) and isMatched("date", date, reviewerItem.date) and isMatched("total", total, reviewerItem.total) and isMatched("lackinfo", lackinfo, reviewerItem.lackinfo):139		print "[TEST] data reviewer is validated"140	else:141		print "[ERROR] data reviewer is incorrect"142def testDataDipsQs(dipsItem, qsDict):143	print "[INFO] begin validating dips questions..."144	annDipsQsDict = dipsItem.getDipsDict()145	if len(annDipsQsDict) == len(qsDict):146		for k,v in qsDict.iteritems():147			if not isMatched("dips " + k, v, annDipsQsDict[k]):148				return149		print "[TEST] dips questions are validated"150	else:151		print "[ERROR] incorrect number of dips questions"152def testEvTypeQuestion(dmRow, grouprandom, parallelgroup):153	print "[INFO] begin validating evidence type questions..."154	if isMatched("grouprandom", grouprandom, dmRow.grouprandom) and isMatched("parallelgroup", parallelgroup, dmRow.parallelgroup):155		print "[TEST] evidence type related questions are validated"156	else:157		print "[ERROR] evidence type related questions are incorrect"158		159def isMatched(field, val1, val2):160	if type(val1) != type(val2):161		print "[ERROR] %s have an incorrect data type" % field162		return False163	if val1 == val2:164		#print "[TEST] %s is validated" % field165		return True166	print "[ERROR] %s is incorrect: val1 (%s) and val2 (%s)" % (field, val1, val2)167	return False	168## TESTING CASES #############################################################169# Validate clinical trial annotation 170# Two data & material items171def test_clinical_trial_1(conn, template):172	print "[INFO] ===== begin test clinical trial annotation 1 ======================"173	annUrn = "test-clinicaltrial-id-1"...within10ms.py
Source:within10ms.py  
1import os                                #for accessing and iterating through directories2import statistics                        #for calculating standard deviation3import matplotlib.pyplot as plt          #for generating histogram4from statsmodels.graphics import tsaplots  #for autocorrelation function5import numpy as np                       #for autocorrelation6import scipy7from scipy import signal8from pandas import read_csv9from statsmodels.graphics.tsaplots import plot_acf10import csv11class Event():12    scope = ''             #initialized to null string13    timestamp = 0          #initialized to zero14    voltage = 0            #this is the voltage from the ramp. It is initialized to zero15    isMatched = False      #initialized to false because the event hasn't been matched to a corrsponding one yet16    def __init__(self, scp, time, volt):  #we will include voltage as soon as we figure out how to record from multiple sources in Waveforms 201517        self.scope = scp18        self.timestamp = time19        self.voltage = volt20#anodeDir = 'C:\\Users\\skyfab\\Documents\\Waveforms\\Data Scenario 2\\anode'  #folder path to .csv acquisitions for AD1 in scenario 121#pmtDir = 'C:\\Users\\skyfab\\Documents\\Waveforms\\Data Scenario 2\pmt'      #folder path to .csv acquisitions for AD2 in scenario 122#anodeDir = 'C:\\Users\\skyfab\\Documents\\Waveforms\\Data Scenario 1\\AD1 run 27'   #folder path to .csv acquisitions for AD1 in scenario 123#pmtDir = 'C:\\Users\\skyfab\\Documents\\Waveforms\\Data Scenario 1\\AD2 run 27'      #folder path to .csv acquisitions for AD2 in scenario 124anodeDir = 'C:\\Users\\skyfab\Documents\\Waveforms\\Data Scenario 1 with voltages\\AD1'   #folder path to .csv acquisitions for AD1 in scenario 125pmtDir = 'C:\\Users\\skyfab\Documents\\Waveforms\\Data Scenario 1 with voltages\\AD2'      #folder path to .csv acquisitions for AD2 in scenario 126anode = []27pmt = []28difsXaxis = []                                                     #number of time differences recorded29for filename in os.listdir(anodeDir):30    name = os.path.join(anodeDir, filename)                        #store the name of the file in 'name'31    index = len(name) - 5                                          #len(name) is the number of characters in name, and len(name) - 5 is ones place of the milliseconds in the timestamp 32                                                                   #example: name = 'C:\Users\skyfab\Documents\Waveforms\Data\anode\anode12.25.43.116.csv' 33                                                                   #the character name[index] corresponds to 6. We use the function int() to cast the character to an integer value34  35    timeStampVal = int(name[index - 8]) * 600000 + int(name[index - 7]) * 60000 + int(name[index - 5]) * 10000 + int(name[index - 4]) * 1000 + int(name[index - 2]) * 100 + int(name[index - 1]) * 10 + int(name[index]) #converting the timestamp to milliseconds36    #anodeTimes.append(timeStampVal)                                 #add timestamp value to anodeTimes37    38    volt = 039    40    with open(name) as f:41        rows = list(csv.reader(f))42        volt += float(rows[21][1])43    44    anode.append(Event("AD1", timeStampVal, volt))45  46for filename in os.listdir(pmtDir):47    name = os.path.join(pmtDir, filename)                          48    index = len(name) - 549  50    timeStampVal = int(name[index - 8]) * 600000 + int(name[index - 7]) * 60000 + int(name[index - 5]) * 10000 + int(name[index - 4]) * 1000 + int(name[index - 2]) * 100 + int(name[index - 1]) * 10 + int(name[index]) #converting the timestamp to milliseconds51    #pmtTimes.append(timeStampVal)                                   #add timestamp value to pmtTimes52    volt = 053    54    with open(name) as f:55        rows = list(csv.reader(f))56        volt += float(rows[21][1])57        58    pmt.append(Event("AD2", timeStampVal, volt))59#the following section is supposed to get rid of acquisition duplicates60'''61Evan's within dT = 10 milliseconds algorithm62step 1: determine which oscilloscope took more acquisitions. This is the list we are going to pop aquisitions from63step 2: start at the beginning of the larger list and see if the acquisition across is within 10 seconds.64        if it is, move on to the next acquisition in the larger list.65        If not, check if the next acquisition has a smaller time difference66            if it is, check if the acquisition is within 10 seconds. if not check if the next acquisition has a smaller time difference67            if not, move on to the next acquisition in the larger list 68'''69pairedAnode = []              #these lists will contain the paired acquisitions70pairedPmt = []71numTossed = 0                  #number of events removed72anodeLen = len(anode)          #73pmtLen = len(pmt)74#for when pmt has more acquisitions than anode 75if(pmtLen > anodeLen):76        for i in range(len(anode)):77            wasMatch = False78            if(i == 0):             #if you are looking at the first element in the large list, compare it to the next three acquisitions79                for j in range(3):80                    if(abs(anode[i].timestamp - pmt[i + j].timestamp) < 10 and not anode[i].isMatched and not pmt[i+j].isMatched):81                        pairedAnode.append(anode[i])82                        pairedPmt.append(pmt[i + j])83                        anode[i].isMatched = True84                        pmt[i + j].isMatched = True85                        wasMatch = True86            elif(i == len(anode) - 1): #if you are looking at the last element in the large list, compare it to the next three acquisitions87                for j in range(3):88                    if(abs(anode[i].timestamp - pmt[i - j].timestamp) < 10 and not anode[i].isMatched and not pmt[i-j].isMatched):89                        pairedAnode.append(anode[i])90                        pairedPmt.append(pmt[i - j])91                        anode[i].isMatched = True92                        pmt[i - j].isMatched = True93                        wasMatch = True94            else:95                for j in range(3):96                    if(abs(anode[i].timestamp - pmt[i - 1 + j].timestamp) < 10 and not anode[i].isMatched and not pmt[i - 1 + j].isMatched):97                            pairedAnode.append(anode[i])98                            pairedPmt.append(pmt[i - 1 + j])99                            anode[i].isMatched = True100                            pmt[i - 1 + j].isMatched = True 101                            wasMatch = True102            if(not wasMatch):103                numTossed += 1104#for when anode has more acquisitions than pmt105if(anodeLen > pmtLen):106    for i in range(len(pmt)):107        wasMatch = False108        if(i == 0):             #if you are looking at the first element in the large list, compare it to the next three acquisitions109            for j in range(3):110                if(abs(pmt[i].timestamp - anode[i + j].timestamp) < 10 and not pmt[i].isMatched and not anode[i+j].isMatched):111                    pairedPmt.append(pmt[i])112                    pairedAnode.append(anode[i + j])113                    pmt[i].isMatched = True114                    anode[i + j].isMatched = True115                    wasMatch = True116        elif(i == len(pmt) - 1): #if you are looking at the last element in the large list, compare it to the next three acquisitions117            for j in range(3):118                if(abs(pmt[i].timestamp - anode[i - j].timestamp) < 10 and not pmt[i].isMatched and not anode[i-j].isMatched):119                    pairedPmt.append(pmt[i])120                    pairedAnode.append(anode[i - j])121                    pmt[i].isMatched = True122                    anode[i - j].isMatched = True123                    wasMatch = True124        else:125            for j in range(3):126                if(abs(pmt[i].timestamp - anode[i - 1 + j].timestamp) < 10 and not pmt[i].isMatched and not anode[i - 1 + j].isMatched):127                        pairedPmt.append(pmt[i])128                        pairedAnode.append(anode[i - 1 + j])129                        pmt[i].isMatched = True130                        anode[i - 1 + j].isMatched = True 131                        wasMatch = True132        133        if(not wasMatch):134            numTossed += 1135'''136if(anodeLen > pmtLen):137    for i in range(len(anode):138        isMatched = False139        for j in range(3):140            if(abs(anode[i].timestamp - pmt[i +j].timestamp) < 10 and not isMatched):141                pairedAnode.append(anode[i])142                pairedPmt.append(pmt[i + j])143                isMatched = True144elif(pmtLen > anodeLen):145    for i in range(len(pmt)):146        isMatched = False147        for j in range(3):148            if(abs(pmt[i].timestamp - anode[i+ j].timestamp) < 10 and not isMatched):149                pairedPmt.append(pmt[i])150                pairedAnode.append(anode[i+j])151                isMatched = True                152'''       153    154    155#The following section can be uncommented to display the timestamp values in anodeTimes and pmtTimes156#This process slows down the program157'''158print("-------------------- now displaying anodeTimes --------------") 159for i in range(len(anodeTimes)):                                        #iterate through and print timestamp values of anodeTimes160    print(anodeTimes[i])161    print('\n')162print("-------------------- now displaying pmtTimes --------------")163 164for i in range(len(pmtTimes)):                                          #iterate through and print timestamp values of pmtTimes165    print(pmtTimes[i])166    print('\n')167'''168timeDifs = [] #difference between timestamps is stored here169voltDifs = [] #difference between voltages is stored here170count = 1  #serves as an index for the time differences171#for a, p in zip(anodeTimes, pmtTimes): 172for a, p in zip(pairedAnode, pairedPmt):173    #timeDifs.append( abs(a - p) )174    timeDifs.append(abs(a.timestamp - p.timestamp))175    voltDifs.append(abs(a.voltage - p.voltage))176    print("%1d %10d %20s %10f %20s %f %20s %10d" % (count, abs(a.timestamp - p.timestamp), "anode voltage: ", a.voltage, "pmt voltage: ", p.voltage, "voltage diff: ", abs(a.voltage - p.voltage)))177    difsXaxis.append(count)178    count += 1179print("\n")180print("The average time difference between the two oscilloscopes is: ")181print(sum(timeDifs) / len(timeDifs))                                        #print average182print("\n")183print("the standard deviation is:")                                         #print standard deviation184print(statistics.stdev(timeDifs))185print("\n")186print("the median is:")187print(statistics.median(timeDifs))                                                     #print median188print('\n\n')189print("The average voltage difference between the two oscilloscopes is: ")               #not sure if I want to plot this yet190print(sum(voltDifs) / len(voltDifs))                                        #print average191print("\n")192print("the standard deviation is:")                                         #print standard deviation193print(statistics.stdev(voltDifs))194print("\n")195print("the median is:")196print(statistics.median(voltDifs))      197print('\n\n')198print("the number of acquisitions for AD1 is:")                                         #print number of acquisitions199print(len(pairedAnode))200print("the number of acquisitions for AD2 is:")201print(len(pairedPmt))202print('\n\n')203print("The number of acquisitions tossed is:")204print(numTossed)205#figure something out for bipolar distributions206#The following lines generate a histogram in a popup window207fig, (ax1, ax2, ax3, ax4) = plt.subplots(4)   # create figure and axes208ax1.hist(timeDifs, bins = 'auto')                                #figure out how to make bin width 1 ms209ax1.set_title('Time Differences')210ax1.set_xlabel('Time Difference in Milliseconds')211ax1.set_ylabel('Frequency')212count = 1213anodeXaxis = []214pmtXaxis = []215while(count <= len(pairedAnode)):216    anodeXaxis.append(count)217    count += 1218count = 1219#while(count <= len(pmtTimes)):220while(count <= len(pairedPmt)):221    pmtXaxis.append(count)222    count += 1223#ax2.scatter(anodeXaxis, anodeTimes, color="b")224#ax2.scatter(pmtXaxis, pmtTimes, color="r", marker="P")225anodeTimes = []226pmtTimes = []227for i in range(len(pairedAnode)):228    anodeTimes.append(pairedAnode[i].timestamp)229for i in range(len(pairedPmt)):230    pmtTimes.append(pairedPmt[i].timestamp)231ax2.scatter(anodeXaxis, anodeTimes, color="b")232ax2.scatter(pmtXaxis, pmtTimes, color="r", marker="P")233ax2.set_xlabel('acquisition number')234ax2.set_ylabel('Time in miliseconds')         235ax3.scatter(difsXaxis, timeDifs)236ax3.set_xlabel('acq number')237ax3.set_ylabel('Time difs in miliseconds') 238#corr = signal.correlate(anodeTimes, pmtTimes, mode = 'full', method = 'auto')239corr = signal.correlate(anodeTimes, pmtTimes, mode = 'full', method = 'auto')240ax4.plot(corr)241'''242autocorr = np.correlate(anodeTimes, pmtTimes, mode = 'valid')243print('\n\n')244for i in range(len(autocorr)):245    print(autocorr[i])246'''247plt.show()248#pmt folder usually has one more acquisition than the anode folder. This can cause l#arge discrepancies when 249#multiple acquisitions runs are kept in the same folder as non-corresponding acquisitions are subtracted...schulte.ts
Source:schulte.ts  
1import { defineStore } from 'pinia'2// å®ä¹æ°æ®ä»åº3import axios from 'axios'45export const useSchulteStore = defineStore('schulte', {6  state: () => {7    return {8      numbers5x5: [9        { id: 1, value: 1, isChecked: false, isMatched: false },10        { id: 2, value: 2, isChecked: false, isMatched: false },11        { id: 3, value: 3, isChecked: false, isMatched: false },12        { id: 4, value: 4, isChecked: false, isMatched: false },13        { id: 5, value: 5, isChecked: false, isMatched: false },14        { id: 6, value: 6, isChecked: false, isMatched: false },15        { id: 7, value: 7, isChecked: false, isMatched: false },16        { id: 8, value: 8, isChecked: false, isMatched: false },17        { id: 9, value: 9, isChecked: false, isMatched: false },18        { id: 10, value: 10, isChecked: false, isMatched: false },19        { id: 11, value: 11, isChecked: false, isMatched: false },20        { id: 12, value: 12, isChecked: false, isMatched: false },21        { id: 13, value: 13, isChecked: false, isMatched: false },22        { id: 14, value: 14, isChecked: false, isMatched: false },23        { id: 15, value: 15, isChecked: false, isMatched: false },24        { id: 16, value: 16, isChecked: false, isMatched: false },25        { id: 17, value: 17, isChecked: false, isMatched: false },26        { id: 18, value: 18, isChecked: false, isMatched: false },27        { id: 19, value: 19, isChecked: false, isMatched: false },28        { id: 20, value: 20, isChecked: false, isMatched: false },29        { id: 21, value: 21, isChecked: false, isMatched: false },30        { id: 22, value: 22, isChecked: false, isMatched: false },31        { id: 23, value: 23, isChecked: false, isMatched: false },32        { id: 24, value: 24, isChecked: false, isMatched: false },33        { id: 25, value: 25, isChecked: false, isMatched: false },34      ],35      number3x3: [36        { id: 1, value: 1, isChecked: false, isMatched: false },37        { id: 2, value: 2, isChecked: false, isMatched: false },38        { id: 3, value: 3, isChecked: false, isMatched: false },39        { id: 4, value: 4, isChecked: false, isMatched: false },40        { id: 5, value: 5, isChecked: false, isMatched: false },41        { id: 6, value: 6, isChecked: false, isMatched: false },42        { id: 7, value: 7, isChecked: false, isMatched: false },43        { id: 8, value: 8, isChecked: false, isMatched: false },44        { id: 9, value: 9, isChecked: false, isMatched: false },45      ],46      number4x4: [47        { id: 1, value: 1, isChecked: false, isMatched: false },48        { id: 2, value: 2, isChecked: false, isMatched: false },49        { id: 3, value: 3, isChecked: false, isMatched: false },50        { id: 4, value: 4, isChecked: false, isMatched: false },51        { id: 5, value: 5, isChecked: false, isMatched: false },52        { id: 6, value: 6, isChecked: false, isMatched: false },53        { id: 7, value: 7, isChecked: false, isMatched: false },54        { id: 8, value: 8, isChecked: false, isMatched: false },55        { id: 9, value: 9, isChecked: false, isMatched: false },56        { id: 10, value: 10, isChecked: false, isMatched: false },57        { id: 11, value: 11, isChecked: false, isMatched: false },58        { id: 12, value: 12, isChecked: false, isMatched: false },59        { id: 13, value: 13, isChecked: false, isMatched: false },60        { id: 14, value: 14, isChecked: false, isMatched: false },61        { id: 15, value: 15, isChecked: false, isMatched: false },62        { id: 16, value: 16, isChecked: false, isMatched: false },63      ], 64      letter5x6: [65        { id: 1, value: 'A', isChecked: false, isMatched: false },66        { id: 2, value: 'B', isChecked: false, isMatched: false },67        { id: 3, value: 'C', isChecked: false, isMatched: false },68        { id: 4, value: 'D', isChecked: false, isMatched: false },69        { id: 5, value: 'E', isChecked: false, isMatched: false },70        { id: 6, value: 'F', isChecked: false, isMatched: false },71        { id: 7, value: 'G', isChecked: false, isMatched: false },72        { id: 8, value: 'H', isChecked: false, isMatched: false },73        { id: 9, value: 'I', isChecked: false, isMatched: false },74        { id: 10, value: 'J', isChecked: false, isMatched: false },75        { id: 11, value: 'K', isChecked: false, isMatched: false },76        { id: 12, value: 'L', isChecked: false, isMatched: false },77        { id: 13, value: 'M', isChecked: false, isMatched: false },78        { id: 14, value: 'N', isChecked: false, isMatched: false },79        { id: 15, value: 'O', isChecked: false, isMatched: false },80        { id: 16, value: 'P', isChecked: false, isMatched: false },81        { id: 17, value: 'Q', isChecked: false, isMatched: false },82        { id: 18, value: 'R', isChecked: false, isMatched: false },83        { id: 19, value: 'S', isChecked: false, isMatched: false },84        { id: 20, value: 'T', isChecked: false, isMatched: false },85        { id: 21, value: 'U', isChecked: false, isMatched: false },86        { id: 22, value: 'V', isChecked: false, isMatched: false },87        { id: 23, value: 'W', isChecked: false, isMatched: false },88        { id: 24, value: 'X', isChecked: false, isMatched: false },89        { id: 25, value: 'Y', isChecked: false, isMatched: false },90        { id: 26, value: 'Z', isChecked: false, isMatched: false },91      ], 92      zhcn5x6: [93        { id: 1, value: 'æ¥', isChecked: false, isMatched: false },94        { id: 2, value: 'ç
§', isChecked: false, isMatched: false },95        { id: 3, value: 'é¦', isChecked: false, isMatched: false },96        { id: 4, value: 'ç', isChecked: false, isMatched: false },97        { id: 5, value: 'ç', isChecked: false, isMatched: false },98        { id: 6, value: 'ç´«', isChecked: false, isMatched: false },99        { id: 7, value: 'ç', isChecked: false, isMatched: false },100        { id: 8, value: 'é¥', isChecked: false, isMatched: false },101        { id: 9, value: 'ç', isChecked: false, isMatched: false },102        { id: 10, value: 'ç', isChecked: false, isMatched: false },103        { id: 11, value: 'å¸', isChecked: false, isMatched: false },104        { id: 12, value: 'æ', isChecked: false, isMatched: false },105        { id: 13, value: 'å', isChecked: false, isMatched: false },106        { id: 14, value: 'å·', isChecked: false, isMatched: false },107        { id: 15, value: 'é£', isChecked: false, isMatched: false },108        { id: 16, value: 'æµ', isChecked: false, isMatched: false },109        { id: 17, value: 'ç´', isChecked: false, isMatched: false },110        { id: 18, value: 'ä¸', isChecked: false, isMatched: false },111        { id: 19, value: 'ä¸', isChecked: false, isMatched: false },112        { id: 20, value: 'å', isChecked: false, isMatched: false },113        { id: 21, value: 'å°º', isChecked: false, isMatched: false },114        { id: 22, value: 'ç', isChecked: false, isMatched: false },115        { id: 23, value: 'æ¯', isChecked: false, isMatched: false },116        { id: 24, value: 'é¶', isChecked: false, isMatched: false },117        { id: 25, value: 'æ²³', isChecked: false, isMatched: false },118        { id: 26, value: 'è½', isChecked: false, isMatched: false },119        { id: 27, value: 'ä¹', isChecked: false, isMatched: false },120        { id: 28, value: '天', isChecked: false, isMatched: false },121      ], 122    }123  },124  getters: {125    square3x3: (state) => {126      const shuffle = arr => arr.sort(() => 0.5 - Math.random())127      return shuffle(state.number3x3)128    },129130    square4x4: (state) => {131      const shuffle = arr => arr.sort(() => 0.5 - Math.random())132      return shuffle(state.number4x4)133    },134    square5x5N: (state) => {135      const shuffle = arr => arr.sort(() => 0.5 - Math.random())136      return shuffle(state.numbers5x5)137    },138    square5x6L: (state) => {139      const shuffle = arr => arr.sort(() => 0.5 - Math.random())140      return shuffle(state.letter5x6)141    },142    square5x6CN: (state) => {143      const shuffle = arr => arr.sort(() => 0.5 - Math.random())144      return shuffle(state.zhcn5x6)145    },146147  },148  actions: {149    handleClick() {150      this.isChecked = !this.isChecked151152    },153154  },
...video-game.functions.spec.ts
Source:video-game.functions.spec.ts  
1import { createDefaultVideoGameFilters, IVideoGameFilters } from '../video-game-listing';2import { IVideoGame } from './video-game.interface';3import {4  videoGameMatchesFavoritesFilter,5  videoGameMatchesPlatformFilter,6  videoGameMatchesSearchQuery7} from './video-game.functions';8describe('with Super Mario Odyssey', () => {9  let superMarioOdyssey: IVideoGame;10  beforeEach(() => {11    superMarioOdyssey = {12      id: '1',13      title: 'Super Mario Odyssey',14      description: 'description',15      platform: 'Nintendo Switch',16      youtubeUrl: 'youtube.com',17      favorite: false,18    };19  });20  describe('videoGameMatchesSearchQuery(superMarioOdyssey, "Super")', () => {21    it('returns true', () => {22      const isMatched = videoGameMatchesSearchQuery(superMarioOdyssey, 'Super');23      expect(isMatched).toEqual(true);24    });25  });26  describe('videoGameMatchesSearchQuery(superMarioOdyssey, "Zelda")', () => {27    it('returns false', () => {28      const isMatched = videoGameMatchesSearchQuery(superMarioOdyssey, 'Zelda');29      expect(isMatched).toEqual(false);30    });31  });32  describe('videoGameMatchesSearchQuery(superMarioOdyssey, "")', () => {33    it('returns true', () => {34      const isMatched = videoGameMatchesSearchQuery(superMarioOdyssey, '');35      expect(isMatched).toEqual(true);36    });37  });38  describe('videoGameMatchesSearchQuery(superMarioOdyssey, falsy)', () => {39    it('returns true', () => {40      const isMatched = videoGameMatchesSearchQuery(superMarioOdyssey, null);41      expect(isMatched).toEqual(true);42    });43  });44  describe('videoGameMatchesPlatformFilter(superMarioOdyssey, nintendoSwitch)', () => {45    it('returns true', () => {46      const nintendoSwitch: IVideoGameFilters = {47        ...createDefaultVideoGameFilters(),48        platform: 'Nintendo Switch',49      };50      const isMatched = videoGameMatchesPlatformFilter(superMarioOdyssey, nintendoSwitch);51      expect(isMatched).toEqual(true);52    });53  });54  describe('videoGameMatchesPlatformFilter(superMarioOdyssey, nintendoSwitch)', () => {55    it('returns true', () => {56      const nintendoSwitch: IVideoGameFilters = {57        ...createDefaultVideoGameFilters(),58        platform: 'Nintendo Switch',59      };60      const isMatched = videoGameMatchesPlatformFilter(superMarioOdyssey, nintendoSwitch);61      expect(isMatched).toEqual(true);62    });63  });64  describe('videoGameMatchesPlatformFilter(superMarioOdyssey, pc)', () => {65    it('returns false', () => {66      const pc: IVideoGameFilters = {67        ...createDefaultVideoGameFilters(),68        platform: 'PC',69      };70      const isMatched = videoGameMatchesPlatformFilter(superMarioOdyssey, pc);71      expect(isMatched).toEqual(false);72    });73  });74  describe('videoGameMatchesPlatformFilter(superMarioOdyssey, falsy)', () => {75    it('returns true', () => {76      const isMatched = videoGameMatchesPlatformFilter(superMarioOdyssey, null);77      expect(isMatched).toEqual(true);78    });79  });80  describe('and it is favourited', () => {81    beforeEach(() => {82      superMarioOdyssey = { ...superMarioOdyssey, favorite: true };83    });84    describe('videoGameMatchesFavoritesFilter(superMarioOdyssey, favorites:true)', () => {85      it('returns true', () => {86        const showFavorites: IVideoGameFilters = {87          ...createDefaultVideoGameFilters(),88          favorites: true,89        };90        const isMatched = videoGameMatchesFavoritesFilter(superMarioOdyssey, showFavorites);91        expect(isMatched).toEqual(true);92      });93    });94    describe('videoGameMatchesFavoritesFilter(superMarioOdyssey, favorites:false)', () => {95      it('returns true', () => {96        const showFavorites: IVideoGameFilters = {97          ...createDefaultVideoGameFilters(),98          favorites: false,99        };100        const isMatched = videoGameMatchesFavoritesFilter(superMarioOdyssey, showFavorites);101        expect(isMatched).toEqual(true);102      });103    });104  });105  describe('and it is not favourited', () => {106    beforeEach(() => {107      superMarioOdyssey = { ...superMarioOdyssey, favorite: false };108    });109    describe('videoGameMatchesFavoritesFilter(superMarioOdyssey, favorites:true)', () => {110      it('returns false', () => {111        const filters: IVideoGameFilters = {112          ...createDefaultVideoGameFilters(),113          favorites: true,114        };115        const isMatched = videoGameMatchesFavoritesFilter(superMarioOdyssey, filters);116        expect(isMatched).toEqual(false);117      });118    });119    describe('videoGameMatchesFavoritesFilter(superMarioOdyssey, favorites:false)', () => {120      it('returns true', () => {121        const filters: IVideoGameFilters = {122          ...createDefaultVideoGameFilters(),123          favorites: false,124        };125        const isMatched = videoGameMatchesFavoritesFilter(superMarioOdyssey, filters);126        expect(isMatched).toEqual(true);127      });128    });129  });130});131describe('when the game is falsy', () => {132  describe('videoGameMatchesSearchQuery(falsy, "Super")', () => {133    it('returns false', () => {134      const isMatched = videoGameMatchesSearchQuery(null, 'Super');135      expect(isMatched).toEqual(false);136    });137  });138  describe('videoGameMatchesPlatformFilter(falsy, "Nintendo Switch")', () => {139    const nintendoSwitch: IVideoGameFilters = {140      ...createDefaultVideoGameFilters(),141      platform: 'Nintendo Switch'142    };143    it('returns false', () => {144      const isMatched = videoGameMatchesPlatformFilter(null, nintendoSwitch);145      expect(isMatched).toEqual(false);146    });147  });...checker.py
Source:checker.py  
1import ROOT2file = ROOT.TFile.Open('test.root','read')3file.cd()4file.cd('sorter')5tree = ROOT.gDirectory.FindObjectAny('vertexTree')6failing_match = 07this_event    = -18myevents = {}9for event in tree :10#   if event.isfirst > 0.5 : continue11  evt        = event.evt12  onlvtxsize = event.onlvtxsize13  ntrk       = event.ntrk      14  ntrk5gev   = event.ntrk5gev  15  ntrk10gev  = event.ntrk10gev 16  cl         = event.cl        17  sumpt2     = event.sumpt2    18  ltpt       = event.ltpt      19  avesumpt   = event.avesumpt  20  isfirst    = event.isfirst21  ismatched  = event.ismatched22  23#   discr = -3.1327991846824776e-02 * sumpt2    + \24#            8.8394987781991623e-04 * ntrk      + \25#            5.7524818636658849e-04 * ntrk5gev  + \26#            1.3525466529345670e-02 * ntrk10gev + \27#            5.6848729864949356e-02 * ltpt      + \28#            1.6917675215048249e-05 * avesumpt 29#   discr =  8.8394987781991623e-04 * sumpt2    + \30#            5.7524818636658849e-04 * ntrk      + \31#            1.3525466529345670e-02 * ntrk5gev  + \32#            5.6848729864949356e-02 * ntrk10gev + \33#            1.6917675215048249e-05 * ltpt      + \34#           -5.6139379732648184e-05 * avesumpt 35#   discr =  8.7935450672209565e-04 * sumpt2    + \36#            3.6420911807874448e-04 * ntrk      + \37#            1.4202446017075245e-02 * ntrk5gev  + \38#            6.2321686696701580e-02 * ntrk10gev + \39#            1.6742885500209335e-05 * ltpt      + \40#           -5.4981590355099178e-05 * avesumpt 41#   print 3.8324663627255950e-04 * sumpt2, '\t', 2.4421095537881357e-04 *ntrk, '\t',6.3290404218937875e-03 * ntrk5gev, '\t', 2.8800916885034698e-02 *ntrk10gev42#   discr =  3.8324663627255950e-04 * sumpt2    + \43#            2.4421095537881357e-04 * ntrk      + \44#            6.3290404218937875e-03 * ntrk5gev  + \45#            2.8800916885034698e-02 * ntrk10gev 46#   discr =  3.8324663630406381e-04 * sumpt2             + \47#           -4.2916529418151064e-02 * ntrk               + \48#            4.3203073772384547e-02 * ntrk-ntrk5gev      + \49#            4.9415876361901409e-02 * ntrk5gev-ntrk10gev + \50#            7.8265682935863348e-02 * ntrk10gev 51  discr =  6.7857799012604862e-04 * sumpt2             + \52          -2.6500643043350961e-04 * ntrk               + \53          -2.4409283096776284e-06 * avesumpt 54#   discr = -1*discr55  56  if evt != this_event : 57    myevents.update({evt:{'disc':[],'ismatched':[],'sumpt2':[]}})58    myevents[evt]['disc'     ].append(discr)59    myevents[evt]['ismatched'].append(ismatched)60    myevents[evt]['sumpt2'   ].append(sumpt2)61  else : 62    myevents[evt]['disc'     ].append(discr)63    myevents[evt]['ismatched'].append(ismatched)64    myevents[evt]['sumpt2'   ].append(sumpt2)65  66  this_event = event.evt67import pdb ; pdb.set_trace()  68bad  = 069good = 070for event in myevents.keys() :71  try :72    if myevents[event]['ismatched'].index(1) == myevents[event]['disc'].index(max(myevents[event]['disc'])) : good += 173    else                                                                                                    : bad  += 174  except :75    bad += 176    77print 'tot ', len(myevents)78print 'good', good79print 'bad ', bad80import pdb ; pdb.set_trace()  81#   evt        = event.evt82#   onlvtxsize = event.onlvtxsize83#   ntrk       = event.ntrk      84#   ntrk5gev   = event.ntrk5gev  85#   ntrk10gev  = event.ntrk10gev 86#   cl         = event.cl        87#   sumpt2     = event.sumpt2    88#   ltpt       = event.ltpt      89#   avesumpt   = event.avesumpt  90# #   weigh      = event.weigh     91#   isfirst    = event.isfirst92#   ismatched  = event.ismatched93#   94# 95#   print evt96#   failing_match += 197# 98# 99# 100# 101# 102# 103# 104#   #print evt105#   #print discr,'\t\t',sumpt2,'\t\t',ismatched,'\t\t',isfirst106#   if evt != this_event :107#     print 'cazzo'108#     disc_dict = {}109#     disc_dict.update({ismatched:[discr,sumpt2]})110#   else :111#     disc_dict.update({ismatched:[discr,sumpt2]})112#   113#   import pdb ; pdb.set_trace()  114#   115#   this_event = evt116#     ...tiles.ts
Source:tiles.ts  
1// Store all possible tiles in an array of objects2// Each object has an unique name and a href to an image3export const TILES = [4  { name: 'stekepanne', src: './images/1.svg', image: null, isMatched: false },5  {6    name: 'hodetelefoner',7    src: './images/2.svg',8    image: null,9    isMatched: false,10  },11  { name: 'gulrot', src: './images/3.svg', image: null, isMatched: false },12  { name: 'pokal', src: './images/4.svg', image: null, isMatched: false },13  { name: 'gitar', src: './images/5.svg', image: null, isMatched: false },14  { name: 'snømann', src: './images/6.svg', image: null, isMatched: false },15  { name: 'gris', src: './images/7.svg', image: null, isMatched: false },16  { name: 'ugle', src: './images/8.svg', image: null, isMatched: false },17  { name: 'chaplin', src: './images/9.svg', image: null, isMatched: false },18  { name: 'kake', src: './images/10.svg', image: null, isMatched: false },19  { name: 'hamburger', src: './images/11.svg', image: null, isMatched: false },20  {21    name: 'gammel mann',22    src: './images/12.svg',23    image: null,24    isMatched: false,25  },26  { name: 'parasoll', src: './images/13.svg', image: null, isMatched: false },27  { name: 'palme', src: './images/14.svg', image: null, isMatched: false },28  { name: 'kuleramme', src: './images/15.svg', image: null, isMatched: false },29  { name: 'trekkspill', src: './images/16.svg', image: null, isMatched: false },30  { name: 'medalje', src: './images/17.svg', image: null, isMatched: false },31  { name: 'gondol', src: './images/18.svg', image: null, isMatched: false },32  { name: 'fly', src: './images/19.svg', image: null, isMatched: false },33  {34    name: 'vekkeklokke',35    src: './images/20.svg',36    image: null,37    isMatched: false,38  },39  {40    name: 'rom-monster',41    src: './images/21.svg',42    image: null,43    isMatched: false,44  },45  { name: 'romvesen', src: './images/22.svg', image: null, isMatched: false },46  { name: 'sykebil', src: './images/23.svg', image: null, isMatched: false },47  { name: 'anker', src: './images/24.svg', image: null, isMatched: false },48  { name: 'lastebil', src: './images/25.svg', image: null, isMatched: false },49  {50    name: 'forskrekket ansikt',51    src: './images/26.svg',52    image: null,53    isMatched: false,54  },55  { name: 'bil', src: './images/27.svg', image: null, isMatched: false },56  { name: 'avocado', src: './images/28.svg', image: null, isMatched: false },57  { name: 'øks', src: './images/29.svg', image: null, isMatched: false },58  { name: 'tåteflaske', src: './images/30.svg', image: null, isMatched: false },59  { name: 'baby', src: './images/31.svg', image: null, isMatched: false },60  {61    name: 'søppelbøtte',62    src: './images/32.svg',63    image: null,64    isMatched: false,65  },66  { name: 'hus', src: './images/33.svg', image: null, isMatched: false },67  { name: 'chili', src: './images/34.svg', image: null, isMatched: false },68  { name: 'tre', src: './images/35.svg', image: null, isMatched: false },69  { name: 'hjort', src: './images/36.svg', image: null, isMatched: false },70  { name: 'telefon', src: './images/37.svg', image: null, isMatched: false },...Using AI Code Generation
1var tracetest = require('./tracetest.js');2var trace = new tracetest();3console.log(trace.isMatched('a', 'a'));4console.log(trace.isMatched('a', 'b'));5console.log(trace.isMatched('a', 'c'));6console.log(trace.isMatched('a', 'd'));7console.log(trace.isMatched('a', 'e'));8console.log(trace.isMatched('a', 'f'));9console.log(trace.isMatched('a', 'g'));10console.log(trace.isMatched('a', 'h'));11console.log(trace.isMatched('a', 'i'));12console.log(trace.isMatched('a', 'j'));13console.log(trace.isMatched('a', 'k'));14console.log(trace.isMatched('a', 'l'));15console.log(trace.isMatched('a', 'm'));16console.log(trace.isMatched('a', 'n'));17console.log(trace.isMatched('a', 'o'));18console.log(trace.isMatched('a', 'p'));19console.log(trace.isMatched('a', 'q'));20console.log(trace.isMatched('a', 'r'));21console.log(trace.isMatched('a', 's'));22console.log(trace.isMatched('a', 't'));23console.log(trace.isMatched('a', 'u'));24console.log(trace.isMatched('a', 'v'));25console.log(trace.isMatched('a', 'w'));26console.log(trace.isMatched('a', 'x'));27console.log(trace.isMatched('a', 'y'));28console.log(trace.isMatched('a', 'z'));29console.log(trace.isMatched('a', 'aa'));30console.log(trace.isMatched('a', 'ab'));31console.log(trace.isMatched('a', 'ac'));32console.log(trace.isMatched('a', 'ad'));33console.log(trace.isMatched('a', 'ae'));34console.log(trace.isMatched('a', 'af'));35console.log(trace.isMatched('a', 'ag'));36console.log(trace.isMatched('a', 'ah'));37console.log(trace.isMatched('a', 'ai'));38console.log(trace.isMatched('a', 'aj'));39console.log(trace.isMatched('a', 'ak'));40console.log(trace.isMatched('a', 'al'));41console.log(trace.isMatched('a', 'am'));42console.log(trace.isMatched('a', 'Using AI Code Generation
1var tracetest = require('./tracetest');2console.log(tracetest.isMatched('a','a'));3exports.isMatched = function(a,b){4    return a === b;5};6var tracetest = require('./tracetest');7console.log(tracetest.isMatched('a','a'));8module.exports.isMatched = function(a,b){9    return a === b;10};11var tracetest = require('./tracetest');12console.log(tracetest.isMatched('a','a'));13exports.isMatched = function(a,b){14    return a === b;15};16var tracetest = require('./tracetest');17console.log(tracetest.isMatched('a','a'));18exports.isMatched = function(a,b){19    return a === b;20};21var tracetest = require('./tracetest');22console.log(tracetest.isMatched('a','a'));23exports.isMatched = function(a,b){24    return a === b;25};26var tracetest = require('./tracetest');27console.log(tracetest.isMatched('Using AI Code Generation
1var trace = require('./tracetest.js');2var result = trace.isMatched('test','test');3console.log(result);4function isMatched(str1,str2){5    if(str1 == str2){6        return true;7    }8    else{9        return false;10    }11}12module.exports.isMatched = isMatched;13var trace = require('C:\Users\test\tracetest.js');14var result = trace.isMatched('test','test');15console.log(result);16var path = require('path');17var trace = require(path.join(__dirname, 'tracetest.js'));18var result = trace.isMatched('test','test');19console.log(result);Using AI Code Generation
1var traceTest = require('./tracetest');2var trace = new traceTest();3trace.isMatched('test', 'test');4var traceTest = function() {5    this.isMatched = function (name, testName) {6        if (name === testName) {7            console.log('matched');8        } else {9            console.log('not matched');10        }11    }12}13module.exports = traceTest;14    this.isMatched = function (name, testName) {15var trace = new traceTest();16var traceTest = function() { ... }17var traceTest = function() { ... }18var trace = new traceTest();19var traceTest = function() { ... }20module.exports = traceTest;21var trace = new traceTest();Using AI Code Generation
1var traceTest = require('./tracetest.js');2var trace = new traceTest.TraceTest();3trace.isMatched("abc","ab*");4function TraceTest() {5  this.isMatched = function (string, pattern) {6  }7}8exports.TraceTest = TraceTest;9exports.isMatched = function (string, pattern) {10}Using AI Code Generation
1var trace = require('./tracetest.js');2var trace1 = new trace.Trace();3trace1.isMatched('abcde','ab?de');4trace1.isMatched('abcde','ab*de');5var trace = require('./tracetest.js');6var trace1 = new trace.Trace();7trace1.isMatched('abcde','ab?de');8trace1.isMatched('abcde','ab*de');9var trace = require('./tracetest.js');10var trace1 = new trace.Trace();11trace1.isMatched('abcde','ab?de');12trace1.isMatched('abcde','ab*de');13var trace = require('./tracetest.js');14var trace1 = new trace.Trace();15trace1.isMatched('abcde','ab?de');16trace1.isMatched('abcde','ab*de');17var trace = require('./tracetest.js');18var trace1 = new trace.Trace();19trace1.isMatched('abcde','ab?de');20trace1.isMatched('abcde','ab*de');21var trace = require('./tracetest.js');22var trace1 = new trace.Trace();23trace1.isMatched('abcde','ab?de');24trace1.isMatched('abcde','ab*de');25var trace = require('./tracetest.js');26var trace1 = new trace.Trace();27trace1.isMatched('abcde','ab?de');28trace1.isMatched('abcde','ab*de');29var trace = require('./tracetest.js');30var trace1 = new trace.Trace();31trace1.isMatched('abcde','ab?de');32trace1.isMatched('abcde','ab*de');33var trace = require('./tracetest.js');34var trace1 = new trace.Trace();35trace1.isMatched('abcde','ab?de');Using AI Code Generation
1var tracetest = require('./tracetest.js');2var trace = new tracetest();3trace.isMatched('test.js', 'test.js', 'test.js');4I'm trying to write a test that checks if a function is called with a specific argument. I'm using Mocha with Chai for my testing. I've tried using sinon.spy() but I'm not sure if that's the right way to go about it. Here's the code:5function add(a, b) {6    return a + b;7}8describe('add()', function() {9    it('should add two numbers', function() {10        expect(add(2, 3)).to.equal(5);11    });12});13describe('add()', function() {14    it('should add two numbers', function() {15        var spy = sinon.spy(add);16        spy(2, 3);17        expect(spy.calledWith(2, 3)).to.equal(true);18    });19});20function getResults() {21    var deferred = Q.defer();22    setTimeout(function() {23        deferred.resolve('test');24    }, 1000);25    return deferred.promise;26}27describe('getResults()', function() {28    it('should return a promise', function() {29        expect(getResults()).to.be.a('promise');30    });31});32function getResults() {33    var deferred = Q.defer();34    setTimeout(function() {35        deferred.resolve('test');36    }, 1000);37    return deferred.promise;38}39describe('getResults()', function() {40    it('should return a promise', function() {Using AI Code Generation
1const tracetest = require("./tracetest");2let pattern = "a*";3let string = "aa";4let result = tracetest.isMatched(string, pattern);5console.log(result);6const tracetest = require("./tracetest");7let pattern = "a*";8let string = "aa";9let result = tracetest.printAllMatches(string, pattern);10console.log(result);Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
