Best Python code snippet using pyresttest_python
test1.py
Source:test1.py
1import idx2numpy2from matplotlib import pyplot as plt3import numpy as np4#konwersja5ndar=idx2numpy.convert_from_file('t10k-labels.idx1-ubyte')6ndarr=idx2numpy.convert_from_file('t10k-images.idx3-ubyte')7ndarr_flatten = []8#print(ndarr[0])9for i in range(len(ndarr)):10 ndarr_flatten.append(ndarr[i].flatten())11#print((ndar[0]))12#print(ndarr[0]/255)13#print(ndarr_flatten[0])14train_dataset = idx2numpy.convert_from_file('train-images.idx3-ubyte')15train_values = idx2numpy.convert_from_file('train-labels.idx1-ubyte')16test_dataset = idx2numpy.convert_from_file('t10k-images.idx3-ubyte')17test_values = idx2numpy.convert_from_file('t10k-labels.idx1-ubyte')18x_train = train_dataset[:]19y = np.zeros(train_values.shape)20print(x_train[0])21def convert_datasets(train, test):22 test_flatten23 print(train_flatten)24 #train_flatten = train[0].flatten()25 test_flatten = test[0].flatten()26 for i in range(len(train)):27 # var = train[i] / 25528 # train_flatten.append(var.flatten())29 train_flatten = np.append(train_flatten, train[i].flatten())30 #for i in range(len(test)):31 # var = test[i] / 25532 #test_flatten.append(var.flatten())33 np.append(test_flatten, var.flatten(), axis=0)34 return train_flatten, test_flatten35#train_v, test_v = convert_datasets(train_dataset, test_dataset)36#print(test_v)37#print(train_v)38#print(np.zeros(10))39#wyswietlanie40#pixels = train_v[1].reshape((28, 28))41#plt.imshow(pixels, cmap='gray')...
01-recursion-sol.py
Source:01-recursion-sol.py
...13 if n <= 1:14 return 115 else:16 return n * factorial(n-1)17def test_flatten():18 assert flatten([1, 2, [3], [4, 5]]) == [1, 2, 3, 4, 5]19 assert flatten([1, 2, (3, 4), "welcome"]) == [1, 2, (3, 4), "welcome"]20def test_factorial():21 assert factorial(1) == 122 assert factorial(-1) == 123 assert factorial(5) == 12024def test():25 print("test_flatten")26 test_flatten()27 print("test_factorial")28 test_factorial()29def main():30 pass31if __name__ == "__main__":32 if 'test' in sys.argv:33 test()34 exit(0)...
tests.py
Source:tests.py
1from solution import flatten2def test_flatten():3 assert flatten([]) == []4 assert flatten([5 1,6 2,7 [3, 5],8 [[4, 3], 2],9 ]) == [1, 2, 3, 5, 4, 3, 2]10 assert flatten([11 [1, [5], [], [[-3, 'hi']]],12 'string',13 10,14 [[[5]]],15 ]) == [1, 5, -3, 'hi', 'string', 10, 5]16 assert flatten([17 1,18 2,19 {'a': 1},20 [3, 5],21 2,22 ]) == [1, 2, {'a': 1}, 3, 5, 2]23 print('test_flatten is Ok!')...
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!!