MCPcopy Create free account
hub / github.com/plotly/plotly.py / test_origin

Function test_origin

tests/test_optional/test_px/test_imshow.py:67–90  ·  view source on GitHub ↗
(binary_string, binary_format)

Source from the content-addressed store, hash-verified

65@pytest.mark.parametrize("binary_string", [False, True])
66@pytest.mark.parametrize("binary_format", ["png", "jpg"])
67def test_origin(binary_string, binary_format):
68 for i, img in enumerate([img_rgb, img_gray]):
69 fig = px.imshow(
70 img,
71 origin="lower",
72 binary_string=binary_string,
73 binary_format=binary_format,
74 )
75 assert fig.layout.yaxis.autorange is True
76 if binary_string and i == 0 and binary_format == "png":
77 # The equality below does not hold for jpeg compression since it's lossy
78 assert np.all(img[::-1] == decode_image_string(fig.data[0].source))
79 if binary_string:
80 if binary_format == "jpg":
81 assert fig.data[0].source[:15] == "data:image/jpeg"
82 else:
83 assert fig.data[0].source[:14] == "data:image/png"
84 fig = px.imshow(img_rgb, binary_string=binary_string)
85 assert fig.layout.yaxis.autorange is None
86 fig = px.imshow(img_gray, binary_string=binary_string)
87 if binary_string:
88 assert fig.layout.yaxis.autorange is None
89 else:
90 assert fig.layout.yaxis.autorange == "reversed"
91
92
93def test_colorscale():

Callers

nothing calls this directly

Calls 1

decode_image_stringFunction · 0.85

Tested by

no test coverage detected