1 def auto_correlate(x):
2 cor = np.correlate(x,x,mode="full")
3 return cor[N-1:]
4 c = np.zeros(N)
5 c = auto_correlate(x-ave)/N
6 plt.plot(c)
7 plt.xlim(-1000, 10000)
8 plt.xlabel(r'$i$',fontsize=16)
9 plt.ylabel(r'$\varphi(i)$',fontsize=16)
10 print('\sigma^2 = ', std**2)
11 plt.show()
Why do I keep getting error 'tuple' object not callable online 7 ? please explain
The Python "TypeError: 'tuple' object is not callable" occurs when we try to call a tuple as if it were a function. To solve the error, make sure to use square brackets when accessing a tuple at a specific index, e.g. my_tuple[0] .
To summarize, TypeError' tuple' object is not callable occurs when you try to call a tuple as if it were a function. To solve this error, ensure when you are defining multiple tuples in a container like a list that you use commas to separate them.
It looks like you may have overwritten the plt.xlim function.
Did you perhaps run plt.xlim=(-1000, 10000)
? (note the "=")
type plt.xlim
and run it to check.
Output should be something like:
<function matplotlib.pyplot.xlim(*args, **kwargs)>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With