def test_2d_coordinates(self):
        img_size = (32, 17, 1, 1, 1)
        win_size = (31, 3, 1)
        sampling_map = np.zeros(img_size)
        coords = weighted_spatial_coordinates(64, img_size, win_size,
                                              sampling_map)

        self.assertAllEqual(coords.shape, (64, N_SPATIAL))
        self.assertCoordinatesAreValid(coords, sampling_map)

        # testing high weight location (15, 1, 1, 0, 0)
        sampling_map[15, 1, 0, 0, 0] = 1.0
        coords = weighted_spatial_coordinates(64, img_size, win_size,
                                              sampling_map)
        self.assertAllEqual(coords.shape, (64, N_SPATIAL))
        self.assertTrue(np.all(coords == [15, 1, 0]))
    def test_1d_coordinates(self):
        img_size = (32, 1, 1, 1, 1)
        win_size = (15, 1, 1)
        sampling_map = np.zeros(img_size)
        coords = weighted_spatial_coordinates(10, img_size, win_size,
                                              sampling_map)
        self.assertAllEqual(coords.shape, (10, N_SPATIAL))
        self.assertCoordinatesAreValid(coords, sampling_map)

        sampling_map[20, 0, 0] = 0.1
        coords = weighted_spatial_coordinates(10, img_size, win_size,
                                              sampling_map)
        self.assertAllEqual(coords.shape, (10, N_SPATIAL))
        self.assertTrue(np.all(coords == [20, 0, 0]))

        sampling_map[9, 0, 0] = 0.1
        coords = weighted_spatial_coordinates(10, img_size, win_size,
                                              sampling_map)
        self.assertAllEqual(coords.shape, (10, N_SPATIAL))
        self.assertTrue(np.all((coords == [20, 0, 0]) | (coords == [9, 0, 0])))