common.loads() should return time only if asked to

This commit is contained in:
Roman Zeyde
2014-07-21 13:29:27 +03:00
parent 5d71431c7c
commit 3ccf4ff188
5 changed files with 15 additions and 10 deletions

View File

@@ -42,15 +42,21 @@ def to_byte(bits):
return chr(byte)
def load(fileobj):
return loads(fileobj.read())
def load(fileobj, time=False):
return loads(fileobj.read(), time=time)
def loads(data):
def loads(data, time=False):
x = np.fromstring(data, dtype='int16')
x = x / scaling
t = np.arange(len(x)) / Fs
return t, x
if np.max(np.abs(x)) > SATURATION_THRESHOLD:
raise ValueError('saturation')
if time:
t = np.arange(len(x)) / Fs
return t, x
else:
return x
def dumps(sym, n=1):