基本上,如何测试/ while循环。这甚至是一件事吗?我应该只测试计算的输出并查看它是否正确?
此代码如下。它是一个在(较大的)图像上运行模板的函数。
def _scan_image(self, image, template, process):
"""main function: will iterate over the image one pixel at a time"""
for i in xrange(len(image)): # --------> I want to test inside this loop
for j in xrange(len(image[i])):
if (j <= self.x_axis_leng) and \
(i <= self.y_axis_hgt):
self.temp_matrix_holder.append(\
image[i][j:j+len(template[0])])
self.temp_matrix_holder.append(\
image[i + 1][j:j+len(template[0])])
new_score = self.calculate.run(\
self.temp_matrix_holder, self.temp, process)
if new_score <= self.score:
self.score = new_score
self.best_location = [j, i]
self._empty_list()
return self.score, self.best_location