Best Python code snippet using avocado_python
test_safeloader_core.py
Source:test_safeloader_core.py
...86# A level 0 library containing a base test class87L0_LIB = """88from avocado import Test89class BaseL0(Test):90 def test_l0(self):91 pass92"""93L1_LIB1 = """94from ..l0lib import BaseL095class BaseL1(BaseL0):96 def test_l1(self):97 pass98"""99L1_LIB2 = """100from .. import l0lib101class BaseL1(l0lib.BaseL0):102 def test_l1(self):103 pass104"""...
precomp_matrix_mnist.py
Source:precomp_matrix_mnist.py
1import os2import numpy as np3from util import load_data, ROOT_PATH,_sqdist4from sklearn.decomposition import PCA5def precomp(sname,i,seed=527):6 np.random.seed(seed)7 train, dev, test = load_data(ROOT_PATH+'/data/'+sname+'/main.npz',Torch=False)8 folder = ROOT_PATH+'/tmp/'9 os.makedirs(folder, exist_ok=True)10 if sname in ['mnist_z','mnist_xz']:11 M = int(train.z.shape[0]/400)12 train_K0 = _sqdist(train.z[i*M:(i+1)*M],train.z)13 dev_K0 = _sqdist(dev.z[i*M:(i+1)*M],dev.z)14 np.savez(folder+'{}_K_{}.npz'.format(sname,i),train_K0=train_K0, dev_K0 = dev_K0)15 16 if i < 8 and sname in ['mnist_x','mnist_xz']:17 pca = PCA(n_components=8)18 pca.fit(train.x)19 X = pca.transform(train.x)20 test_X = pca.transform(test.x)21 dev_X = pca.transform(dev.x)22 train_L0 = _sqdist(X[:,[i]],X[:,[i]])23 dev_L0 = _sqdist(dev_X[:,[i]],X[:,[i]])24 test_L0 = _sqdist(test_X[:,[i]],X[:,[i]])25 np.savez(folder+'{}_L_{}.npz'.format(sname,i),train_L0=train_L0, test_L0=test_L0, dev_L0 = dev_L0)26if __name__ == '__main__':27 for ind in range(400):28 for sname in ['mnist_z','mnist_x','mnist_xz']:29 precomp(sname,ind)30 folder = ROOT_PATH+'/mnist_precomp/'31 os.makedirs(folder, exist_ok=True)32 for sname in ['mnist_z','mnist_x','mnist_xz']:33 if sname in ['mnist_z','mnist_xz']:34 train_K0 = []35 dev_K0 = []36 for w_id in range(400):37 res = np.load(ROOT_PATH+'/tmp/{}_K_{}.npz'.format(sname,w_id))38 os.remove(ROOT_PATH+'/tmp/{}_K_{}.npz'.format(sname,w_id))39 train_K0 += [res['train_K0']]40 dev_K0 += [res['dev_K0']]41 train_K0 = np.vstack(train_K0)42 dev_K0 = np.vstack(dev_K0)43 np.save(folder+'{}_train_K0.npy'.format(sname), train_K0)44 np.save(folder+'{}_dev_K0.npy'.format(sname), dev_K0)45 dist = np.sqrt(train_K0)46 a = np.median(dist.flatten())47 np.save(folder+'{}_ak.npy'.format(sname), a)48 49 if sname in ['mnist_x','mnist_xz']:50 train_L0 = []51 test_L0 = []52 for i in range(8):53 L0 = np.load(ROOT_PATH+'/tmp/{}_L_{}.npz'.format(sname,i))54 os.remove(ROOT_PATH + '/tmp/{}_L_{}.npz'.format(sname,i))55 train_L0 += [L0['train_L0']]56 test_L0 += [L0['test_L0']]57 np.savez(folder+'{}_Ls.npz'.format(sname),train_L0=train_L0, test_L0=test_L0)...
wsgi.py
Source:wsgi.py
1"""2WSGI config for test_l0 project.3It exposes the WSGI callable as a module-level variable named ``application``.4For more information on this file, see5https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/6"""7import os8from django.core.wsgi import get_wsgi_application9os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_l0.settings')...
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!!