Commit e83bc5cc authored by Jean Ibarz's avatar Jean Ibarz
Browse files

Added a test to visually check that scipy.signal.convolve modes {'full',...

Added a test to visually check that scipy.signal.convolve modes {'full', 'valid', 'same'} have the correct behavior.
parent 0c586bf2
def test_convolve_valid():
"""
test to visually check that scipy.signal.convolve modes {'full', 'valid', 'same'}
have the correct behavior.
:return:
"""
import scipy.signal
import numpy as np
in1 = np.ones(shape=(100,1))
in2 = np.ones(shape=(10,1))
r_full = scipy.signal.convolve(in1=in1, in2=in2, mode='full')
assert len(r_full) == len(in1)+len(in2)-1
r_valid = scipy.signal.convolve(in1=in1, in2=in2, mode='valid')
assert len(r_valid) == len(in1)-len(in2)+1
r_same = scipy.signal.convolve(in1=in1, in2=in2, mode='same')
assert len(r_same) == len(in1)
# import matplotlib.pyplot as plt
# plt.plot(r_full, label='r_full')
# plt.plot(r_valid+1, 'g', label='r_valid+1')
# plt.plot(r_same+2, 'b', label='r_same+2')
# plt.show()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment