test_summary.py 703 字节
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
        self.writer = storage.StorageWriter(self.dir, sync_cycle=1).as_mode("train")
S
superjom 已提交
11

S
superjom 已提交
12 13 14
    def test_write(self):
        scalar = self.writer.scalar("model/scalar/min")
        scalar.set_caption("model/scalar/min")
S
superjom 已提交
15
        for i in range(10):
S
superjom 已提交
16
            scalar.add_record(i, 1.0)
S
superjom 已提交
17

S
superjom 已提交
18 19 20
    def test_read(self):
        self.reader = storage.StorageReader("train", self.dir)
        scalar = self.reader.scalar("model/scalar/min")
S
superjom 已提交
21
        self.assertEqual(scalar.caption(), "train")
S
superjom 已提交
22

S
superjom 已提交
23 24 25

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