Beispiel #1
0
def test_complex_removal():
    """Test more complex clustering with removing a cluster."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ['A', 'B'], 2: ['C']}
    partition_after = {3: ['A', 'B', 'C']}

    match = match_clusters(partition_before, partition_after)

    assert match == ([(1, 3)], [], [2])
Beispiel #2
0
def test_complex_matching():
    """Test more complex clustering with no removal or adding."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ['A', 'B'], 2: ['C', 'D', 'E']}
    partition_after = {3: ['A', 'C', 'E'], 4: ['B', 'D']}

    match = match_clusters(partition_before, partition_after)

    assert match == ([(1, 4), (2, 3)], [], [])
Beispiel #3
0
def test_complex_adding():
    """Test more complex clustering with adding a new cluster."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ['A', 'B', 'C']}
    partition_after = {2: ['A', 'B'], 3: ['C']}

    match = match_clusters(partition_before, partition_after)

    assert match == ([(1, 2)], [3], [])
Beispiel #4
0
def test_the_same_clusters():
    """Test if the two exact clusters will be matched."""
    from beard_server.modules.matching import match_clusters

    signatures_before = {1: ['A', 'B']}
    signatures_after = {2: ['A', 'B']}

    match = match_clusters(signatures_before, signatures_after)

    assert match == ([(1, 2)], [], [])
Beispiel #5
0
def test_cluster_removal():
    """Test if the removed cluster will be distinguished."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ['A', 'B']}
    partition_after = {}

    match = match_clusters(partition_before, partition_after)

    assert match == ([], [], [1])
def test_complex_removal():
    """Test more complex clustering with removing a cluster."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ['A', 'B'], 2: ['C']}
    partition_after = {3: ['A', 'B', 'C']}

    match = match_clusters(partition_before, partition_after)

    assert match == ([(1, 3)], [], [2])
def test_complex_matching():
    """Test more complex clustering with no removal or adding."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ['A', 'B'], 2: ['C', 'D', 'E']}
    partition_after = {3: ['A', 'C', 'E'], 4: ['B', 'D']}

    match = match_clusters(partition_before, partition_after)

    assert match == ([(1, 4), (2, 3)], [], [])
def test_complex_adding():
    """Test more complex clustering with adding a new cluster."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ['A', 'B', 'C']}
    partition_after = {2: ['A', 'B'], 3: ['C']}

    match = match_clusters(partition_before, partition_after)

    assert match == ([(1, 2)], [3], [])
def test_cluster_removal():
    """Test if the removed cluster will be distinguished."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ['A', 'B']}
    partition_after = {}

    match = match_clusters(partition_before, partition_after)

    assert match == ([], [], [1])
def test_the_same_clusters():
    """Test if the two exact clusters will be matched."""
    from beard_server.modules.matching import match_clusters

    signatures_before = {1: ['A', 'B']}
    signatures_after = {2: ['A', 'B']}

    match = match_clusters(signatures_before, signatures_after)

    assert match == ([(1, 2)], [], [])
Beispiel #11
0
def test_almost_the_same_keys():
    """Test the case where the keys are the same after casting."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ["A", "B", "C"], "1": ["D", "E"]}

    partition_after = {1: ["A", "B", "C"], "1": ["D", "E"]}

    match = match_clusters(partition_before, partition_after)

    assert match == ([('1', '1'), (1, 1)], [], [])
def test_almost_the_same_keys():
    """Test the case where the keys are the same after casting."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ["A", "B", "C"],
                        "1": ["D", "E"]}

    partition_after = {1: ["A", "B", "C"],
                       "1": ["D", "E"]}

    match = match_clusters(partition_before, partition_after)

    assert match == ([('1', '1'), (1, 1)], [], [])
def test_wang_signtures():
    """Test the real output of Beard."""
    from beard_server.modules.matching import match_clusters

    with open(pkg_resources.resource_filename(
        __name__, os.path.join('data', 'wang_clusters_1.json')),
            'r') as file_before:

        signatures_before = json.load(file_before)

    match = match_clusters(signatures_before, signatures_before)

    assert match == ([(u'158992', u'158992'), (u'623639', u'623639'),
                      (u'623638', u'623638')], [], [])
Beispiel #14
0
def test_wang_signtures():
    """Test the real output of Beard."""
    from beard_server.modules.matching import match_clusters

    with open(
            pkg_resources.resource_filename(
                __name__, os.path.join('data', 'wang_clusters_1.json')),
            'r') as file_before:

        signatures_before = json.load(file_before)

    match = match_clusters(signatures_before, signatures_before)

    assert match == ([(u'158992', u'158992'), (u'623639', u'623639'),
                      (u'623638', u'623638')], [], [])
def test_complex_subproblems():
    """Test the case, where there are at least two subproblems."""
    from beard_server.modules.matching import match_clusters

    partition_before = {1: ["A", "B", "C"],
                        2: ["D", "E"],
                        3: ["F"],
                        4: ["G"],
                        5: ["H"]}

    partition_after = {6: ["A", "B"],
                       7: ["C", "D"],
                       8: ["E", "F"],
                       9: ["G"],
                       10: ["I"]}

    match = match_clusters(partition_before, partition_after)

    assert match == ([(4, 9), (1, 6), (2, 7), (3, 8)], [10], [5])
Beispiel #16
0
def test_complex_subproblems():
    """Test the case, where there are at least two subproblems."""
    from beard_server.modules.matching import match_clusters

    partition_before = {
        1: ["A", "B", "C"],
        2: ["D", "E"],
        3: ["F"],
        4: ["G"],
        5: ["H"]
    }

    partition_after = {
        6: ["A", "B"],
        7: ["C", "D"],
        8: ["E", "F"],
        9: ["G"],
        10: ["I"]
    }

    match = match_clusters(partition_before, partition_after)

    assert match == ([(4, 9), (1, 6), (2, 7), (3, 8)], [10], [5])