Skip to content

Commit

Permalink
Clean up test_chunksize_fails()
Browse files Browse the repository at this point in the history
  • Loading branch information
timhoffm committed Jul 12, 2022
1 parent f5ffdb8 commit a10b4c5
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions lib/matplotlib/tests/test_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,50 +286,46 @@ def test_chunksize_fails():
w = 5*dpi
h = 6*dpi

# just fit in the width
# make a Path that spans the whole w-h rectangle
x = np.linspace(0, w, N)
# and go top-to-bottom
y = np.ones(N) * h
y[::2] = 0
path = Path(np.vstack((x, y)).T)
# effectively disable path simplification (but leaving it "on")
path.simplify_threshold = 0

idt = IdentityTransform()
# make a renderer
# setup the minimal GraphicsContext to draw a Path
ra = RendererAgg(w, h, dpi)
# setup the minimal gc to draw a line
gc = ra.new_gc()
gc.set_linewidth(1)
gc.set_foreground('r')
# make a Path
p = Path(np.vstack((x, y)).T)
# effectively disable path simplification (but leaving it "on")
p.simplify_threshold = 0

gc.set_hatch('/')
with pytest.raises(OverflowError, match='hatched path'):
ra.draw_path(gc, p, idt)
with pytest.raises(OverflowError, match='can not split hatched path'):
ra.draw_path(gc, path, IdentityTransform())
gc.set_hatch(None)

with pytest.raises(OverflowError, match='filled path'):
ra.draw_path(gc, p, idt, (1, 0, 0))
with pytest.raises(OverflowError, match='can not split filled path'):
ra.draw_path(gc, path, IdentityTransform(), (1, 0, 0))

# Set to zero to disable, currently defaults to 0, but let's be sure.
with rc_context({'agg.path.chunksize': 0}):
with pytest.raises(OverflowError, match='Please set'):
ra.draw_path(gc, p, idt)
ra.draw_path(gc, path, IdentityTransform())

# Set big enough that we do not try to chunk.
with rc_context({'agg.path.chunksize': 1_000_000}):
with pytest.raises(OverflowError, match='Please reduce'):
ra.draw_path(gc, p, idt)
ra.draw_path(gc, path, IdentityTransform())

# Small enough we will try to chunk, but big enough we will fail to render.
with rc_context({'agg.path.chunksize': 90_000}):
with pytest.raises(OverflowError, match='Please reduce'):
ra.draw_path(gc, p, idt)
ra.draw_path(gc, path, IdentityTransform())

p.should_simplify = False
path.should_simplify = False
with pytest.raises(OverflowError, match="should_simplify is False"):
ra.draw_path(gc, p, idt)
ra.draw_path(gc, path, IdentityTransform())


def test_non_tuple_rgbaface():
Expand Down

0 comments on commit a10b4c5

Please sign in to comment.