forked from neuml/paperai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestvectors.py
41 lines (31 loc) · 875 Bytes
/
testvectors.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
"""
Vectors module tests
"""
import os
import unittest
# pylint: disable=E0401
from paperai.vectors import RowIterator, Vectors
from utils import Utils
class TestVectors(unittest.TestCase):
"""
Vectors tests
"""
def testStream(self):
"""
Test row streaming
"""
# Full index stream
self.assertEqual(len(list(RowIterator(Utils.DBFILE))), 34222)
def testTokens(self):
"""
Test tokens file creation
"""
output = Vectors.tokens(Utils.DBFILE)
self.assertEqual(Utils.hashfile(output), "9fb9b7088bb84930f0cf73d69cb58fe8")
def testRun(self):
"""
Tests word vectors creation
"""
# Build vectors file
Vectors.run(Utils.PATH, 300, 4, Utils.PATH + "/test")
self.assertTrue(os.path.getsize(Utils.PATH + "/test.magnitude") > 0)