我正在尝试创建一个布尔数组来标识数组中的空列表。我做了以下代码:
import numpy as np
from scipy.spatial import cKDTree
rand_points = np.random.rand(5,3)
other_points = np.zeros((5,3))
for i in range(3):
other_points[:,i] = rand_points[:,i] * 2
randTree = cKDTree(rand_points)
nearPoints = cKDTree.query_ball_point(randTree, other_points, 0.6)
nearPoints
可以产生以下输出:
array([list([]), list([]), list([2]), list([]), list([])], dtype=object)
我想生成一个布尔数组,它选择等于list([ ])
as 的元素True
。我尝试了多种方法,但都没有成功,例如:
nearPoints == None
我将如何正确创建布尔数组?