test_summary.py 732 字节
Newer Older
S
superjom 已提交
1
import storage
S
superjom 已提交
2 3
import numpy as np
import unittest
S
superjom 已提交
4
import random
S
superjom 已提交
5
import time
S
superjom 已提交
6

S
superjom 已提交
7
class StorageTest(unittest.TestCase):
S
superjom 已提交
8
    def setUp(self):
S
superjom 已提交
9
        self.dir = "./tmp/storage_test"
S
superjom 已提交
10

S
superjom 已提交
11 12 13
    def test_read(self):
        print 'test write'
        self.writer = storage.StorageWriter(self.dir, sync_cycle=1).as_mode("train")
S
superjom 已提交
14
        scalar = self.writer.scalar("model/scalar/min")
S
superjom 已提交
15
        # scalar.set_caption("model/scalar/min")
S
superjom 已提交
16
        for i in range(10):
S
superjom 已提交
17
            scalar.add_record(i, 1.0)
S
superjom 已提交
18

S
superjom 已提交
19
        print 'test read'
S
superjom 已提交
20 21
        self.reader = storage.StorageReader("train", self.dir)
        scalar = self.reader.scalar("model/scalar/min")
S
superjom 已提交
22
        self.assertEqual(scalar.caption(), "train")
S
superjom 已提交
23

S
superjom 已提交
24 25 26

if __name__ == '__main__':
    unittest.main()