我一直试图在我继承的cython程序中追踪段错误的来源。 我已经通过执行gdb python3在python3下实现了gdb,然后run my_file.py并得到了这个:
Program received signal SIGSEGV, Segmentation fault. __pyx_f_7sklearn_5utils_25graph_shortest_path_leftmost_sibling (__pyx_v_node=<optimised out>) at /home/my_name/.pyxbld/temp.linux-x86_64-3.4/pyrex/sklearn/utils/graph_shortest_path_strat.c:3195 3195 __pyx_t_1 = (__pyx_v_temp->left_sibling != 0);谢谢@Veedrac电话会议如下:
landmark_points=[random.randint(0,kng.shape[0]) for r in range(self.number_landmark_points)] self.dist_matrix_=graph_shortest_path_strat(kng,landmark_points,method=self.path_method,directed=False).基本上不是计算图中每个点之间的距离,而是想要计算所有点之间的距离和数组中定义的有限数量的点。 其中landmark_points是整数数组,kng是最近邻居的图表
kng = kneighbors_graph(self.nbrs_, self.n_neighbors,mode='distance')graph_shortest_path是一个.pyx代码。 我使用的版本是0.15.1
I have been trying to trace the source of a segfault in a cython program that I inherited. I have implemented gdb under python3 by executing gdb python3 then run my_file.py and got this:
Program received signal SIGSEGV, Segmentation fault. __pyx_f_7sklearn_5utils_25graph_shortest_path_leftmost_sibling (__pyx_v_node=<optimised out>) at /home/my_name/.pyxbld/temp.linux-x86_64-3.4/pyrex/sklearn/utils/graph_shortest_path_strat.c:3195 3195 __pyx_t_1 = (__pyx_v_temp->left_sibling != 0);Thanks @Veedrac The call appears as follows:
landmark_points=[random.randint(0,kng.shape[0]) for r in range(self.number_landmark_points)] self.dist_matrix_=graph_shortest_path_strat(kng,landmark_points,method=self.path_method,directed=False).Basically instead of calculating the distances between every single point in a graph I want to calculate the distance between all points and a limited number of points defined in an array. where landmark_points is an array of integers kng is a graph of nearest neighbors
kng = kneighbors_graph(self.nbrs_, self.n_neighbors,mode='distance')the graph_shortest_path is a .pyx code. And I am using version is 0.15.1
最满意答案
@Veedrac感谢您的帮助。 我实际上追溯到我使用random.randint的事实,当我应该用random.sample生成唯一的随机整数时。
@Veedrac thanks for your help. I actually traced the error to the fact that I was using random.randint, when I should have been generating unique random integers with random.sample.
更多推荐
发布评论