的结果math.factorial(21)
是Python长。numpy无法将其转换为其数字类型之一,因此将其保留为dtype=object
。一元函数对对象数组的工作方式是,它们只是尝试在对象上调用相同名称的方法。例如
np.log(np.array([x], dtype=object)) <-> np.array([x.log()], dtype=object)
由于.log()
Python上没有方法,因此您可以得到AttributeError
。
python + numpy:如果numpy.log的操作数太大,为什么会抛出属性错误?
的结果math.factorial(21)
是Python长。numpy无法将其转换为其数字类型之一,因此将其保留为dtype=object
。一元函数对对象数组的工作方式是,它们只是尝试在对象上调用相同名称的方法。例如
np.log(np.array([x], dtype=object)) <-> np.array([x.log()], dtype=object)
由于.log()
Python上没有方法,因此您可以得到AttributeError
。