Adding a test for the power kernel and removing unused import.

RE:#722
This commit is contained in:
James Douglass 2023-02-02 16:35:12 -08:00
parent f7dc9aca72
commit c91eaa6064
1 changed files with 14 additions and 1 deletions

View File

@ -11,7 +11,6 @@ import unittest
import numpy
import pandas
import pandas.testing
import pygeoprocessing
import shapely.geometry
from natcap.invest import utils
@ -296,6 +295,20 @@ class UNATests(unittest.TestCase):
self.assertAlmostEqual(1.5915502e-05, kernel_array.max())
self.assertEqual(0, kernel_array.min())
def test_power_kernel(self):
"""UNA: Test the power kernel."""
from natcap.invest import urban_nature_access
beta = -5
max_distance = 3
distance = numpy.array([0, 1, 2, 3, 4])
kernel = urban_nature_access._kernel_power(
distance, max_distance, beta)
# These regression values are calculated by hand
expected_array = numpy.array([1, 1, (1/32), (1/243), 0])
numpy.testing.assert_allclose(
expected_array, kernel)
def test_greenspace_budgets(self):
"""UNA: Test the per-capita greenspace budgets functions."""
from natcap.invest import urban_nature_access