@@ -136,16 +136,35 @@ def test_fig_parameter_default_no_warning(sdata_blobs: SpatialData):
136136 plt .close ("all" )
137137
138138
139- def test_fig_parameter_no_warning_with_ax_list (sdata_blobs : SpatialData ):
140- """Passing fig= with a list of axes should not warn (fig is still required there )."""
139+ def test_fig_parameter_warns_with_ax_list (sdata_blobs : SpatialData ):
140+ """Passing fig= alongside a list of axes should also emit the deprecation (regression for #625 )."""
141141 set_transformation (sdata_blobs ["blobs_image" ], Identity (), "second_cs" )
142142 fig , axs = plt .subplots (1 , 2 )
143- with warnings .catch_warnings ():
144- warnings .simplefilter ("error" , DeprecationWarning )
143+ with pytest .warns (DeprecationWarning , match = "`fig` is being deprecated" ):
145144 sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (fig = fig , ax = list (axs ), show = False )
146145 plt .close ("all" )
147146
148147
148+ def test_show_ax_list_infers_fig (sdata_blobs : SpatialData ):
149+ """show(ax=[...]) should infer fig from the axes without requiring fig= (regression for #625)."""
150+ set_transformation (sdata_blobs ["blobs_image" ], Identity (), "second_cs" )
151+ fig , axs = plt .subplots (1 , 2 )
152+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (ax = list (axs ), show = False )
153+ for ax in axs :
154+ assert ax .get_figure () is fig
155+ assert len (ax .get_images ()) > 0
156+ plt .close (fig )
157+
158+
159+ def test_show_single_panel_accepts_ax_list (sdata_blobs : SpatialData ):
160+ """show(ax=[ax]) for a single coordinate system should be accepted (regression for #625)."""
161+ fig , ax = plt .subplots ()
162+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (ax = [ax ], show = False )
163+ assert ax .get_figure () is fig
164+ assert len (ax .get_images ()) > 0
165+ plt .close (fig )
166+
167+
149168def test_frameon_false_multi_panel (sdata_blobs : SpatialData ):
150169 """frameon=False should apply to all panels in a multi-panel plot (regression for #204)."""
151170 set_transformation (sdata_blobs ["blobs_image" ], Identity (), "second_cs" )
0 commit comments