How to use resuilt method in pytest-benchmark

Best Python code snippet using pytest-benchmark

lab7.py

Source:lab7.py Github

copy

Full Screen

1import math2import matplotlib.pyplot as plt3def solve_dir(x):4 return 2 - 1 / (math.log(10) * x ** 2)5def solve(x):6 return x ** 2 + math.log10(x)7def integrate(x, m_i, m_next, h):8 return ((h / 2) * (solve(x) + solve(x + h))) - ((h ** 3 / 24) * (m_i + m_next))9def div(x, m_i, m_next, h):10 return (m_i + 6 / h * (x - (x + h)) * (11 (solve(x + h) - solve(x)) / h - (m_next - 2 * m_i) / 3) + 6 / h ** 2 * (12 x - (x + h)) ** 2 * ((m_next + m_i) / 2 - (solve(x + h) - solve(x)) / h))13a = 0.414b = 0.915n = 1116h = (b - a) / 1017segment = [a + h * i for i in range(11)]18gov = [solve(i) for i in segment]19# нижняя диагональ20diag_1i = [0.5 if i != 9 else 1 for i in range(11 - 1)]21diag_1i.insert(0, 0)22# главная диагональ23diag_i = [2 for _ in range(11)]24# верхняя диагональ25diag_i1 = [0.5 if i != 0 else 1 for i in range(11 - 1)]26diag_i1.append(0)27# вектор правой части28resuilt = []29for i in range(11):30 if i == 0:31 resuilt.append((3 / h) * (gov[i + 1] - gov[i]) - (h / 2) * solve_dir(segment[i]))32 elif i == 10:33 resuilt.append((h * solve_dir(segment[i]) / 2) + 3 * ((gov[i] - gov[i - 1]) / h))34 else:35 resuilt.append(30 * (gov[i + 1] - gov[i - 1]))36def solveMatrix(n, a, c, b, f):37 m = 038 x = [0 for i in range(n)]39 for i in range(1, n):40 m = a[i] / c[i - 1]41 c[i] = c[i] - m * b[i - 1]42 f[i] = f[i] - m * f[i - 1]43 x[n - 1] = f[n - 1] / c[n - 1]44 for i in range(n - 2, -1, -1):45 x[i] = (f[i] - b[i] * x[i + 1]) / c[i]46 return x47# пример48mi = solveMatrix(11, diag_1i, diag_i, diag_i1, resuilt)49def S(x, i):50 res = 051 a1 = 6 / h52 a2 = (gov[i + 1] - gov[i]) / h53 a3 = (mi[i + 1] + 2 * mi[i]) / 354 a4 = 12 * (x - segment[i]) / (h ** 2)55 a5 = (mi[i + 1] + mi[i]) / 256 a6 = (gov[i + 1] - gov[i]) / h57 res += a1 * (a2 - a3) + a4 * (a5 - a6)58 return res59govS2 = []60for j, i in enumerate(segment):61 if j == 10:62 j = 963 govS2.append(S(i, j))64govy2 = [solve_dir(i) for i in segment]65plt.plot(segment, govy2)66plt.plot(segment, govS2)67plt.legend(['Функция', 'Сплайн'], loc=2)...

Full Screen

Full Screen

work.py

Source:work.py Github

copy

Full Screen

1# -*- coding:utf8 -*-2"""3 使用本周学习的技术改造第二周的计算器实现,其目标如下:4 1. 运行后提示让用户输入一个数字5 2. 提示输入操作符(+ - * /)6 3. 再次提示输入一个数字7 4. 打印计算结果8 5. 在不退出程序的前提下,可以允许用户继续输入新一组数据计9 6. 尽可能改善用户体验(新需求)10"""11def Calculator(x, opt, y):12 if opt == "+":13 return x + y14 elif opt == "-":15 return x - y16 elif opt == "*":17 return x * y18 elif opt == "/":19 return x / y20 else:21 print("请正确输入")22while True:23 x = float(input("请输入数字: "))24 opt = input("请输入+,-,*,/: ")25 y = float(input("请输入数字: "))26 resuilt = Calculator(x, opt, y)...

Full Screen

Full Screen

Running_External_programs.py

Source:Running_External_programs.py Github

copy

Full Screen

1import subprocess2resuilt = subprocess.run(['ls','-l'])...

Full Screen

Full Screen

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 pytest-benchmark 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