Beispiel #1
0
    def test_attr_label_matrix_and_data(self):
        w = self.widget
        # Don't run the MDS optimization to save time and to prevent the
        # widget be in a blocking state when trying to send the next signal
        w.start = Mock()

        # Data and matrix
        data = Table("zoo")
        dist = Euclidean(data)
        self.send_signal(w.Inputs.distances, dist)
        self.send_signal(w.Inputs.data, data)
        self.assertTrue(set(chain(data.domain.variables, data.domain.metas))
                        < set(w.label_model))

        # Has data, but receives a signal without data: has to keep the label
        dist.row_items = None
        self.send_signal(w.Inputs.distances, dist)
        self.assertTrue(set(chain(data.domain.variables, data.domain.metas))
                        < set(w.label_model))

        # Has matrix without data, and loses the data: remove the label
        self.send_signal(w.Inputs.data, None)
        self.assertEqual(list(w.label_model), [None])

        # Has matrix without data, receives data: add attrs to combo, select
        self.send_signal(w.Inputs.data, data)
        self.assertTrue(set(chain(data.domain.variables, data.domain.metas))
                        < set(w.label_model))
    def test_attr_label_matrix_and_data(self):
        w = self.widget
        # Don't run the MDS optimization to save time and to prevent the
        # widget be in a blocking state when trying to send the next signal
        w.start = Mock()

        # Data and matrix
        data = Table("zoo")
        dist = Euclidean(data)
        self.send_signal(w.Inputs.distances, dist)
        self.send_signal(w.Inputs.data, data)
        self.assertTrue(
            set(chain(data.domain.variables, data.domain.metas)) < set(
                w.label_model))

        # Has data, but receives a signal without data: has to keep the label
        dist.row_items = None
        self.send_signal(w.Inputs.distances, dist)
        self.assertTrue(
            set(chain(data.domain.variables, data.domain.metas)) < set(
                w.label_model))

        # Has matrix without data, and loses the data: remove the label
        self.send_signal(w.Inputs.data, None)
        self.assertEqual(list(w.label_model), [None])

        # Has matrix without data, receives data: add attrs to combo, select
        self.send_signal(w.Inputs.data, data)
        self.assertTrue(
            set(chain(data.domain.variables, data.domain.metas)) < set(
                w.label_model))
Beispiel #3
0
 def test_distances_without_data_1(self):
     """
     Only distances and no data.
     GH-2335
     """
     signal_data = Euclidean(self.data, axis=1)
     signal_data.row_items = None
     self.send_signal("Distances", signal_data)
    def test_set_distances(self):
        assert isinstance(self.widget, OWDistanceMatrix)

        iris = Table("iris")[:5]
        distances = Euclidean(iris)

        # Distances with row data
        self.widget.set_distances(distances)
        self.assertIn(iris.domain[0], self.widget.annot_combo.model())

        # Distances without row data
        distances.row_items = None
        self.widget.set_distances(distances)
        self.assertNotIn(iris.domain[0], self.widget.annot_combo.model())
    def test_set_distances(self):
        assert isinstance(self.widget, OWDistanceMatrix)

        iris = Table("iris")[:5]
        distances = Euclidean(iris)

        # Distances with row data
        self.widget.set_distances(distances)
        self.assertIn(iris.domain[0], self.widget.annot_combo.model())

        # Distances without row data
        distances.row_items = None
        self.widget.set_distances(distances)
        self.assertNotIn(iris.domain[0], self.widget.annot_combo.model())