Best Python code snippet using avocado_python
problem_unittests.py
Source: problem_unittests.py
1from copy import deepcopy2from unittest import mock3import tensorflow as tf4def test_safe(func):5 """6 Isolate tests7 """8 def func_wrapper(*args):9 with tf.Graph().as_default():10 result = func(*args)11 print('Tests Passed')12 return result13 return func_wrapper14def _assert_tensor_shape(tensor, shape, display_name):15 assert tf.assert_rank(tensor, len(shape), message='{} has wrong rank'.format(display_name))16 tensor_shape = tensor.get_shape().as_list() if len(shape) else []17 wrong_dimension = [ten_dim for ten_dim, cor_dim in zip(tensor_shape, shape)18 if cor_dim is not None and ten_dim != cor_dim]...
cython_example.py
Source: cython_example.py
...24ctypedef numpy.float64_t DTYPE_t25@cython.boundscheck(False)26@cython.cdivision(True)27@cython.wraparound(False)28def test_safe(double [::1] test, int num_threads):29 cdef int xmax = test.shape[0], ii, jj, mytid30 cdef double[:,:] blergh=numpy.zeros((num_threads,10))31 cdef double[:] blerghsum=numpy.zeros(10)32 with nogil, parallel(num_threads=num_threads):33 mytid = threadid()34 for ii in prange(0,xmax,schedule="static", chunksize=1):35 for jj in range(0,10):36 blergh[mytid,jj] += test[ii]37 return numpy.asarray(blergh).sum(axis=0)38data = numpy.ones(1000000)39%timeit test_unsafe(data,1)40%timeit test_unsafe(data,2)41%timeit test_unsafe(data,4)42%timeit test_unsafe(data,8)43%timeit test_safe(data,1)44%timeit test_safe(data,2)45%timeit test_safe(data,4)46%timeit test_safe(data,8)47testdata=numpy.array([2,3,5,7,11,13,17,19,23,31],dtype="f8")48res = test_safe(testdata,8)49print("We expect ", res)50ii = 051while True or ii<1000000:52 res2 = test_unsafe(testdata,2)53 ii = ii + 154 if numpy.allclose(res,res2):55 continue56 else:57 raise ValueError("WRONG", res2)58%%cython --compile-args=-Ofast --compile-args=-fopenmp --link-args=-fopenmp --link-args=-lgomp59import cython,numpy,os60from cython.parallel cimport prange, parallel, threadid61cimport numpy62DTYPE=numpy.float64...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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!!