Skip to content

Commit 8a009fa

Browse files
committed
Add test for checking barb magnitudes before plotting
1 parent 58e229a commit 8a009fa

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/plots/test_declarative.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,31 @@ def test_no_field_error_barbs():
565565
barbs.draw()
566566

567567

568+
@needs_cartopy
569+
def test_too_big_error_barbs():
570+
"""Make sure we get an error when we are about to draw too many pennants."""
571+
data = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)).squeeze()
572+
573+
bp = BarbPlot()
574+
bp.data = data
575+
bp.field = ['u_wind', 'v_wind']
576+
bp.level = 500
577+
bp.scale = 1e4
578+
bp.skip = [8, 8]
579+
580+
mp = MapPanel()
581+
mp.layout = (1, 1, 1)
582+
mp.area = (-100, -70, 30, 45)
583+
mp.plots = [bp]
584+
585+
pc = PanelContainer()
586+
pc.size = (10, 8)
587+
pc.panels = [mp]
588+
589+
with pytest.raises(ValueError):
590+
pc.draw()
591+
592+
568593
@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.377)
569594
def test_projection_object(ccrs, cfeature):
570595
"""Test that we can pass a custom map projection."""

0 commit comments

Comments
 (0)