Best Python code snippet using hypothesis
LinProgramming.py
Source:LinProgramming.py
...76 if self.test_optimal() == 1:77 print("you have reached the optimal Tabular")78 print(str(self.step) + " steps were taken")79 break80 if self.test_unbounded() == 1:81 print("This Problem Is Unbounded")82 print("step reached: " + str(self.step))83 break84 if self.test_infeasible() == 1:85 print("This problem is infeasible")86 print("step reached: " + str(self.step))87 break88 rhs_j = self.prog.tab0.shape[1] - 189 for i, rhs_i in zip(self.prog.B, range(self.prog.B.size)):90 self.solution[int(i)] = self.prog.tab0[rhs_i, rhs_j]91 self.objective = self.prog.tab0[self.prog.tab0.shape[0] - 1, self.prog.tab0.shape[1] - 1]92 def jordan_exchange(self):93 self.prog.get_pivot()94 self.prog.update_col()95 self.prog.update_row()96 self.prog.update_rest()97 self.prog.tab0 = copy.copy(self.prog.tab1)98 self.prog.tab1[0:-1, 0:-1] = 099 self.step += 1100 def test_unbounded(self):101 for i in range(self.prog.tab0.shape[1] - 1):102 if sum(v >= 0 for v in self.prog.tab0[:, i]) == self.prog.tab0.shape[0]:103 return 1104 def test_optimal(self):105 tab = self.prog.tab0106 obj_arr = tab[-1:, :][0, :]107 rhs_arr = tab[:, self.prog.n_V - 1]108 if sum(n > 0 for n in obj_arr[:-1]) == 0:109 if sum(n < 0 for n in rhs_arr) == 0:110 return 1111 else:112 return 0113 def test_infeasible(self):114 tab = self.prog.tab1...
test_exact.py
Source:test_exact.py
...8 [[0.5, 0.5], [1, 0.5], [0, 1]], dtype=np.float329 )10 self.y_train = np.array([1, 1, 0], dtype=np.int)11 self.x_eval = np.array([0, 0], dtype=np.float)12 def test_unbounded(self):13 solver = ExactSolver(14 self.X_train, self.y_train,15 QpSolverFactory().create('gcd'), 1, False16 )17 perturbation = solver(self.x_eval)18 self.assertTrue(19 np.allclose(20 perturbation,21 np.array([-0.25, 0.25], dtype=self.X_train.dtype)22 )23 )24 self.assertEqual(25 perturbation.dtype, self.X_train.dtype26 )...
test_box.py
Source:test_box.py
1import numpy as np2import psdr3def test_unbounded(m = 5):4 dom = psdr.BoxDomain(-np.inf*np.ones(m), np.inf*np.ones(m))5 assert dom.is_unbounded == True6 7 dom = psdr.BoxDomain(-np.ones(m), np.ones(m))8 assert dom.is_unbounded == False9def test_point(m = 5):10 dom = psdr.BoxDomain(np.ones(m), np.ones(m))11 assert dom.is_point == True12 13 dom = psdr.BoxDomain(-np.ones(m), np.ones(m))...
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!!