Coverage for test_fun.py: 95%
20 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-08 21:58 +0200
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-08 21:58 +0200
1#/usr/bin/env python
2import os
3import sys
5import unittest
6from archery.quiver import VectorDict
7from archery.barrack import make_from_path, mapping_row_iter
8from archery import mdict
9from collections import Counter
11from math import sqrt, cos, pi
13class CWCos(VectorDict, Counter):
14 pass
16class TestCosWithCounter(unittest.TestCase):
19 def testCos(self):
20 self.assertAlmostEqual(
21 CWCos(["mot", "wut", "wut", "bla"]).cos(CWCos(["mot","wut", "bla"])),
22 0.942809041582
23 )
24 self.assertAlmostEqual(
25 CWCos(["mot", "wut", ]).cos(CWCos(["mot",])),
26 cos(pi/4)
27 )
29class TestBuildingFromMap(unittest.TestCase):
31 def test_weired_exp_idea(self):
32 tree= dict(a=dict(b=1, c=1, d=dict(e=2, f=dict(e=5)), v=3))
33 self.assertEqual(tree,
34 sum([ make_from_path(mdict, p) for p in mapping_row_iter(tree)])
35 )
37if __name__ == '__main__':
38 unittest.main(verbosity=4)