Best Python code snippet using autotest_python
sparse_table_test.py
Source: sparse_table_test.py
...6 def test_min(self) -> None:7 a = [3, 1, 2, 10, -1]8 semigroup = dsalgo.algebraic_structure.Semigroup[int](min)9 get_min = dsalgo.sparse_table.sparse_table(semigroup, a)10 self.assertEqual(get_min(0, 5), -1)11 self.assertEqual(get_min(0, 1), 3)12 self.assertEqual(get_min(0, 3), 1)13class TestDisjointSparseTable(unittest.TestCase):14 def test_min(self) -> None:15 a = [3, 1, 2, 10, -1]16 semigroup = dsalgo.algebraic_structure.Semigroup[int](min)17 get_min = dsalgo.sparse_table.disjoint_sparse_table(semigroup, a)18 self.assertEqual(get_min(0, 5), -1)19 self.assertEqual(get_min(0, 1), 3)20 self.assertEqual(get_min(0, 3), 1)21 def test_sum(self) -> None:22 a = [3, 1, 2, 10, -1]23 semigroup = dsalgo.algebraic_structure.Semigroup[int](operator.add)24 get_sum = dsalgo.sparse_table.disjoint_sparse_table(semigroup, a)25 self.assertEqual(get_sum(0, 5), 15)26 self.assertEqual(get_sum(0, 1), 3)27 self.assertEqual(get_sum(0, 3), 6)28 def test_xor(self) -> None:29 a = [3, 1, 2, 10, 0]30 semigroup = dsalgo.algebraic_structure.Semigroup[int](operator.xor)31 get_xor = dsalgo.sparse_table.disjoint_sparse_table(semigroup, a)32 self.assertEqual(get_xor(0, 5), 10)33 self.assertEqual(get_xor(0, 1), 3)34 self.assertEqual(get_xor(0, 3), 0)35class TestDisjointSparseTableIntXor(unittest.TestCase):36 def test(self) -> None:37 a = [3, 1, 2, 10, 0]38 get_xor = dsalgo.sparse_table.disjoint_sparse_table_int_xor(a)39 self.assertEqual(get_xor(0, 5), 10)40 self.assertEqual(get_xor(0, 1), 3)41 self.assertEqual(get_xor(0, 3), 0)42class TestDisjointSparseTableIntSum(unittest.TestCase):43 def test(self) -> None:44 a = [3, 1, 2, 10, -1]45 get_sum = dsalgo.sparse_table.disjoint_sparse_table_int_sum(a)46 self.assertEqual(get_sum(0, 5), 15)47 self.assertEqual(get_sum(0, 1), 3)48 self.assertEqual(get_sum(0, 3), 6)49class TestSparseTable2D(unittest.TestCase):50 def test(self) -> None:51 a = [52 [0, 1, 2, 3],53 [4, 5, 6, 7],54 [-1, 4, 0, 1],55 ]56 semigroup = dsalgo.algebraic_structure.Semigroup[int](min)57 get_min = dsalgo.sparse_table.sparse_table_2d(semigroup, a)58 self.assertEqual(get_min(0, 0, 3, 4), -1)59 self.assertEqual(get_min(0, 1, 3, 4), 0)60 self.assertEqual(get_min(1, 3, 2, 4), 7)61 self.assertEqual(get_min(1, 1, 2, 3), 5)62 self.assertEqual(get_min(0, 2, 2, 3), 2)63class TestSparseTable2DFixedShape(unittest.TestCase):64 def test(self) -> None:65 a = [66 [0, 1, 2, 3],67 [4, 5, 6, 7],68 [-1, 4, 0, 1],69 ]70 semigroup = dsalgo.algebraic_structure.Semigroup[int](min)71 get_min = dsalgo.sparse_table.sparse_table_2d_fixed_window(72 semigroup,73 a,74 (2, 2),75 )76 self.assertEqual(get_min(0, 0), 0)77 self.assertEqual(get_min(1, 0), -1)78 self.assertEqual(get_min(0, 2), 2)79 with self.assertRaises(IndexError):80 get_min(0, 3)81if __name__ == "__main__":...
15-special-stack-datastructure-method3.py
...45 return actual_popped46 else:47 print("Can't pop. Stack underflow!")48 return False49 def get_min(self):50 if self.peek() is None:51 print(f"minimum {None}")52 return None53 print(f"minimum {self.min}")54 return self.min55 def peek(self):56 if not self.is_empty():57 print(f"Top element {self.elements[self.top]}")58 return self.elements[self.top]59 print("stack underflow!")60 return61if __name__ == "__main__":62 special_stack = SpecialStack(10)63 special_stack.push(8)64 special_stack.get_min()65 special_stack.push(4)66 special_stack.get_min()67 special_stack.push(14)68 special_stack.get_min()69 special_stack.push(45)70 special_stack.get_min()71 special_stack.push(3)72 special_stack.get_min()73 special_stack.push(-2)74 special_stack.get_min()75 special_stack.push(12)76 special_stack.get_min()77 special_stack.pop()78 special_stack.get_min()79 special_stack.pop()80 special_stack.get_min()81 special_stack.pop()82 special_stack.get_min()83 special_stack.pop()84 special_stack.get_min()85 special_stack.pop()86 special_stack.get_min()87 special_stack.pop()88 special_stack.get_min()89 special_stack.pop()...
test_minstack.py
Source: test_minstack.py
...20 assert stack.is_empty()21def test_min():22 stack = MinStack()23 stack.push(4)24 assert stack.get_min() == 425 stack.push(3)26 assert stack.get_min() == 327 stack.push(3)28 assert stack.get_min() == 329 stack.push(2)30 assert stack.get_min() == 231 stack.pop()32 assert stack.get_min() == 333 stack.pop()34 assert stack.get_min() == 335 stack.pop()36 assert stack.get_min() == 437 stack.pop()...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!