use real part at common.dumps()

This commit is contained in:
Roman Zeyde
2014-08-08 14:50:07 +03:00
parent 841208bd3f
commit 9a6ca77aa4
4 changed files with 4 additions and 4 deletions

View File

@@ -47,7 +47,7 @@ def loads(data):
def dumps(sym, n=1): def dumps(sym, n=1):
sym = sym.imag * scaling sym = sym.real * scaling
sym = sym.astype('int16') sym = sym.astype('int16')
data = sym.tostring() data = sym.tostring()
return data * n return data * n

View File

@@ -76,5 +76,5 @@ if __name__ == '__main__':
sampler = Sampler(x, Interpolator()) sampler = Sampler(x, Interpolator())
sampler.freq += df sampler.freq += df
y = np.array(list(sampler)) y = np.array(list(sampler))
y = common.dumps(y*1j) y = common.dumps(y)
sys.stdout.write(y) sys.stdout.write(y)

View File

@@ -49,5 +49,5 @@ def test_icapture():
def test_dumps_loads(): def test_dumps_loads():
x = np.array([.1, .4, .2, .6, .3, .5]) x = np.array([.1, .4, .2, .6, .3, .5])
y = common.loads(common.dumps(x * 1j)) y = common.loads(common.dumps(x))
assert all(x == y) assert all(x == y)

View File

@@ -29,7 +29,7 @@ def run(size, chan):
data = tx_audio.getvalue() data = tx_audio.getvalue()
data = common.loads(data) data = common.loads(data)
data = chan(data) data = chan(data)
data = common.dumps(data * 1j) data = common.dumps(data)
rx_audio = BytesIO(data) rx_audio = BytesIO(data)
rx_data = BytesIO() rx_data = BytesIO()