私はこの 'int'オブジェクトが呼び出し可能なエラーでしばらくレスリングしていますが、まだ表示されています。ここに私のコードです:私のコードで 'Int'オブジェクト呼び出し可能なエラーがありません
import numpy as np
import matplotlib.pyplot as plt
def main_1(n):
"""executes part (a) of problem 1"""
def c_n1(n):
"""Finds constants for n terms"""
sum = 0
for i in range(-n, n+1):
sum += (((-1)**i)*27*np.sqrt(3)*i)/(2*np.pi*(1-9*(i**2)))
return sum
def f_n1(n, func):
"""function values using constant c_n values"""
lmbda = 2
k_n = (2*np.pi*n)/lmbda
sum = 0
x = 1
#range = int(2*x)
t_steps = 100
#delta_t = range/t_steps
f_t_values = np.zeros((t_steps))
t = np.linspace(-x, x, t_steps)
for i in t:
for j in range(-n, n+1):
sum += np.sin(k_n*i)*func(n)
f_t_values[i] = sum
return f_t_values, t
def plot(f_t_values, t):
"""plots f_t function over interval t"""
plt.plot(f_t_values, t)
plt.show
f_t_values, t = f_n1(n, c_n1)
plot(f_t_values, t)
print(f_t_values.shape)
print(t.shape)
main_1(5)
q = np.arange(1,2,100)
print(q.shape)
、ここでその生産エラーです:
TypeError Traceback (most recent call last)
<ipython-input-6-03432c50e4a9> in <module>()
39 print(t.shape)
40
---> 41 main_1(5)
42
43 q = np.arange(1,2,100)
<ipython-input-6-03432c50e4a9> in main_1(n)
34 plt.show
35
---> 36 f_t_values, t = f_n1(n, c_n1)
37 plot(f_t_values, t)
38 print(f_t_values.shape)
<ipython-input-6-03432c50e4a9> in f_n1(n, func)
24
25 for i in t:
---> 26 for j in range(-n, n+1):
27 sum += np.sin(k_n*i)*func(n)
28 f_t_values[i] = sum
TypeError: 'int' object is not callable
私はこのエラーは、私が「*」と、システムが機能としてそれを読み忘れていた意味の時間のほとんどを理解します2、例えば2(1-2 * n)である。私はその種の間違いを私のコードには見ないので、誰かが私が何が起こっているかを知るのを助けることができます。感謝:)
変数名に組み込み関数名を使用しないでください。または、問題を尋ねています –