This repository has been archived by the owner on Jul 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_standardizer.py
48 lines (38 loc) · 1.73 KB
/
test_standardizer.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
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import absolute_import
import unittest
import standardizer
class TestStandardizer(unittest.TestCase):
def test_linear_mapping(self):
mapped_value = standardizer.Standardizer.get_mapped_value(
normalized_value=1.0, min_value=0.0, max_value=3.0, skew_factor=1.0
)
self.assertAlmostEqual(mapped_value, 3.0)
mapped_value = standardizer.Standardizer.get_mapped_value(
normalized_value=0.5, min_value=0.0, max_value=3.0, skew_factor=1.0
)
self.assertAlmostEqual(mapped_value, 1.5)
mapped_value = standardizer.Standardizer.get_mapped_value(
normalized_value=0.0, min_value=0.0, max_value=3.0, skew_factor=1.0
)
self.assertAlmostEqual(mapped_value, 0.0)
def test_skewed_mapping(self):
mapped_value = standardizer.Standardizer.get_mapped_value(
normalized_value=1.0, min_value=0.0, max_value=3.0, skew_factor=0.3
)
self.assertAlmostEqual(mapped_value, 3.0)
mapped_value = standardizer.Standardizer.get_mapped_value(
normalized_value=0.5, min_value=0.0, max_value=3.0, skew_factor=0.3
)
self.assertLess(mapped_value, 1.5)
self.assertGreater(mapped_value, 0.0)
mapped_value = standardizer.Standardizer.get_mapped_value(
normalized_value=0.013, min_value=0.0, max_value=3.0, skew_factor=0.3
)
self.assertLess(mapped_value, 0.013)
self.assertGreater(mapped_value, 0.0)
mapped_value = standardizer.Standardizer.get_mapped_value(
normalized_value=0.0, min_value=0.0, max_value=3.0, skew_factor=0.3
)
self.assertAlmostEqual(mapped_value, 0.0)
if __name__ == '__main__':
unittest.main()