wrong output using numpy fft on a tone I am getting the wrong output with the following simple implementation of Python fft.  Can someone please explain what I need to fix?

import numpy as np
import matplotlib.pyplot as plt


def tone(fs, frequency, dur=1, amp=50):
    '''
    test tone
    '''
    nsamples = dur * fs
    t = np.linspace(0, dur, nsamples, endpoint=False)

    tone = amp*np.sin(frequency*2*np.pi*t)
    return tone

fs = 16000
dur = 0.5
freq = 1500

stim = tone(fs, freq, dur=dur)
time = np.linspace(0, dur, num=fs*dur)

t = np.linspace(0, fs, num=fs*dur)
fdata = np.fft.fft(stim)

hwp = int(np.shape(fdata)[0]/2)
tplt = t[:hwp]
fplt = fdata[:hwp]

plt.figure(num=1)
plt.plot(time, stim, 'b-')
plt.show()

plt.figure(num=2)
plt.plot(tplt, np.abs(fplt.real), 'b-')
plt.xscale('log')
plt.show()




Removing 

, endpoint = False

will fix the implementation though I do not understand why.
Perhaps someone can explain(?)
UPDATE: I suspected Spectral Leakage but that is not the case here. The reason for this is the OP is choosing to plot just the real component of the FFT, with a linear magnitude scale so the actual effect of the spectral leakage cannot be seen. (We actually get spectral leakage when we use endpoint = true!). If you change the plot from fplt.real to np.abs(fplt) you will see the true magnitude plot that must include the real and imaginary components!).

Here is the result with endpoint = true and plotting the dB of the magnitude.
plt.plot(tplt, 20*np.log10(np.abs(fplt)), 'b-'). The spectral leakage in this case is quite clear!



Here is the result with endpoint = false using
plt.plot(tplt, 20*np.log10(np.abs(fplt)), 'b-')

Here we see noise that is nearly 300 dB down (floating point precision).