-
Notifications
You must be signed in to change notification settings - Fork 12
/
weight_test.py
35 lines (29 loc) · 987 Bytes
/
weight_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'''
Tests weight functions.
.. moduleauthor:: Chris Fournier <chris.m.fournier@gmail.com>
'''
import unittest
from decimal import Decimal
from . import (weight_s_scale, weight_t_scale)
class TestWeight(unittest.TestCase):
'''
Test similarity helper functions.
'''
def test_weight_t_scale(self):
'''
Test to see that penalties for substitution edits are discounted from
3 to 1.5.
'''
transpositions = [[1,2], [1,3], [1,4]]
weight = weight_t_scale(transpositions, 4)
self.assertEqual(weight, Decimal('1.5'))
def test_weight_s_scale(self):
'''
Test to see that penalties for transposition edits are discounted from
3 to 1.5.
'''
substitutions = [[1,2], [1,3], [1,4]]
weight = weight_s_scale(substitutions, 4)
self.assertEqual(weight, Decimal('1.5'))
weight = weight_s_scale(substitutions, 5, 2)
self.assertEqual(weight, Decimal('1.5'))