-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.py
47 lines (37 loc) · 805 Bytes
/
tools.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
41
42
43
44
45
try:
import cPickle
except:
import _pickle as cPickle
import sys, os
import zlib
def checkdir(path):
if not os.path.exists(path):
os.makedirs(path)
def save(data,name):
cPickle.dumps(data)
compressed=zlib.compress(cPickle.dumps(data))
f=open(name,"wb")
f.write(compressed)
f.close()
def load(name):
compressed=open(name,"rb").read()
data=cPickle.loads(zlib.decompress(compressed))
return data
def load2(name):
compressed=open(name,"rb").read()
data=cPickle.loads(compressed)
return data
def isnumeric(value):
try:
int(value)
return True
except:
return False
return r'$\mathrm{'+x+'}$'
def ERR(msg):
print(msg)
sys.exit()
def lprint(msg):
sys.stdout.write('\r')
sys.stdout.write(msg)
sys.stdout.flush()