-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtools.py
More file actions
31 lines (27 loc) · 693 Bytes
/
tools.py
File metadata and controls
31 lines (27 loc) · 693 Bytes
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
from subproc import run_subproc
def normal_distribution(mu, sigma):
return lambda x: 1.0/(sigma*sqrt(2*pi))*exp(-(x-mu)*(x-mu)/(2*sigma*sigma))
def drange(start, stop, step):
r = start
if(stop > start):
while r < stop:
yield r
r += step
else:
while r > stop:
yield r
r += step
def save_obj(obj, filename ):
try:
cPickle
except:
import cPickle
with open(filename, 'wb') as f:
cPickle.dump(obj, f, cPickle.HIGHEST_PROTOCOL)
def load_obj(filename):
try:
cPickle
except:
import cPickle
with open(filename, 'rb') as f:
return cPickle.load(f)