def test_form(self):
        m = [[0, 2, 3, 4], [2, 0, 6, 7], [3, 6, 0, 8], [4, 7, 8, 0]]

        m = numpy.array(m)
        dist = hierarchical.condensedform(m, mode="lower")
        numpy.testing.assert_equal(dist, numpy.array([2, 3, 6, 4, 7, 8]))
        numpy.testing.assert_equal(hierarchical.squareform(dist, mode="lower"),
                                   m)
        dist = hierarchical.condensedform(m, mode="upper")
        numpy.testing.assert_equal(dist, numpy.array([2, 3, 4, 6, 7, 8]))
        numpy.testing.assert_equal(hierarchical.squareform(dist, mode="upper"),
                                   m)
    def test_form(self):
        m = [[0, 2, 3, 4],
             [2, 0, 6, 7],
             [3, 6, 0, 8],
             [4, 7, 8, 0]]

        m = numpy.array(m)
        dist = hierarchical.condensedform(m, mode="lower")
        numpy.testing.assert_equal(dist, numpy.array([2, 3, 6, 4, 7, 8]))
        numpy.testing.assert_equal(
            hierarchical.squareform(dist, mode="lower"), m)
        dist = hierarchical.condensedform(m, mode="upper")
        numpy.testing.assert_equal(dist, numpy.array([2, 3, 4, 6, 7, 8]))
        numpy.testing.assert_equal(
            hierarchical.squareform(dist, mode="upper"), m)
    def setUpClass(cls):
        m = [
            [],
            [3],
            [2, 4],
            [17, 5, 4],
            [2, 8, 3, 8],
            [7, 5, 10, 11, 2],
            [8, 4, 1, 5, 11, 13],
            [4, 7, 12, 8, 10, 1, 5],
            [13, 9, 14, 15, 7, 8, 4, 6],
            [12, 10, 11, 15, 2, 5, 7, 3, 1],
        ]
        cls.items = [
            "Ann",
            "Bob",
            "Curt",
            "Danny",
            "Eve",
            "Fred",
            "Greg",
            "Hue",
            "Ivy",
            "Jon",
        ]

        dist = numpy.array(list(flatten(m)), dtype=float)
        matrix = hierarchical.squareform(dist, mode="lower")
        cls.m = m
        cls.matrix = Orange.misc.DistMatrix(matrix)
        cls.matrix.items = cls.items

        cls.cluster = hierarchical.dist_matrix_clustering(cls.matrix)
    def setUpClass(cls):
        m = [[],
             [3],
             [2, 4],
             [17, 5, 4],
             [2, 8, 3, 8],
             [7, 5, 10, 11, 2],
             [8, 4, 1, 5, 11, 13],
             [4, 7, 12, 8, 10, 1, 5],
             [13, 9, 14, 15, 7, 8, 4, 6],
             [12, 10, 11, 15, 2, 5, 7, 3, 1]]
        cls.items = ["Ann", "Bob", "Curt", "Danny", "Eve", "Fred",
                     "Greg", "Hue", "Ivy", "Jon"]

        dist = numpy.array(list(flatten(m)), dtype=float)
        matrix = hierarchical.squareform(dist, mode="lower")
        cls.m = m
        cls.matrix = Orange.misc.DistMatrix(matrix)
        cls.matrix.items = cls.items

        cls.cluster = hierarchical.dist_matrix_clustering(cls.matrix)