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

Function test_chunksize_fails

lib/matplotlib/tests/test_agg.py:331–381  ·  view source on GitHub ↗
(high_memory)

Source from the content-addressed store, hash-verified

329
330
331def test_chunksize_fails(high_memory):
332 # NOTE: This test covers multiple independent test scenarios in a single
333 # function, because each scenario uses ~2GB of memory and we don't
334 # want parallel test executors to accidentally run multiple of these
335 # at the same time.
336
337 N = 100_000
338 dpi = 500
339 w = 5*dpi
340 h = 6*dpi
341
342 # make a Path that spans the whole w-h rectangle
343 x = np.linspace(0, w, N)
344 y = np.ones(N) * h
345 y[::2] = 0
346 path = Path(np.vstack((x, y)).T)
347 # effectively disable path simplification (but leaving it "on")
348 path.simplify_threshold = 0
349
350 # setup the minimal GraphicsContext to draw a Path
351 ra = RendererAgg(w, h, dpi)
352 gc = ra.new_gc()
353 gc.set_linewidth(1)
354 gc.set_foreground('r')
355
356 gc.set_hatch('/')
357 with pytest.raises(OverflowError, match='cannot split hatched path'):
358 ra.draw_path(gc, path, IdentityTransform())
359 gc.set_hatch(None)
360
361 with pytest.raises(OverflowError, match='cannot split filled path'):
362 ra.draw_path(gc, path, IdentityTransform(), (1, 0, 0))
363
364 # Set to zero to disable, currently defaults to 0, but let's be sure.
365 with rc_context({'agg.path.chunksize': 0}):
366 with pytest.raises(OverflowError, match='Please set'):
367 ra.draw_path(gc, path, IdentityTransform())
368
369 # Set big enough that we do not try to chunk.
370 with rc_context({'agg.path.chunksize': 1_000_000}):
371 with pytest.raises(OverflowError, match='Please reduce'):
372 ra.draw_path(gc, path, IdentityTransform())
373
374 # Small enough we will try to chunk, but big enough we will fail to render.
375 with rc_context({'agg.path.chunksize': 90_000}):
376 with pytest.raises(OverflowError, match='Please reduce'):
377 ra.draw_path(gc, path, IdentityTransform())
378
379 path.should_simplify = False
380 with pytest.raises(OverflowError, match="should_simplify is False"):
381 ra.draw_path(gc, path, IdentityTransform())
382
383
384def test_non_tuple_rgbaface():

Callers

nothing calls this directly

Calls 9

draw_pathMethod · 0.95
PathClass · 0.90
RendererAggClass · 0.90
IdentityTransformClass · 0.90
rc_contextFunction · 0.90
new_gcMethod · 0.45
set_linewidthMethod · 0.45
set_foregroundMethod · 0.45
set_hatchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…