I am trying to use np.where in a cython program to select where values are within a radius. Ususally this would work with numpy, but with cython I get
TypeError: 'tuple' object cannot be interpreted as an integer
def test(double[:,::1] array, double[:] point, double radius):
array = np.asarray(array)
idx = np.where(np.logical_and(np.greater_equal(array[:, 0], point[0] - radius), np.less_equal(array[:, 0], point[0] + radius)))
a = array[idx]
I tried doing this but got error
only integer scalar arrays can be converted to a scalar index
a = array[idx[0].astype(int)]
奇怪的是,即使我已经做了 np.asarray,它也能做到这一点
a = np.array(array)[idx[0]]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.