Exemplo n.º 1
0
    def test_sample_occupied_with_valid_and_affine(self):
        *_, gl30_10 = random_test_data((2, 2))
        affine = Affine(30, 0, 0, 0, 30, 0)

        expected = [{
            'col': 0,
            'row': 1,
            'x': 0.0,
            'y': 30.0,
            'label': 80
        }, {
            'col': 1,
            'row': 0,
            'x': 30.0,
            'y': 0.0,
            'label': 50
        }, {
            'col': 0,
            'row': 0,
            'x': 0.0,
            'y': 0.0,
            'label': 90
        }]
        actual = sample_occupied(gl30_10, affine=affine, seed=42)

        self.assertEqual(expected, actual)
Exemplo n.º 2
0
    def test_sample_occupied_with_empty(self):
        a = np.zeros((5, 5), dtype=np.uint8)

        expected = 0
        actual = list(sample_occupied(a))

        self.assertEqual(expected, len(actual))
Exemplo n.º 3
0
    def test_sample_occupied_with_valid(self):
        *_, gl30_10 = random_test_data((2, 2))

        expected = [{
            'label': 80,
            'col': 0,
            'row': 1
        }, {
            'label': 50,
            'col': 1,
            'row': 0
        }, {
            'label': 90,
            'col': 0,
            'row': 0
        }]
        actual = sample_occupied(gl30_10, seed=42)

        self.assertEqual(expected, actual)
Exemplo n.º 4
0
    def test_sample_occupied_with_malicious_data(self):
        a = np.random.randint(2, size=10)

        with self.assertRaises(TropiclySamplingError) as err:
            sample_occupied(a)