Best Python code snippet using assertpy_python
dijkstras.py
Source: dijkstras.py
...51 size = self.size()52 ileft = self.ileft(i)53 iright = self.iright(i)54 imin = i55 if (ileft < size and self.is_less_than(self.nodes[ileft], self.nodes[imin])):56 imin = ileft57 if (iright < size and self.is_less_than(self.nodes[iright], self.nodes[imin])):58 imin = iright59 if (imin != i):60 self.nodes[i], self.nodes[imin] = self.nodes[imin], self.nodes[i]61 # If there is a lambda to get absolute index of a node62 # update your order_mapping array to indicate where that index lives63 # in the nodes array (so lookup by this index is O(1))64 if self.get_index is not None:65 self.order_mapping[self.get_index(self.nodes[imin])] = imin66 self.order_mapping[self.get_index(self.nodes[i])] = i67 self.min_heapify_subtree(imin)68 # Heapify an un-heapified array69 def min_heapify(self):70 for i in range(len(self.nodes), -1, -1):71 self.min_heapify_subtree(i)72 def min(self):73 return self.nodes[0]74 def pop(self):75 min = self.nodes[0]76 if self.size() > 1:77 self.nodes[0] = self.nodes[-1]78 self.nodes.pop()79 # Update order_mapping if applicable80 if self.get_index is not None:81 self.order_mapping[self.get_index(self.nodes[0])] = 082 self.min_heapify_subtree(0)83 elif self.size() == 1:84 self.nodes.pop()85 else:86 return None87 # If self.get_index exists, update self.order_mapping to indicate88 # the node of this index is no longer in the heap89 if self.get_index is not None:90 # Set value in self.order_mapping to None to indicate it is not in the heap91 self.order_mapping[self.get_index(min)] = None92 return min93 # Update node value, bubble it up as necessary to maintain heap property94 def decrease_key(self, i, val):95 self.nodes[i] = self.update_node(self.nodes[i], val)96 iparent = self.iparent(i)97 while (i != 0 and not self.is_less_than(self.nodes[iparent], self.nodes[i])):98 self.nodes[iparent], self.nodes[i] = self.nodes[i], self.nodes[iparent]99 # If there is a lambda to get absolute index of a node100 # update your order_mapping array to indicate where that index lives101 # in the nodes array (so lookup by this index is O(1))102 if self.get_index is not None:103 self.order_mapping[self.get_index(self.nodes[iparent])] = iparent104 self.order_mapping[self.get_index(self.nodes[i])] = i105 i = iparent106 iparent = self.iparent(i) if i > 0 else None107 def index_of_node_at(self, i):108 return self.get_index(self.nodes[i])109class Graph:110 def __init__(self, nodes):111 self.adj_list = [[node, []] for node in nodes]...
numeric_classifier_test.py
Source: numeric_classifier_test.py
...21 def testNumericClassifier(self):22 assert NumericClassifier.equals(3, 3)23 assert NumericClassifier.equals(3.0, 3)24 assert not NumericClassifier.equals(4, 3)25 assert NumericClassifier.is_less_than(3, 4)26 assert NumericClassifier.is_less_than(3.0, 4)27 assert NumericClassifier.is_less_than(3.0, 4.0)28 assert not NumericClassifier.is_less_than(3, 3)29 assert not NumericClassifier.is_less_than(3.0, 3.0)30 assert not NumericClassifier.is_less_than(4.0, 3.0)31 assert not NumericClassifier.is_less_than(4, 3)32 assert NumericClassifier.is_greater_than(4, 3)33 assert NumericClassifier.is_greater_than(4, 3.0)34 assert NumericClassifier.is_greater_than(4.0, 3.0)35 assert not NumericClassifier.is_greater_than(3, 3)36 assert not NumericClassifier.is_greater_than(3.0, 3.0)37 assert not NumericClassifier.is_greater_than(3.0, 4.0)38 assert not NumericClassifier.is_greater_than(3, 4)39 assert NumericClassifier.is_less_than_or_equal_to(3, 4)40 assert NumericClassifier.is_less_than_or_equal_to(3, 3)41 assert not NumericClassifier.is_less_than_or_equal_to(4, 3)42 assert NumericClassifier.is_greater_than_or_equal_to(4, 3)43 assert NumericClassifier.is_greater_than_or_equal_to(3, 3)44 assert not NumericClassifier.is_greater_than_or_equal_to(3, 4)45 assert NumericClassifier.is_inclusively_between(2, 1, 3)...
test_is_less_than.py
Source: test_is_less_than.py
...21 ]22 for fr_param in field_params_rule_params:23 with self.subTest(fr_param=fr_param):24 self.assertTrue(25 self.FRC.is_less_than(26 LinkedProtoField(value=fr_param[1]),27 Rule(verb="is_less_than", params=fr_param[0]),28 )29 )30 def test_not_comply_less(self):31 field_params_rule_params = [32 [2, 1],33 [0, -1],34 [1, 0],35 [1, -1],36 [-1, -2],37 [-1.3, -1.5],38 [0.9, -1.3],39 ]40 for fr_param in field_params_rule_params:41 with self.subTest(fr_param=fr_param):42 self.assertFalse(43 self.FRC.is_less_than(44 LinkedProtoField(value=fr_param[0]),45 Rule(verb="is_less_than", params=fr_param[1]),46 )47 )48 def test_not_comply_equal(self):49 field_params_rule_params = [[3, 3], [0, 0], [-1, -1], [-1.5, -1.5], [2.3, 2.3]]50 for fr_param in field_params_rule_params:51 with self.subTest(fr_param=fr_param):52 self.assertFalse(53 self.FRC.is_less_than(54 LinkedProtoField(value=fr_param[1]),55 Rule(verb="is_less_than", params=fr_param[0]),56 )...
Check out the latest blogs from LambdaTest on this topic:
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
Collecting and examining data from multiple sources can be a tedious process. The digital world is constantly evolving. To stay competitive in this fast-paced environment, businesses must frequently test their products and services. While it’s easy to collect raw data from multiple sources, it’s far more complex to interpret it properly.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.
If you pay close attention, you’ll notice that toggle switches are all around us because lots of things have two simple states: either ON or OFF (in binary 1 or 0).
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!!