我想用自动四舍五入将int16数组与float数组相乘,但这失败了:
import numpy
A = numpy.array([1, 2, 3, 4], dtype=numpy.int16)
B = numpy.array([0.5, 2.1, 3, 4], dtype=numpy.float64)
A *= B我得到:
TypeError:不能通过转换规则“same_kind”将ufunc从dtype('float64')到dtype('int16')的输出相乘
发布于 2016-07-30 19:18:09
import numpy as np
A = np.float_(A)
A *= B尝尝这个。我认为是不同的数组类型,你会失败。
投射
https://stackoverflow.com/questions/38673531
复制相似问题