Example #1
0
    def test_calculate_min_distances(self):
        """WaveEnergy: testing '_calculate_min_distances' function."""
        from natcap.invest import wave_energy

        srs = sampledata.SRS_WILLAMETTE
        pos_x = srs.origin[0]
        pos_y = srs.origin[1]

        set_one = numpy.array([[pos_x, pos_y], [pos_x, pos_y - 100],
                               [pos_x, pos_y - 200]])
        set_two = numpy.array([[pos_x + 100, pos_y],
                               [pos_x + 100, pos_y - 100],
                               [pos_x + 100, pos_y - 200]])

        result_dist, result_id = wave_energy._calculate_min_distances(
            set_one, set_two)

        expected_result_dist = [100, 100, 100]
        expected_result_id = [0, 1, 2]

        for res, exp_res in zip(result_dist, expected_result_dist):
            self.assertEqual(res, exp_res)
        for res, exp_res in zip(result_id, expected_result_id):
            self.assertEqual(res, exp_res)
Example #2
0
    def test_calculate_min_distances(self):
        """WaveEnergy: testing '_calculate_min_distances' function."""
        from natcap.invest import wave_energy

        origin = (443723.127327877911739, 4956546.905980412848294)
        pos_x = origin[0]
        pos_y = origin[1]

        set_one = numpy.array([[pos_x, pos_y], [pos_x, pos_y - 100],
                               [pos_x, pos_y - 200]])
        set_two = numpy.array([[pos_x + 100, pos_y],
                               [pos_x + 100, pos_y - 100],
                               [pos_x + 100, pos_y - 200]])

        result_dist, result_id = wave_energy._calculate_min_distances(
            set_one, set_two)

        expected_result_dist = [100, 100, 100]
        expected_result_id = [0, 1, 2]

        for res, exp_res in zip(result_dist, expected_result_dist):
            self.assertEqual(res, exp_res)
        for res, exp_res in zip(result_id, expected_result_id):
            self.assertEqual(res, exp_res)