我正在尝试编写一个检查结构是否不超出范围的函数。结构和球面均位于以numpy数组表示的切片中。当结构突出时,我将半径增加10%,并想要创建新结构。除了我显示结构和球体时,结构仍然突出,一切似乎都正常。看起来带有球形的数组根本没有更新。可能是什么原因?
sphere_masks = list()
for slice, distance_matrix in self.distance_matrices:
sphere = distance_matrix <= self.radius
if sphere.any() and smooth:
sphere = self._smooth_circle(sphere)
sphere_masks.append((slice, sphere))
print("Radius = " + str(self.radius))
sphere_masks_all = list()
[sphere_masks_all.append(np.zeros(np.shape(mask))) for mask in self.series_masks]
sphere_masks_all[sphere_masks[0][0] : (sphere_masks[-1][0] + 1)] = [mask for _, mask in sphere_masks]
if self.sphere_type == "circumscribed":
for i, struct in enumerate(self.series_masks):
intersection = np.logical_and(sphere_masks[i][1], struct.astype(bool))
if np.count_nonzero(struct) != np.count_nonzero(intersection):
print(str(i))
self.radius = 1.1 * self.radius
#function calls itself
self._create_sphere_masks()
return sphere_masks_all
答案 0 :(得分:0)
return self._create_sphere_masks()