예제 #1
0
    def test_random(self):
        x = (np.random.random((20, 30)) * 5).astype(np.int)

        labels = label(x)
        n = labels.max()
        for i in range(n):
            values = x[labels == i]
            assert np.all(values == values[0])
예제 #2
0
 def test_diag(self):
     x = np.array([[0, 0, 1],
                   [0, 1, 0],
                   [1, 0, 0]])
     assert_array_equal(label(x),
                        x)
예제 #3
0
    def test_basic(self):
        assert_array_equal(label(self.x), self.labels)

        # Make sure data wasn't modified
        assert self.x[0, 2] == 3