@@ -191,10 +191,21 @@ def test_plot_evoked_field(renderer):
191191 ch_type = t ,
192192 )
193193 evoked .plot_field (maps , time = 0.1 , n_contours = n_contours )
194+ renderer .backend ._close_all ()
194195
195- # Test plotting inside an existing Brain figure.
196- brain = Brain ("fsaverage" , "lh" , "inflated" , subjects_dir = subjects_dir )
197- fig = evoked .plot_field (maps , time = 0.1 , fig = brain )
196+ # Test plotting inside an existing Brain figure. Check that units are taken into
197+ # account.
198+ for units in ["mm" , "m" ]:
199+ brain = Brain (
200+ "fsaverage" , "lh" , "inflated" , units = units , subjects_dir = subjects_dir
201+ )
202+ fig = evoked .plot_field (maps , time = 0.1 , fig = brain )
203+ assert brain ._units == fig ._units
204+ scale = 1000 if units == "mm" else 1
205+ assert (
206+ fig ._surf_maps [0 ]["surf" ]["rr" ][0 , 0 ] == scale * maps [0 ]["surf" ]["rr" ][0 , 0 ]
207+ )
208+ renderer .backend ._close_all ()
198209
199210 # Test some methods
200211 fig = evoked .plot_field (maps , time_viewer = True )
@@ -214,6 +225,7 @@ def test_plot_evoked_field(renderer):
214225
215226 fig = evoked .plot_field (maps , time_viewer = False )
216227 assert isinstance (fig , Figure3D )
228+ renderer .backend ._close_all ()
217229
218230
219231@testing .requires_testing_data
0 commit comments