Commit c5a07994 authored by Franck Thollard's avatar Franck Thollard
Browse files

adding basic testing to V5_cython

parent 0ba606a5
import numpy as np
import dtw_cort as dt
def test_dtw_zero_if_equal():
""" test dtw is 0 when series are equal"""
a = np.random.random(100)
b = np.copy(a)
assert(dt.dtw_distance(a, b) == 0.0)
import unittest
import numpy as np
import dtw_cort as dt
class TestDtwCortCython(unittest.TestCase):
def test_cort_one_if_equal(self):
"""check cort returns 1 for equal arrays"""
a = np.random.random(100)
b = np.copy(a)
self.assertAlmostEqual(dt.cort(a, b), 1.0)
def test_dtw_null_if_equal(self):
"""check dtw returns 0 for equal arrays"""
a = np.random.random(100)
b = np.copy(a)
self.assertAlmostEqual(dt.dtw_distance(a, b), 0.0)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestDtwCortCython)
_res = unittest.TextTestRunner(verbosity=2).run(suite)
import sys
sys.exit(max(len(_res.failures), len(_res.errors)))
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