def testOutputGraphOriginal(): def orderTuples(itms): return list( map(lambda x: (x[0], x[1]) if x[0] < x[1] else (x[1], x[0]), itms)) mca = MedeinaCumulativeApplication("dir") mca.interactionStore = [ ("Spec1", "Spec2"), ("Spec2", "Spec3"), ("Spec3", "Spec4"), ("Spec1", "Spec2"), ("Spec5", "Spec6"), ] mca.scientificToUser = { "Spec1": "USpec1", "Spec2": "USpec2", "Spec3": "USpec3", "Spec4": "USpec4", "Spec5": "USpec5", "Spec6": "USpec6", } expected = [ ("USpec1", "USpec2"), ("USpec2", "USpec3"), ("USpec3", "USpec4"), ("USpec5", "USpec6"), ] unittest.TestCase().assertCountEqual( orderTuples(mca.to_graph_original().edges), orderTuples(expected))
def testOutputListWithUserMapping(): mca = MedeinaCumulativeApplication("dir") mca.interactionStore = [ ("Spec1", "Spec2"), ("Spec2", "Spec3"), ("Spec3", "Spec4"), ("Spec1", "Spec2"), ("Spec5", "Spec6"), ] mca.scientificToUser = { "Spec1": "USpec1", "Spec2": "USpec2", "Spec3": "USpec3", "Spec4": "USpec4", "Spec5": "USpec5", "Spec6": "USpec6", } expectedOne = [ ("Spec1", "Spec2"), ("Spec2", "Spec3"), ("Spec3", "Spec4"), ("Spec5", "Spec6"), ] expectedTwo = [ ("USpec1", "USpec2"), ("USpec2", "USpec3"), ("USpec3", "USpec4"), ("USpec5", "USpec6"), ] expected = list(zip(expectedOne, expectedTwo)) unittest.TestCase().assertCountEqual(mca.to_list_original(), expected)
def testOutputMatrixOriginal(): def orderTuples(itms): return list( map(lambda x: (x[0], x[1]) if x[0] < x[1] else (x[1], x[0]), itms)) mca = MedeinaCumulativeApplication("dir") mca.interactionStore = [ ("Spec1", "Spec2"), ("Spec2", "Spec3"), ("Spec3", "Spec4"), ("Spec1", "Spec2"), ("Spec5", "Spec6"), ] mca.scientificToUser = { "Spec1": "USpec1", "Spec2": "USpec2", "Spec3": "USpec3", "Spec4": "USpec4", "Spec5": "USpec5", "Spec6": "USpec6", } crushed = [] matrixOut, labelOrder = mca.to_matrix_original() matrixOut = matrixOut.tolist() for kr, row in enumerate(matrixOut): for kc, col in enumerate(row): if col == 1: crushed.append((labelOrder[kr], labelOrder[kc])) crushed = list(set(orderTuples(crushed))) expected = [ ("USpec1", "USpec2"), ("USpec2", "USpec3"), ("USpec3", "USpec4"), ("USpec5", "USpec6"), ] unittest.TestCase().assertCountEqual(orderTuples(expected), crushed)