MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_repeated_save_with_alpha

Function test_repeated_save_with_alpha

lib/matplotlib/tests/test_agg.py:28–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27
28def test_repeated_save_with_alpha():
29 # We want an image which has a background color of bluish green, with an
30 # alpha of 0.25.
31
32 fig = Figure([1, 0.4])
33 fig.set_facecolor((0, 1, 0.4))
34 fig.patch.set_alpha(0.25)
35
36 # The target color is fig.patch.get_facecolor()
37
38 buf = io.BytesIO()
39
40 fig.savefig(buf,
41 facecolor=fig.get_facecolor(),
42 edgecolor='none')
43
44 # Save the figure again to check that the
45 # colors don't bleed from the previous renderer.
46 buf.seek(0)
47 fig.savefig(buf,
48 facecolor=fig.get_facecolor(),
49 edgecolor='none')
50
51 # Check the first pixel has the desired color & alpha
52 # (approx: 0, 1.0, 0.4, 0.25)
53 buf.seek(0)
54 assert_array_almost_equal(tuple(imread(buf)[0, 0]),
55 (0.0, 1.0, 0.4, 0.250),
56 decimal=3)
57
58
59def test_large_single_path_collection():

Callers

nothing calls this directly

Calls 6

savefigMethod · 0.95
FigureClass · 0.90
imreadFunction · 0.90
set_facecolorMethod · 0.45
set_alphaMethod · 0.45
get_facecolorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…