Best Python code snippet using hypothesis
testDFS.py
Source: testDFS.py
1import unittest2import DFS3location = '/Users/faiyamrahman/Desktop/personal improvement/' \4 +'make_ money/programming/Design and Analysis of Algorithms I/SCC.txt'5x = DFS.Graph(location)6class TestDFS(unittest.TestCase):7## def setUp(self):8## self.location_DRone = '/Users/faiyamrahman/Desktop/personal improvement/' \9## +'make_ money/programming/Design and Analysis of Algorithms I/DRone.txt'10## self.location_DRtwo = '/Users/faiyamrahman/Desktop/personal improvement/' \11## +'make_ money/programming/Design and Analysis of Algorithms I/DRtwo.txt'12## self.location_DRthree = '/Users/faiyamrahman/Desktop/personal improvement/' \13## +'make_ money/programming/Design and Analysis of Algorithms I/DRthree.txt'14## self.location_DRfour = '/Users/faiyamrahman/Desktop/personal improvement/' \15## +'make_ money/programming/Design and Analysis of Algorithms I/DRfour.txt'16## self.location_DRfive = '/Users/faiyamrahman/Desktop/personal improvement/' \17## +'make_ money/programming/Design and Analysis of Algorithms I/DRfive.txt'18## self.location_DRsix = '/Users/faiyamrahman/Desktop/personal improvement/' \19## +'make_ money/programming/Design and Analysis of Algorithms I/DRsix.txt'20## self.location_DRseven = '/Users/faiyamrahman/Desktop/personal improvement/' \21## +'make_ money/programming/Design and Analysis of Algorithms I/DRseven.txt'22## self.location_DReight= '/Users/faiyamrahman/Desktop/personal improvement/' \23## +'make_ money/programming/Design and Analysis of Algorithms I/DReight.txt'24## self.location_DRnine= '/Users/faiyamrahman/Desktop/personal improvement/' \25## +'make_ money/programming/Design and Analysis of Algorithms I/DRnine.txt'26## self.location_DRten= '/Users/faiyamrahman/Desktop/personal improvement/' \27## +'make_ money/programming/Design and Analysis of Algorithms I/DRten.txt'28## self.location_HW= '/Users/faiyamrahman/Desktop/personal improvement/' \29## +'make_ money/programming/Design and Analysis of Algorithms I/SCC.txt'30## self.G1 = DFS.Graph(self.location_DRone)31## self.G2 = DFS.Graph(self.location_DRtwo)32## self.G3 = DFS.Graph(self.location_DRthree)33## self.G4 = DFS.Graph(self.location_DRfour)34## self.G5 = DFS.Graph(self.location_DRfive)35## self.G6 = DFS.Graph(self.location_DRsix)36## self.G7 = DFS.Graph(self.location_DRseven)37## self.G8 = DFS.Graph(self.location_DReight)38## self.G9 = DFS.Graph(self.location_DRnine)39## self.G10 = DFS.Graph(self.location_DRten)40## def test_getDRG_one(self):41## expected = (4,[[2,3],[4],[4],[2]])42## test = DFS.getDirGraph(self.location_DRone)43## self.assertEqual(expected,test)44##45## def test_getDRF_two(self):46## expected = (10,[[3],[1,4],[2,6],[5,6],[6],[7,10],[8],[4,9],[7],[9]])47## test = DFS.getDirGraph(self.location_DRtwo)48## self.assertEqual(expected,test)49## 50## def test_getDRF_three(self):51## expected = (10,[[3],[1,4],[2,6],[5,6],[],[7,10],[8],[4,9],[7],[9]])52## test = DFS.getDirGraph(self.location_DRthree)53## self.assertEqual(expected,test)54##55## def test_topSort_one(self):56## expected = [[1,2,3,4],[1,3,2,4]]57## test = DFS.TopSort(self.G1)58## self.assertTrue(test in expected)59 def test_FindSCCs_HW(self):60 expected = [434821,968,459,313,211]61 test = DFS.FindSCCs(x)[:5]62 self.assertEqual(expected,test)63## def test_FindSCCs_one(self):64## expected = [2,1,1]65## test = DFS.FindSCCs(self.G1)66## self.assertEqual(expected,test)67##68## def test_FindSCCs_two(self):69## expected = [7,3]70## test = DFS.FindSCCs(self.G2)71## self.assertEqual(expected,test)72##73## def test_FindSCCs_three(self):74## expected = [6,3,1]75## test = DFS.FindSCCs(self.G3)76## self.assertEqual(expected,test)77##78## def test_FindSCCs_four(self):79## expected = [3,3,3]80## test = DFS.FindSCCs(self.G4)81## self.assertEqual(expected,test)82##83## def test_FindSCCs_five(self):84## expected = [3,3,2]85## test = DFS.FindSCCs(self.G5)86## self.assertEqual(expected,test)87##88## def test_FindSCCs_six(self):89## expected = [3,3,1,1]90## test = DFS.FindSCCs(self.G6)91## self.assertEqual(expected,test)92##93## def test_FindSCCs_seven(self):94## expected = [7,1]95## test = DFS.FindSCCs(self.G7)96## self.assertEqual(expected,test)97##98## def test_FindSCCs_eight(self):99## expected = [6,3,2,1]100## test = DFS.FindSCCs(self.G8)101## self.assertEqual(expected,test)102##103## def test_FindSCCs_nine(self):104## expected = [6,1,1,1,1,1,1,1,1]105## test = DFS.FindSCCs(self.G9)106## self.assertEqual(expected,test)107##108## def test_FindSCCs_ten(self):109## expected = [3,2,2,2,1,1]110## test = DFS.FindSCCs(self.G10)111## self.assertEqual(expected,test)112##113##114## def test_graphReverse_one(self):115## """116## Check that both the adjacency list representation of the graph117## has reversed and that the individual vertices have updated their edges118## """119## expectedGraph = [[],[1,4],[1],[2,3]]120## self.G1.selfReverse()121## self.assertEqual(expectedGraph,self.G1.getGraph())122## for i in range(0,4):123## self.assertEqual(expectedGraph[i],self.G1.getVertices()[i].getEdges())124##125## def test_graphReverse_two(self):126## """127## Same as above, except for G2128## """129## expectedGraph = [[2],[3],[1],[2,8],[4],[3,4,5],[6,9],[7],[8,10],[6]]130## self.G2.selfReverse()131## self.assertEqual(expectedGraph,self.G2.getGraph())132## for i in range(0,10):133## self.assertEqual(expectedGraph[i],self.G2.getVertices()[i].getEdges())134 135suite = unittest.TestLoader().loadTestsFromTestCase(TestDFS)...
config.py
Source: config.py
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT license.3import subprocess, os4import re5from antares.common import backend, AntaresGlobal6def to_search_space(ast_seq, input_dict, output_dict):7 from antares.default_codegen import codegen8 codegen(ast_seq, input_dict, output_dict, {}, space_only=True)9 space = AntaresGlobal.auto_config.get_config_space()10 return space11def to_kernel_slices(compute_graph, best_config):12 from antares.default_codegen import codegen13 return codegen(*compute_graph, best_config)14def get_execution_parallism():15 num_gpus = len(subprocess.getoutput('ls /dev/nvidia[0-9]* 2>/dev/null').split())16 num_gpus = num_gpus if num_gpus > 0 else 117 return num_gpus18def do_native_translation_v2(codeset, **kwargs):19 kernel_name, in_args, out_args, body = codeset20 expand_args = ', '.join([f'{x[0]}* __restrict__ {x[1]}' for x in in_args + out_args])21 if 'VAMAP' in os.environ:22 expand_args += ', ' + ', '.join([f'int {x.split(":")[0]}' for x in os.environ['VAMAP'].split(',')])23 def get_extent(key, defval=1):24 str_pat = f'// [thread_extent] {key} = '25 idx = body.find(str_pat)26 if idx >= 0:27 return int(body[idx+len(str_pat):body.index('\n', idx)])28 return defval29 launch_bounds = get_extent('threadIdx.x') * get_extent('threadIdx.y') * get_extent('threadIdx.z')30 cuda_linux_half = ''31 if '_win64' not in backend:32 cuda_linux_half += '\n__forceinline__ __device__ __half max(const __half &a, const __half &b) {{ return a > b ? a : b; }}'33 cuda_linux_half += '\n__forceinline__ __device__ __half min(const __half &a, const __half &b) {{ return a < b ? a : b; }}\n'34 full_body = f'''35#include <cuda_runtime.h>36#include <cuda_fp16.h>37#include <mma.h>38#ifndef __CUDA_COMMON_MACRO__39#define __CUDA_COMMON_MACRO__40#define __ITEM_0_OF__(v) (v).x41#define __ITEM_1_OF__(v) (v).y42#define __ITEM_2_OF__(v) (v).z43#define __ITEM_3_OF__(v) (v).w44#define __STORE_ITEM_0__(t, out, ido, in, idi) *(t*)(out + ido) = *(t*)(in + idi)45#define __STORE_ITEM_1__(t, out, ido, in, idi)46#define __STORE_ITEM_2__(t, out, ido, in, idi)47#define __STORE_ITEM_3__(t, out, ido, in, idi)48#define MAKE_VEC4_OP(type) \\49 __forceinline__ __device__ type operator+(const type &l, const type &r) {{ return make_##type(l.x + r.x, l.y + r.y, l.z + r.z, l.w + r.w); }} \\50 __forceinline__ __device__ type operator-(const type &l, const type &r) {{ return make_##type(l.x - r.x, l.y - r.y, l.z - r.z, l.w - r.w); }} \\51 __forceinline__ __device__ type operator*(const type &l, const type &r) {{ return make_##type(l.x * r.x, l.y * r.y, l.z * r.z, l.w * r.w); }} \\52 __forceinline__ __device__ type operator/(const type &l, const type &r) {{ return make_##type(l.x / r.x, l.y / r.y, l.z / r.z, l.w / r.w); }} \\53 __forceinline__ __device__ type operator%(const type &l, const type &r) {{ return make_##type(l.x % r.x, l.y % r.y, l.z % r.z, l.w % r.w); }}54#define MAKE_VEC2_OP(type) \\55 __forceinline__ __device__ type operator+(const type &l, const type &r) {{ return make_##type(l.x + r.x, l.y + r.y); }} \\56 __forceinline__ __device__ type operator-(const type &l, const type &r) {{ return make_##type(l.x - r.x, l.y - r.y); }} \\57 __forceinline__ __device__ type operator*(const type &l, const type &r) {{ return make_##type(l.x * r.x, l.y * r.y); }} \\58 __forceinline__ __device__ type operator/(const type &l, const type &r) {{ return make_##type(l.x / r.x, l.y / r.y); }} \\59 __forceinline__ __device__ type operator%(const type &l, const type &r) {{ return make_##type(l.x % r.x, l.y % r.y); }}60MAKE_VEC4_OP(int4)61MAKE_VEC2_OP(int2)62{cuda_linux_half}63#endif64{kwargs['attrs'].blend}65extern "C" __global__ __launch_bounds__({launch_bounds}) void {kernel_name}({expand_args}) {{66 {body}67}}68'''69 if kwargs['attrs'].backend.endswith('_win64'):70 full_body = re.sub(r'\bint64_t\b', '__int64', full_body)...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.
In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.
How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.
Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.
Mobile application development is on the rise like never before, and it proportionally invites the need to perform thorough testing with the right mobile testing strategies. The strategies majorly involve the usage of various mobile automation testing tools. Mobile testing tools help businesses automate their application testing and cut down the extra cost, time, and chances of human error.
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!!