forked from miracleyoo/RL-PCB-Optimization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
40 lines (33 loc) · 1.11 KB
/
utils.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
# coding: utf-8
# Author: Zhongyang Zhang
# Email : [email protected]
import os
import time
import warnings
warnings.filterwarnings("ignore")
warnings.filterwarnings("ignore", category=DeprecationWarning)
__all__ = ['folder_init', 'Timer']
def folder_init(opt):
"""
Initialize folders required
"""
if not os.path.exists('source'):
os.mkdir('source')
if not os.path.exists('source/reference'):
os.mkdir('source/reference')
if not os.path.exists('./source/summary/'):
os.mkdir('./source/summary/')
if not os.path.exists('./source/val_results/'):
os.mkdir('./source/val_results/')
if not os.path.exists(opt.NET_SAVE_PATH):
os.mkdir(opt.NET_SAVE_PATH)
class Timer(object):
def __init__(self, time_elapsed=0, name=None):
self.name = name
self.time_elapsed = time_elapsed
def __enter__(self):
self.tstart = time.time()
def __exit__(self, type, value, traceback):
print('==> [%s]:\t' % self.name, end='')
self.time_elapsed = time.time() - self.tstart
print('Elapsed Time: %s (s)' % self.time_elapsed)