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

Function test_metrics_cache2

lib/matplotlib/tests/test_text.py:879–903  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

877
878
879def test_metrics_cache2():
880 # dig into the signature to get the mutable default used as a cache
881 renderer_cache = inspect.signature(
882 mpl.text._get_text_metrics_function
883 ).parameters['_cache'].default
884 gc.collect()
885 renderer_cache.clear()
886
887 def helper():
888 fig, ax = plt.subplots()
889 fig.draw_without_rendering()
890 # show we hit the outer cache
891 assert len(renderer_cache) == 1
892 func = renderer_cache[fig.canvas.get_renderer()]
893 cache_info = func.cache_info()
894 # show we hit the inner cache
895 assert cache_info.currsize > 0
896 assert cache_info.currsize == cache_info.misses
897 assert cache_info.hits > cache_info.misses
898 plt.close(fig)
899
900 helper()
901 gc.collect()
902 # show the outer cache has a lifetime tied to the renderer (via the figure)
903 assert len(renderer_cache) == 0
904
905
906def test_annotate_offset_fontsize():

Callers

nothing calls this directly

Calls 2

helperFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…