def test_feature_get_speed(self): count = 1000 total = 0 f = None for i in range(count): t0 = timeit.default_timer() new_f = nodetools.get_feature_from_nodes(self.nodes, self.complete_feature_keys) t1 = timeit.default_timer() total += t1-t0 if i > 1: self.assertEqual(f, new_f) f = new_f unsafe_time = total/count print("Unsafe get: \t{0}".format(unsafe_time)) total = 0 for i in range(count): t0 = timeit.default_timer() new_f, a, b = nodetools.get_feature_from_nodes_with_breakdown(self.nodes, self.complete_feature_keys) t1 = timeit.default_timer() total += t1-t0 if i > 1: self.assertEqual(f, new_f) f = new_f safe_time = total/count print("Safe get: \t\t{0}".format(safe_time))
def get_feature_for_all_nodes_with_breakdown(self, feature_keys): """ Gets feature value for all boundary nodes in world (unordered) along with flags indicating whether some/all/none of the nodes actually had a value for feature_keys :param feature_keys: list of feature keys (see SpatialNode class for explanation) :return 0: List of feature values for each node, with None if node had no value :return 1: True if some nodes had a value for the feature, False if none did :return 2: True if all nodes had a value for the feature, False if some did not """ return nodetools.get_feature_from_nodes_with_breakdown(self.all_boundary_nodes, feature_keys)