TypeError: ‘numpy.int64‘ object is not callable 解决办法

<ipython-input-3-1f37d78639f5> in normalize_comx(num)
     27         imag = num.imag
     28         temp = np.sqrt( real* real+ imag* imag)#计算模值
---> 29         real=real/max(temp)#归一化
     30         imag = imag/max(temp) * 1j
     31         return real + imag

TypeError: 'numpy.int64' object is not callabl

 出现报错'numpy.int64' object is not callable,找了好久,报错这里代码没有问题。

原因是我在程序其它位置用了python内置函数max作为变量名

d=np.correlate(ta.imag, ta0.imag, "full")
max = np.argmax(d)
za=ta[max-d1:max]

有意思的是我第一次调用函数没报错,第二次max就冲突了

把max变量名改了就好了

d=np.correlate(ta.imag, ta0.imag, "full")
max _num= np.argmax(d)
za=ta[max _num-d1:max _num]

记住python以下内置函数,都不要用于变量名,Jupyter notebook用到这些会显示绿色的,注意。

同理也不要用自己写的函数作为变量名

  内置函数  
abs()divmod()input()open()staticmethod()
all()enumerate()int()ord()str()
any()eval()isinstance()pow()sum()
basestring()execfile()issubclass()print()super()
bin()file()iter()property()tuple()
bool()filter()len()range()type()
bytearray()float()list()raw_input()unichr()
callable()format()locals()reduce()unicode()
chr()frozenset()long()reload()vars()
classmethod()getattr()map()repr()xrange()
cmp()globals()max()reverse()zip()
compile()hasattr()memoryview()round()__import__()
complex()hash()min()set() 
delattr()help()next()setattr() 
dict()hex()object()slice() 
dir()id()oct()sorted()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值