view python/tests/utils.txt @ 322:28661c5887d3

Corrected a major bug for LCSS Added functions to test all alignments when computing the LCSS with a finite delta
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 07 May 2013 18:43:40 +0200
parents f6f423e25c7f
children efd4dd4665ac
line wrap: on
line source

>>> from utils import *
>>> from moving import Point

>>> computeChi2([],[])
0.0
>>> computeChi2(range(1,10),range(1,10))
0.0
>>> computeChi2(range(1,9),range(1,10))
0.0

>>> ceilDecimals(1.23, 0)
2.0
>>> ceilDecimals(1.23, 1)
1.3

>>> inBetween(1,2,1.5)
True
>>> inBetween(2.1,1,1.5)
True
>>> inBetween(1,2,0)
False

>>> f = openCheck('non_existant_file.txt')
File non_existant_file.txt could not be opened.

>>> removeExtension('test-adfasdf.asdfa.txt')
'test-adfasdf.asdfa'
>>> removeExtension('test-adfasdf')
'test-adfasdf'

>>> values = line2Ints('1 2 3 5 6')
>>> values[0]
1
>>> values[-1]
6
>>> values = line2Floats('1.3 2.45 7.158e+01 5 6')
>>> values[0]
1.3
>>> values[2] #doctest: +ELLIPSIS
71.5...
>>> values[-1]
6.0

>>> stepPlot([3, 5, 7, 8], 1, 10, 0)
([1, 3, 3, 5, 5, 7, 7, 8, 8, 10], [0, 0, 1, 1, 2, 2, 3, 3, 4, 4])

>>> LCSS(range(5), range(5), 0.1, lambda x,y:abs(x-y))
5
>>> LCSS(range(1,5), range(5), 0.1, lambda x,y:abs(x-y))
4
>>> LCSS(range(5,10), range(5), 0.1, lambda x,y:abs(x-y))
0
>>> LCSS(range(5), range(10), 0.1, lambda x,y:abs(x-y))
5
>>> LCSS(range(5), range(10), 0.1, lambda x,y:abs(x-y), 2)
5

>>> alignedLCSS(range(5), range(5), 0.1, lambda x,y:abs(x-y), 2)
5
>>> alignedLCSS(range(1,5), range(5), 0.1, lambda x,y:abs(x-y), 2)
4

>>> alignedLCSS(range(5,10), range(10), 0.1, lambda x,y:abs(x-y), 2)
5
>>> LCSS(range(5,10), range(10), 0.1, lambda x,y:abs(x-y), 2)
0