def approximate_coding_sessions(clustered_commits, approx_algo): """Approximates the coding sessions that resulted in given clustered commits. :param clustered_commits: Dictionary mapping contributor names to lists of Commit clusters :param approx_algo: Name of approximation algorithm :return: Dictionary mapping contributor names to lists of Session tuples """ approx_func = globals().get(approx_algo + '_approximation') if not approx_func: raise ValueError("Unknown approximation '%s'" % approx_algo) return dicts.mapvalues(curry(map, approx_func), clustered_commits)
def cluster_commits(grouped_commits, cluster_algo, epsilon): """Clusters commits for every contributor in given dictionary. :param grouped_commits: Dictionary mapping contributor names to lists of Commit tuples :param cluster_algo: Name of clustering algorithm :param epsilon: Temporal distance for the epsilon-neighborhood :return: Dictionary mapping author names to lists of coding sessions """ cluster_func = globals().get(cluster_algo + '_clustering') if not cluster_func: raise ValueError("Unknown clustering algorithm '%s'" % cluster_algo) return dicts.mapvalues(curry(cluster_func, epsilon=epsilon), grouped_commits)
def test_dict__some_object(self): with self.assertRaises(TypeError): __unit__.mapvalues(MapValues.FUNCTION, object())
def test_dict__none(self): with self.assertRaises(TypeError): __unit__.mapvalues(MapValues.FUNCTION, None)
def test_function__non_function(self): with self.assertRaises(TypeError): __unit__.mapvalues(object(), self.DICT)
def test_function__none(self): self.assertEquals(self.DICT, __unit__.mapvalues(None, self.DICT))
def write_contrib(contrib, parent, tag): ET.SubElement(parent, tag, attrib=dicts.mapvalues(str_, contrib))
def test_map(self): self.assertEquals(self.MAPPED_DICT, __unit__.mapvalues(MapValues.FUNCTION, self.DICT))
def test_dict__empty(self): self.assertEquals({}, __unit__.mapvalues(None, {})) self.assertEquals({}, __unit__.mapvalues(MapValues.FUNCTION, {}))