How to use step_test method in autotest

Best Python code snippet using autotest_python

LengthTesting.py

Source: LengthTesting.py Github

copy

Full Screen

1import random2import numpy as np3import matplotlib.pyplot as plt4import timeit5678from string import ascii_lowercase9101112def plotter(r_k_time, b_f_time, kmp_time, time, filename):13 '''14 plots using information based on time15 '''16 plt.title(f'Complexity Analysis when m = 500')17 plt.plot(time, b_f_time, label="Brute Force")18 plt.plot(time, r_k_time,19 'tab:orange', label="Rabin Karp")20 plt.plot(time, kmp_time21 , 'tab:green', label="KMP")22 plt.xlabel("n")23 plt.ylabel('time in seconds')24 plt.legend()2526 plt.plot()27 plt.savefig(f"{filename}.png")28 print("plotted")293031def get_random_string(length, letters):32 '''33 Generates random string of length length using letters34 '''35 result_str = ''.join(random.choice(letters) for i in range(length))36 return result_str373839def insert(source_str, insert_str, pos):40 '''41 Fits a string into another string and results in a new string42 '''43 return source_str[:pos]+insert_str+source_str[pos:]4445start_test,end_test,step_test = 5000,1000001,500046times = list(range(start_test,end_test,step_test))4748b_f_temp = list(range(start_test,end_test,step_test))49r_k_temp = list(range(start_test,end_test,step_test))50kmp_temp = list(range(start_test,end_test,step_test))5152for i,n in enumerate(range(start_test,end_test,step_test)):53 pattern = get_random_string(500,ascii_lowercase)54 string_to_search = get_random_string(n-len(pattern), ascii_lowercase)55 string_to_search = insert(56 string_to_search, pattern, random.randint(0, len(string_to_search)-1))57 a = timeit.timeit(stmt="NaiveAlgorithm(pattern,text)",58 setup=f"from BruteForce import NaiveAlgorithm;text='{string_to_search}';pattern='{pattern}';", number=3)59 60 b = timeit.timeit(stmt=f"RabinKarp(pattern,text,524287)",61 setup=f"from RabinKarp import RabinKarp;text='{string_to_search}';pattern='{pattern}';", number=3)62 63 c = timeit.timeit(stmt="KMP_search(pattern,text)",64 setup=f"from Knuth import KMP_search;text='{string_to_search}';pattern='{pattern}';", number=3)65 b_f_temp[i] = a/​366 r_k_temp[i] = b/​367 kmp_temp[i] = c/​368 import time69 if n % 100 == 0:70 print(n)71print("done") ...

Full Screen

Full Screen

test_cnn.py

Source: test_cnn.py Github

copy

Full Screen

1# file: test.py2#3# Restores a learned CNN model and tests it.4#5# Store your test images in a sub-folder for each6# class in <dataset_root>/​validation/​7# e.g.8# <dataset_root>/​validation/​bikes9# <dataset_root>/​validation/​cars10# 11# ---12# Prof. Dr. Juergen Brauer, www.juergenbrauer.org13from dataset_reader import dataset14dataset_root = "V:/​01_job/​12_datasets/​imagenet/​cars_vs_bikes_prepared/​"15testing = dataset(dataset_root + "validation", ".jpeg")16import tensorflow as tf17import numpy as np18# Parameters19batch_size = 120ckpt = tf.train.get_checkpoint_state("saved_model_exp03")21saver = tf.train.import_meta_graph(ckpt.model_checkpoint_path + '.meta')22pred = tf.get_collection("pred")[0]23x = tf.get_collection("x")[0]24keep_prob = tf.get_collection("keep_prob")[0]25sess = tf.Session()26saver.restore(sess, ckpt.model_checkpoint_path)27# test28step_test = 029correct=030while step_test * batch_size < len(testing):31 # testing_ys and testing_xs are tuples32 testing_ys, testing_xs = testing.nextBatch(batch_size)33 # get first image and first ground truth vector34 # from the tuples35 first_img = testing_xs[0]36 first_groundtruth_vec = testing_ys[0]37 # at first iteration:38 # show shape of image and ground truth vector39 if step_test == 0:40 print("Shape of testing_xs is :", first_img.shape)41 print("Shape of testing_ys is :", first_groundtruth_vec.shape)42 # given the input image,43 # let the CNN predict the category!44 predict = sess.run(pred, feed_dict={x: testing_xs, keep_prob: 1.})45 # get ground truth label and46 # predicted label from output vector47 groundtruth_label = np.argmax(first_groundtruth_vec)48 predicted_label = np.argmax(predict, 1)[0]49 print("\nImage test: ", step_test)50 print("Ground truth label :", testing.label2category[groundtruth_label])51 print("Label predicted by CNN:", testing.label2category[predicted_label])52 if predicted_label == groundtruth_label:53 correct+=154 step_test += 155print("\n---")56print("Classified", correct, "images correct of", step_test,"in total.")...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

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