Commit 02d269e9 authored by Purves, Murray's avatar Purves, Murray
Browse files

Updated Python test for interpolation routines

parent 2477811d
......@@ -10,30 +10,72 @@ circular = False
class TestInterpolateBindings(unittest.TestCase):
def test_interpolate_basic(self):
# Basic test of interpolate_values
print("Testing interpolate_values...")
print("Testing interpolate_values (linear)...")
logarithmic = False
base_values = (10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0)
interp_values = (1.0, missing_value, 3.0, missing_value, 6.0,
missing_value, 1.0)
expect_values = (1.0, 2.0, 3.0, 4.5, 6.0, 3.5, 1.0)
test_values = radixmath.interpolate_values(
base_values, interp_values, circular, missing_value
base_values, interp_values, logarithmic, circular, missing_value
)
self.assertEqual(expect_values, test_values)
def test_interpolate_log_basic(self):
# Basic test of interpolate_values
print("Testing interpolate_values (logarithmic)...")
logarithmic = True
base_values = (1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0)
interp_values = (1.0, missing_value, 3.0, missing_value, 6.0,
missing_value, 1.0)
expect_values = (1.0, 2.0, 3.0, 4.5, 6.0, 3.5, 1.0)
test_values = radixmath.interpolate_values(
base_values, interp_values, logarithmic, circular, missing_value
)
self.assertEqual(expect_values, test_values)
def test_interpolate_to_other_base_basic(self):
print("Testing interpolate_to_other_base_values")
print("Testing interpolate_to_other_base_values (linear)...")
logarithmic = False
base_values = (1000.0, 2000.0, 3000.0)
new_base_values = (500.0, 1500.0, 2500.0, 3500.0)
interp_values = (10.5, missing_value, 30.5)
expect_values = (10.5, 15.5, 25.5, 30.5)
test_values = radixmath.interpolate_to_other_base_values(
base_values, new_base_values, interp_values, circular, missing_value
base_values, new_base_values, interp_values, logarithmic,
circular, missing_value
)
self.assertEqual(expect_values, test_values)
def test_interpolate_to_other_base_basic_log(self):
print("Testing interpolate_to_other_base_values (logarithmic)...")
logarithmic = True
base_values = (1000.0, 4000.0, 16000.0)
new_base_values = (500.0, 2000.0, 8000.0, 32000.0)
interp_values = (10.5, missing_value, 30.5)
expect_values = (10.5, 15.5, 25.5, 30.5)
test_values = radixmath.interpolate_to_other_base_values(
base_values, new_base_values, interp_values, logarithmic,
circular, missing_value
)
self.assertEqual(expect_values, test_values)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment