コード例 #1
0
ファイル: test_video.py プロジェクト: zhaoyang10/multiperson
 def test_put(self):
     cache = mmcv.Cache(3)
     for i in range(1, 4):
         cache.put('k{}'.format(i), i)
         assert cache.size == i
     assert cache._cache == OrderedDict([('k1', 1), ('k2', 2), ('k3', 3)])
     cache.put('k4', 4)
     assert cache.size == 3
     assert cache._cache == OrderedDict([('k2', 2), ('k3', 3), ('k4', 4)])
     cache.put('k2', 2)
     assert cache._cache == OrderedDict([('k2', 2), ('k3', 3), ('k4', 4)])
コード例 #2
0
ファイル: test_video.py プロジェクト: zhaoyang10/multiperson
 def test_get(self):
     cache = mmcv.Cache(3)
     assert cache.get('key_none') is None
     assert cache.get('key_none', 0) == 0
     cache.put('k1', 1)
     assert cache.get('k1') == 1
コード例 #3
0
ファイル: test_video.py プロジェクト: zhaoyang10/multiperson
 def test_init(self):
     with pytest.raises(ValueError):
         mmcv.Cache(0)
     cache = mmcv.Cache(100)
     assert cache.capacity == 100
     assert cache.size == 0