Commit 80a0ca0d authored by Purves, Murray's avatar Purves, Murray
Browse files

Adding test for python bindings

parent d4505495
......@@ -27,7 +27,9 @@ IF(Python3_FOUND)
)
ADD_CUSTOM_TARGET(target ALL DEPENDS ${OUTPUT})
install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} install --prefix=${CMAKE_INSTALL_PREFIX})")
INSTALL(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} install --prefix=${CMAKE_INSTALL_PREFIX})")
ADD_TEST(NAME radixmathpy_test COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/radixmathpy/test.py" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
ELSE()
MESSAGE(WARNING "Not found Python 3: not including bindings")
......
import unittest
import interpolate
missing_value = -9999.0
tolerance = 0.0001
circular = False
# Basic test of interpolate_values
print("Testing interpolate_values...")
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]
print(" Base values: ", str(base_values))
print(" Before interpolation: ", str(interp_values))
class TestInterpolateBindings(unittest.TestCase):
def test_interpolate_basic(self):
# Basic test of interpolate_values
print("Testing interpolate_values...")
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 = interpolate.interpolate_values(base_values, interp_values,
circular, missing_value)
test_values = interpolate.interpolate_values(
base_values, interp_values, circular, missing_value
)
print(" After interpolation: ", str(test_values))
print(" Expected values: ", str(expect_values))
self.assertEqual(expect_values, test_values)
print("Testing interpolate_to_other_base_values")
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]
def test_interpolate_to_other_base_basic(self):
print("Testing interpolate_to_other_base_values")
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]
print(" Base values: ", str(base_values))
print(" Before interpolation: ", str(interp_values))
test_values = interpolate.interpolate_to_other_base_values(
base_values, new_base_values, interp_values, circular,
missing_value
)
test_values = interpolate.interpolate_to_other_base_values(
base_values, new_base_values, interp_values, circular, missing_value
)
self.assertEqual(expect_values, test_values)
print(" New base values: ", str(new_base_values))
print(" After interpolation: ", str(test_values))
print(" Expected values: ", str(expect_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