Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_pyplot():
backend = plt.get_backend()
plt.switch_backend("agg")
x = y = [0, 1, 2]
plt.plot(x, y)
plt.switch_backend(backend)
img = imgviz.io.pyplot_to_numpy()
assert isinstance(img, np.ndarray)
assert img.ndim == 3
plt.subplot(131)
plt.title("+img")
plt.imshow(labelviz_withimg)
plt.axis("off")
plt.subplot(132)
plt.title("loc=centroid")
plt.imshow(labelviz_withname1)
plt.axis("off")
plt.subplot(133)
plt.title("loc=rb")
plt.imshow(labelviz_withname2)
plt.axis("off")
img = imgviz.io.pyplot_to_numpy()
plt.close()
return img
# -------------------------------------------------------------------------
plt.figure(dpi=200)
plt.subplot(121)
plt.title("rgb:\n{}".format(rgb.shape))
plt.imshow(rgb)
plt.axis("off")
plt.subplot(122)
plt.title("rgb_resized:\n{}".format(rgb_resized.shape))
plt.imshow(rgb_resized)
plt.axis("off")
img = imgviz.io.pyplot_to_numpy()
plt.close()
return img
# -------------------------------------------------------------------------
plt.figure(dpi=200)
plt.subplot(121)
plt.title("rgb")
plt.imshow(data["rgb"])
plt.axis("off")
plt.subplot(122)
plt.title("depth (colorized)")
plt.imshow(depthviz)
plt.axis("off")
img = imgviz.io.pyplot_to_numpy()
plt.close()
return img
# -------------------------------------------------------------------------
plt.figure(dpi=200)
plt.subplot(121)
plt.title("image")
plt.imshow(rgb)
plt.axis("off")
plt.subplot(122)
plt.title("flow")
plt.imshow(flowviz)
plt.axis("off")
img = imgviz.io.pyplot_to_numpy()
plt.close()
return img
plt.subplot(131)
plt.title("original")
plt.axis("off")
plt.imshow(rgb)
plt.subplot(132)
plt.title("centerized1:\n{}".format(centerized1.shape))
plt.imshow(centerized1)
plt.axis("off")
plt.subplot(133)
plt.title("centerized2:\n{}".format(centerized2.shape))
plt.imshow(centerized2)
plt.axis("off")
return imgviz.io.pyplot_to_numpy()
# -------------------------------------------------------------------------
plt.figure(dpi=200)
plt.subplot(121)
plt.title("rgb")
plt.imshow(data["rgb"])
plt.axis("off")
plt.subplot(122)
plt.title("res4 (colorized)")
plt.imshow(nchannel_viz)
plt.axis("off")
img = imgviz.io.pyplot_to_numpy()
plt.close()
return img
# -------------------------------------------------------------------------
plt.figure(dpi=200)
plt.subplot(121)
plt.title("original")
plt.imshow(rgb)
plt.axis("off")
plt.subplot(122)
plt.title("instances")
plt.imshow(tiled)
plt.axis("off")
img = imgviz.io.pyplot_to_numpy()
plt.close()
return img