Пример #1
0
def test_cy_py_same():
    signal = np.arange(20, dtype=np.float32)

    cy_result = agc_cython.agc(4, signal)
    py_result = agc_python.agc(4, signal)
    c_cy_result = agc_c_cy.agc(4, signal)
#    sub_result = agc_subroutine.agc(4, signal)

    print "cy:", cy_result
    print "py:", py_result
    print "c_cy", c_cy_result
#    print "subroutine", sub_result

    assert np.array_equal(cy_result, py_result)
    assert np.array_equal(cy_result, c_cy_result)
Пример #2
0
def test_cy_py_same():
    signal = np.arange(20, dtype=np.float32)

    cy_result = agc_cython.agc(4, signal)
    py_result = agc_python.agc(4, signal)
    c_cy_result = agc_c_cy.agc(4, signal)
    #    sub_result = agc_subroutine.agc(4, signal)

    print "cy:", cy_result
    print "py:", py_result
    print "c_cy", c_cy_result
    #    print "subroutine", sub_result

    assert np.array_equal(cy_result, py_result)
    assert np.array_equal(cy_result, c_cy_result)
Пример #3
0
t = np.linspace(0,20,100).astype(np.float32)

signal = np.sin(t)

# add some noise
signal += (np.random.random(signal.shape)-0.5) * 0.3

# create an array for the result:
#filtered = np.zeros_like(signal)

# run it through the AGC filter:
filtered = agc_subroutine.agc(10, signal)

# try the python version
filtered2 = agc_python.agc(10, signal)

if np.allclose(filtered2, filtered2):
	print "the same"
else:
	print "not the same"

## plot the results

fig = plt.figure(figsize=(10,5))
ax = fig.add_subplot(1,1,1)
ax.plot(t, signal, t, filtered, t, filtered2)

plt.show()