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

Function test_clip_path_ids_reuse

lib/matplotlib/tests/test_backend_svg.py:307–331  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

305
306
307def test_clip_path_ids_reuse():
308 fig, circle = Figure(), Circle((0, 0), radius=10)
309 for i in range(5):
310 ax = fig.add_subplot()
311 aimg = ax.imshow([[i]])
312 aimg.set_clip_path(circle)
313
314 inner_circle = Circle((0, 0), radius=1)
315 ax = fig.add_subplot()
316 aimg = ax.imshow([[0]])
317 aimg.set_clip_path(inner_circle)
318
319 with BytesIO() as fd:
320 fig.savefig(fd, format='svg')
321 buf = fd.getvalue()
322
323 tree = xml.etree.ElementTree.fromstring(buf)
324 ns = 'http://www.w3.org/2000/svg'
325
326 clip_path_ids = set()
327 for node in tree.findall(f'.//{{{ns}}}clipPath[@id]'):
328 node_id = node.attrib['id']
329 assert node_id not in clip_path_ids # assert ID uniqueness
330 clip_path_ids.add(node_id)
331 assert len(clip_path_ids) == 2 # only two clipPaths despite reuse in multiple axes
332
333
334def test_savefig_tight():

Callers

nothing calls this directly

Calls 7

FigureClass · 0.90
CircleClass · 0.90
add_subplotMethod · 0.80
imshowMethod · 0.80
set_clip_pathMethod · 0.45
savefigMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…