How to use snuff method in autotest

Best Python code snippet using autotest_python

monthDistribution.py

Source:monthDistribution.py Github

copy

Full Screen

1import csv2import matplotlib.pyplot as plt3import numpy as np4import scipy.stats as stats5def countKey(key,listDataDicts):6 outDict = {}7 for row in listDataDicts:8 try:9 outDict[row[key]] += 110 except KeyError:11 outDict[row[key]] = 112 return outDict13listDataDicts = []14with open('34933-0001-Data.tsv', 'r') as tsvFile:15 tsvReader = csv.DictReader(tsvFile,delimiter='\t')16 for row in tsvReader:17 listDataDicts.append(row)18# Now looking at the drug first use on a per month basis19cigMonths = countKey("CIGMFU", listDataDicts)20snuffMonths = countKey("SNUFMFU", listDataDicts)21chewMonths = countKey("CHEWMFU", listDataDicts)22cigarMonths = countKey("CIGARMFU", listDataDicts)23alcMonths = countKey("ALCMFU", listDataDicts)24mjMonths = countKey("MJMFU", listDataDicts)25cocMonths = countKey("COCMFU", listDataDicts)26heroinMonths = countKey("HERMFU", listDataDicts)27halMonths = countKey("HALMFU", listDataDicts)28inhMonths = countKey("INHMFU", listDataDicts)29prMonths = countKey("ANALMFU", listDataDicts)30tranqMonths = countKey("TRANMFU", listDataDicts)31stimMonths = countKey("STIMMFU", listDataDicts)32sedMonths = countKey("SEDMFU", listDataDicts)33january = cigMonths["1"]+snuffMonths["1"]+chewMonths["1"]+cigarMonths["1"]+alcMonths["1"]+mjMonths["1"]+cocMonths["1"]+heroinMonths["1"]+halMonths["1"]+inhMonths["1"]+prMonths["1"]+tranqMonths["1"]+stimMonths["1"]+sedMonths["1"]34february = cigMonths["2"]+snuffMonths["2"]+chewMonths["2"]+cigarMonths["2"]+alcMonths["2"]+mjMonths["2"]+cocMonths["2"]+heroinMonths["2"]+halMonths["2"]+inhMonths["2"]+prMonths["2"]+tranqMonths["2"]+stimMonths["2"]+sedMonths["2"]35march = cigMonths["3"]+snuffMonths["3"]+chewMonths["3"]+cigarMonths["3"]+alcMonths["3"]+mjMonths["3"]+cocMonths["3"]+heroinMonths["3"]+halMonths["3"]+inhMonths["3"]+prMonths["3"]+tranqMonths["3"]+stimMonths["3"]+sedMonths["3"]36april = cigMonths["4"]+snuffMonths["4"]+chewMonths["4"]+cigarMonths["4"]+alcMonths["4"]+mjMonths["4"]+cocMonths["4"]+heroinMonths["4"]+halMonths["4"]+inhMonths["4"]+prMonths["4"]+tranqMonths["4"]+stimMonths["4"]+sedMonths["4"]37may = cigMonths["5"]+snuffMonths["5"]+chewMonths["5"]+cigarMonths["5"]+alcMonths["5"]+mjMonths["5"]+cocMonths["5"]+heroinMonths["5"]+halMonths["5"]+inhMonths["5"]+prMonths["5"]+tranqMonths["5"]+stimMonths["5"]+sedMonths["5"]38june = cigMonths["6"]+snuffMonths["6"]+chewMonths["6"]+cigarMonths["6"]+alcMonths["6"]+mjMonths["6"]+cocMonths["6"]+heroinMonths["6"]+halMonths["6"]+inhMonths["6"]+prMonths["6"]+tranqMonths["6"]+stimMonths["6"]+sedMonths["6"]39july = cigMonths["7"]+snuffMonths["7"]+chewMonths["7"]+cigarMonths["7"]+alcMonths["7"]+mjMonths["7"]+cocMonths["7"]+heroinMonths["7"]+halMonths["7"]+inhMonths["7"]+prMonths["7"]+tranqMonths["7"]+stimMonths["7"]+sedMonths["7"]40august = cigMonths["8"]+snuffMonths["8"]+chewMonths["8"]+cigarMonths["8"]+alcMonths["8"]+mjMonths["8"]+cocMonths["8"]+heroinMonths["8"]+halMonths["8"]+inhMonths["8"]+prMonths["8"]+tranqMonths["8"]+stimMonths["8"]+sedMonths["8"]41september = cigMonths["9"]+snuffMonths["9"]+chewMonths["9"]+cigarMonths["9"]+alcMonths["9"]+mjMonths["9"]+cocMonths["9"]+heroinMonths["9"]+halMonths["9"]+inhMonths["9"]+prMonths["9"]+tranqMonths["9"]+stimMonths["9"]+sedMonths["9"]42october = cigMonths["10"]+snuffMonths["10"]+chewMonths["10"]+cigarMonths["10"]+alcMonths["10"]+mjMonths["10"]+cocMonths["10"]+heroinMonths["10"]+halMonths["10"]+inhMonths["10"]+prMonths["10"]+tranqMonths["10"]+stimMonths["10"]+sedMonths["10"]43november = cigMonths["11"]+snuffMonths["11"]+chewMonths["11"]+cigarMonths["11"]+alcMonths["11"]+mjMonths["11"]+cocMonths["11"]+heroinMonths["11"]+halMonths["11"]+inhMonths["11"]+prMonths["11"]+tranqMonths["11"]+stimMonths["11"]+sedMonths["11"]44december = cigMonths["12"]+snuffMonths["12"]+chewMonths["12"]+cigarMonths["12"]+alcMonths["12"]+mjMonths["12"]+cocMonths["12"]+heroinMonths["12"]+halMonths["12"]+inhMonths["12"]+prMonths["12"]+tranqMonths["12"]+stimMonths["12"]+sedMonths["12"]45ydata = [january,february,march,april,may,june,july,august,september,october,november,december]46xLabels = ["January","February", "March","April","May", "June","July","August","September","October","November","December"]47#normalize the data48total = 049for month in ydata:50 total += month51normed = [x/total for x in ydata]52#KS-Test53D,pVal = stats.kstest(normed, 'uniform')54critVal = .0555if pVal< critVal :56 print "The data is statistically signficant (p < %0.4f) in its variation from the uniform distribution (Two Sided KS-Test, statistic = %f, p-value = %f)" %(critVal,D,pVal)57else:58 print "The data is not statistically signficant (p >= %0.4f) in its variation from the uniform distribution (Two Sided KS-Test, statistic = %f, p-value = %f)" %(critVal,D,pVal)59#Mann-Whitney U-Test60U,pVal2 = stats.mannwhitneyu(normed, stats.uniform.rvs(size=12))61if pVal2< critVal :62 print "\n The data is statistically signficant (p < %0.4f) in its variation from the uniform distribution (Two Sided Mann-Whitney U-Test, statistic = %f, p-value = %f) \n" %(critVal,U,2*pVal2)63else:64 print "The data is not statistically signficant (p >= %0.4f) in its variation from the uniform distribution (Two Sided Mann-Whitney U-Test, statistic = %f, p-value = %f) \n" %(critVal,U,2*pVal2)65plt.bar(range(len(ydata)), ydata)66plt.title("Month Popularity by Drug Use Inception")67plt.xlabel("Month")68plt.ylabel("Frequency of Drug Use Inception")69plt.xticks([x+.4 for x in range(len(xLabels))], xLabels)70plt.xticks(rotation=50)71plt.tight_layout()...

Full Screen

Full Screen

1_3_raise_exce_manually.py

Source:1_3_raise_exce_manually.py Github

copy

Full Screen

1try:2 amt = 10003 if amt < 5000:4 raise NameError("Snuff. Funds") # Raise exception manually5except NameError as name:6 print("AN EXCEPTION OCCURRED ::", name)7'''8In Java, below line is object creation9Java : NameError name = NameError("Snuff. Funds")10Python : name = NameError("Snuff. Funds") # Rem. all scenarios11 NameError name = NameError("Snuff. Funds") #Exception handling12'''13class BookNotAvailable(Exception):14 def __init__(self, book_Id):15 self.bookId = book_Id16def findBook(book_Id):17 print("finding book")18 raise BookNotAvailable(book_Id)19try:20 findBook(12345)21except BookNotAvailable as e:22 print("Book with id : {} is not available".format(e.bookId))23print("---------------------------------------------------------------------")24class SomethingIsWrong(BaseException):25 def __init__(self, reason):26 self.reason = reason27 def __str__(self):28 return self.reason29try:30 print('one')31 raise SomethingIsWrong('xyz')32except SomethingIsWrong as somethingWrong:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest 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