I have written a simple function to do a baseline substraction of my spectrum using numpy. The code looks like this:
import numpy as np
def bas_sub(baseline_y, spectrum_y):
try:
len(baseline_y)==len(spectrum_y)
spectrum_new = np.copy(spectrum_y)-baseline_y
return spectrum_new
except:
print 'Baseline and spectrum shoud have the same length.'
Where baseline and spectrum are two 1D numpy arrays. What I want my function to do is a simple length check, i.e. if the baseline and spectrum have different length the function should print the message: 'Baseline and spectrum should have the same length'. The function works well with input of equal length but it fails in printing the message with input of different length. In the last case the function output is a NoneType object. What do I do wrong? Thanks