@@ -607,3 +607,37 @@ def test_cartesian_and_geo():
607607 ax [0 ]._apply_axis_sharing ()
608608 assert mocked .call_count == 1
609609 return fig
610+
611+
612+ def test_check_tricontourf ():
613+ """
614+ Ensure that tricontour functions are getting
615+ the transform for GeoAxes.
616+ """
617+ import cartopy .crs as ccrs
618+
619+ lon0 = 90
620+ lon = np .linspace (- 180 , 180 , 10 )
621+ lat = np .linspace (- 90 , 90 , 10 )
622+ lon2d , lat2d = np .meshgrid (lon , lat )
623+
624+ data = np .sin (3 * np .radians (lat2d )) * np .cos (2 * np .radians (lon2d ))
625+ # Place a box with constant values in order to have a visual reference
626+ mask_box = (lon2d >= 0 ) & (lon2d <= 20 ) & (lat2d >= 0 ) & (lat2d <= 20 )
627+ data [mask_box ] = 1.5
628+
629+ lon , lat , data = map (np .ravel , (lon2d , lat2d , data ))
630+
631+ fig , ax = uplt .subplots (proj = "cyl" , proj_kw = {"lon0" : lon0 })
632+ original_func = ax [0 ]._call_native
633+ with mock .patch .object (
634+ ax [0 ],
635+ "_call_native" ,
636+ autospec = True ,
637+ side_effect = original_func ,
638+ ) as mocked :
639+ for func in "tricontour tricontourf" .split ():
640+ getattr (ax [0 ], func )(lon , lat , data )
641+ assert "transform" in mocked .call_args .kwargs
642+ assert isinstance (mocked .call_args .kwargs ["transform" ], ccrs .PlateCarree )
643+ uplt .close (fig )
0 commit comments