【发布时间】:2020-06-11 20:21:39
【问题描述】:
我在使用以下功能时遇到问题。我无法弄清楚routes 参数结构。
def show_image(data, routes=[]):
'''
Given a list of lists of integers "data",
and an optional list of boolean list of lists "routes",
show the data as an image and overlay the routes on the image in red.
'''
image_data = [x[:] for x in data]
for i in range(len(image_data)):
for j in range(len(image_data[i])):
image_data[i][j] = [image_data[i][j]] * 3
if any(route[i][j] for route in routes):
image_data[i][j] = [255, 0, 0]
io.imshow(np.array(image_data, dtype=np.uint8))
io.show()
我有数据参数工作,但我不确定routes = []。我知道它需要一个"list of boolean list of lists",我假设它是这样的:
[[True, True], [False,False]]
有人可以给我一些虚拟的data 参数来看看它是如何工作的吗?谢谢
【问题讨论】:
标签: python function types parameters boolean