-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
35 lines (28 loc) · 1.06 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
import os, csv, numpy as np
def make_dir(dir):
if not os.path.exists(dir):
print("dir ( {} ) is made under {}".format(dir, os.getcwd()))
os.mkdir(dir)
list2str = lambda s: ', '.join(map(str, s))
def write_csv(rowTitle, row, file_name='res'):
print('csv Title {}\n row {}'.format(rowTitle, row))
make_dir('result')
with open('res/{}.csv'.format(file_name), 'a', newline='') as csvFile:
writer = csv.writer(csvFile)
if len(rowTitle)>0:
writer.writerow(rowTitle)
if len(row)>0:
writer.writerow(row)
csvFile.close()
intersection = lambda lst1, lst2: [value for value in lst1 if value in lst2]
from datetime import datetime
from pytz import timezone, utc
def get_pst_time():
date_format='%m-%d-%Y--%H-%M-%S-%Z'
date = datetime.now(tz=utc)
date = date.astimezone(timezone('US/Pacific'))
pstDateTime=date.strftime(date_format)
# pstDateTime = pd.Timestamp.today()
return pstDateTime
def sigmoid(x):
return np.where(x >= 0, 1 / (1 + np.exp(-x)), np.exp(x) / (1 + np.exp(x)))