diff --git a/py_wake/tests/notebook.py b/py_wake/tests/notebook.py index 6d4a93ba201313cc49c6afb6f4f4ac166f41f10b..eb9396644297a781d14a5df6ab096a38da406646 100644 --- a/py_wake/tests/notebook.py +++ b/py_wake/tests/notebook.py @@ -123,7 +123,7 @@ except ModuleNotFoundError: code_str = "def test():\n " + "\n ".join(lines) + "\ntest()" exec(code_str, l, {}) - plt.close() + plt.close('all') except Exception as e: raise type(e)("Code error in %s\n%s\n" % (self.filename, str(e))).with_traceback(sys.exc_info()[2]) diff --git a/py_wake/tests/test_deficit_models/test_fuga.py b/py_wake/tests/test_deficit_models/test_fuga.py index 726eb1b084fd50c4537478a7e17e3e3184c7c7cf..26d959a0b1af965d8d8ae401e005236ea3d19256 100644 --- a/py_wake/tests/test_deficit_models/test_fuga.py +++ b/py_wake/tests/test_deficit_models/test_fuga.py @@ -172,7 +172,7 @@ def test_fuga_downwind(): if 0: plt.show() - plt.close() + plt.close('all') def test_fuga_table_edges(): diff --git a/py_wake/tests/test_deflection_models/test_deflection_models.py b/py_wake/tests/test_deflection_models/test_deflection_models.py index 50110f41dce938c35859bfa7f2fd6650360c108b..0444aee84a086ce147efed65c3d868efd33d6c93 100644 --- a/py_wake/tests/test_deflection_models/test_deflection_models.py +++ b/py_wake/tests/test_deflection_models/test_deflection_models.py @@ -62,4 +62,4 @@ def test_plot_deflection_grid(deflectionModel): plt.legend() if 0: plt.show() - plt.close() + plt.close('all') diff --git a/py_wake/tests/test_flow_map.py b/py_wake/tests/test_flow_map.py index b225aba3819ccee5398ebb0dd3eaa14b221a07f1..f45874fc8632497fcedea13685dd670ed489d683 100644 --- a/py_wake/tests/test_flow_map.py +++ b/py_wake/tests/test_flow_map.py @@ -14,7 +14,7 @@ from py_wake.deflection_models.jimenez import JimenezWakeDeflection def close_plots(): yield try: - plt.close() + plt.close('all') except Exception: pass @@ -84,7 +84,7 @@ def test_YZGrid_plot_wake_map_perpendicular(): sim_res.flow_map(grid=YZGrid(x=-100, y=None, resolution=100, extend=.1), wd=270, ws=None).plot_wake_map() if 0: plt.show() - plt.close() + plt.close('all') def test_YZGrid_variables(): @@ -102,7 +102,7 @@ def test_YZGrid_variables(): if 0: print(np.round(fm.WS_eff.interp(h=110)[::10].squeeze().values, 4)) plt.show() - plt.close() + plt.close('all') npt.assert_array_almost_equal(fm.WS_eff.interp(h=110)[::10].squeeze(), [9.1461, 8.4157, 7.3239, 6.058, 5.022, 4.6455, 5.1019, 6.182, 7.446, 8.506], 4) @@ -120,7 +120,7 @@ def test_YZGrid_plot_wake_map_parallel(): sim_res.flow_map(grid=YZGrid(x=-450, y=None, resolution=100, extend=.1), wd=0, ws=None).plot_wake_map() if 0: plt.show() - plt.close() + plt.close('all') def test_YZGrid_terrain_perpendicular(): @@ -146,7 +146,7 @@ def test_YZGrid_terrain_perpendicular(): if 0: print(np.round(fm.WS_eff_xylk[:, 0, 0, 0], 2).values.tolist()) plt.show() - plt.close() + plt.close('all') npt.assert_array_almost_equal(fm.WS_eff_xylk[:, 0, 0, 0], [5.39, 8.48, 8.42, 6.42, 5.55, 11.02, 4.99, 11.47, 5.32, 10.22, 13.39, 8.79, 8.51, 12.4, 5.47, 10.78, 10.12, 6.54, 10.91, 7.18], 2) @@ -174,7 +174,7 @@ def test_YZGrid_terrain_parallel(): if 0: print(np.round(fm.WS_eff_xylk[:, 0, 0, 0], 2).values.tolist()) plt.show() - plt.close() + plt.close('all') npt.assert_array_almost_equal(fm.WS_eff_xylk[:, 0, 0, 0], [7.24, 7.24, 7.28, 7.42, 4.48, 6.14, 3.52, 4.98, 6.06, 7.18, 8.24, 8.64, 7.14, 7.28, 3.8, 5.72, 7.09, 7.49, 6.88, 6.15], 2) @@ -192,7 +192,7 @@ def test_Points(): if 0: flow_map.WS_eff.plot() plt.show() - plt.close() + plt.close('all') def test_not_implemented_plane(): diff --git a/py_wake/tests/test_ground_models/test_mirror.py b/py_wake/tests/test_ground_models/test_mirror.py index b15e7ad6639e5ae7ca2cb0b99189a2423a7252c3..79f63ec3a1fda38ee3fa863c398aca5d66d5a447 100644 --- a/py_wake/tests/test_ground_models/test_mirror.py +++ b/py_wake/tests/test_ground_models/test_mirror.py @@ -38,7 +38,7 @@ def test_Mirror_NOJ(): plt.legend() plt.show() - plt.close() + plt.close('all') npt.assert_array_equal(res, ref) @@ -66,7 +66,7 @@ def test_Mirror(wfm_cls): plt.legend() plt.show() - plt.close() + plt.close('all') npt.assert_array_equal(res, ref) @@ -91,5 +91,5 @@ def test_Mirror_flow_map(wfm_cls, groundModel, superpositionModel): if 0: plt.show() - plt.close() + plt.close('all') npt.assert_array_equal(fm_ref.WS_eff, fm_res.WS_eff) diff --git a/py_wake/tests/test_main.py b/py_wake/tests/test_main.py index 3d7901fefa7ba7a9943abfd9356256dd3dee0315..47fe5b44d2192be67f8fa32570c7c97e46a537af 100644 --- a/py_wake/tests/test_main.py +++ b/py_wake/tests/test_main.py @@ -59,7 +59,7 @@ def test_main(module): ' in %s.main' % module.__name__).with_traceback(sys.exc_info()[2]) finally: Grid.default_resolution = default_resolution - plt.close() + plt.close('all') if __name__ == '__main__': diff --git a/py_wake/tests/test_notebooks.py b/py_wake/tests/test_notebooks.py index 9c8463f276fd71b52f136457c1b23ac444026f83..054ccbbdbb7f7f4839b6a5b9391011b2c9022d7d 100644 --- a/py_wake/tests/test_notebooks.py +++ b/py_wake/tests/test_notebooks.py @@ -38,7 +38,7 @@ def test_notebooks(notebook): raise Exception(notebook.filename + " failed") from e finally: Grid.default_resolution = default_resolution - plt.close() + plt.close('all') plt.rcParams.update({'figure.max_open_warning': 20}) diff --git a/py_wake/tests/test_rotor_avg_models.py b/py_wake/tests/test_rotor_avg_models.py index c58ac2a558c251732bd6bec195d411a9f483a247..1977bd2b0186ab9b836661e5b2fe1a61c52bd175 100644 --- a/py_wake/tests/test_rotor_avg_models.py +++ b/py_wake/tests/test_rotor_avg_models.py @@ -58,7 +58,7 @@ def test_RotorGridAvg_deficit(): if 0: plt.legend() plt.show() - plt.close() + plt.close('all') def test_RotorGridAvg_ti(): @@ -101,7 +101,7 @@ def test_RotorGridAvg_ti(): if 0: plt.legend() plt.show() - plt.close() + plt.close('all') def test_gauss_quadrature(): diff --git a/py_wake/tests/test_sites/test_site.py b/py_wake/tests/test_sites/test_site.py index 2e72c21dc3dff1e768657aebbde640ab2e79595f..7c41ffd0c2ca1d64ee0cbe08be7156b2348ba57a 100644 --- a/py_wake/tests/test_sites/test_site.py +++ b/py_wake/tests/test_sites/test_site.py @@ -20,7 +20,7 @@ ti = .1 def close_plots(): yield try: - plt.close() + plt.close('all') except Exception: pass @@ -99,7 +99,7 @@ def test_plot_ws_distribution(site): if 0: plt.show() - plt.close() + plt.close('all') def test_plot_wd_distribution(site): @@ -115,7 +115,7 @@ def test_plot_wd_distribution(site): if 0: plt.show() - plt.close() + plt.close('all') def test_plot_wd_distribution_uniformSite(): @@ -124,7 +124,7 @@ def test_plot_wd_distribution_uniformSite(): p1 = site.plot_wd_distribution(n_wd=12, ax=plt) if 0: plt.show() - plt.close() + plt.close('all') def test_plot_wd_distribution_with_ws_levels(site): @@ -145,7 +145,7 @@ def test_plot_wd_distribution_with_ws_levels(site): if 0: plt.show() - plt.close() + plt.close('all') def test_plot_wd_distribution_with_ws_levels_xr(site): @@ -172,7 +172,7 @@ def test_plot_wd_distribution_with_ws_levels_xr(site): [0.0103, 0.0386, 0.0369, 0.0127, 0.0015], [0.0092, 0.0231, 0.0152, 0.0038, 0.0004]], 4) - plt.close() + plt.close('all') def test_plot_wd_distribution_with_ws_levels2(site): @@ -192,7 +192,7 @@ def test_plot_wd_distribution_with_ws_levels2(site): [0.013, 0.028, 0.011, 0.001, 0.0]], 3) if 0: plt.show() - plt.close() + plt.close('all') def test_plot_ws_distribution_iea37(): diff --git a/py_wake/tests/test_sites/test_wasp_grid_site.py b/py_wake/tests/test_sites/test_wasp_grid_site.py index bff3ff388d7f4c17ec26a684b21b88c63f1ed413..5c1b4554c7caef847abf83841799939a24e4e4ef 100644 --- a/py_wake/tests/test_sites/test_wasp_grid_site.py +++ b/py_wake/tests/test_sites/test_wasp_grid_site.py @@ -22,7 +22,7 @@ def close_plots(): yield finally: try: - plt.close() + plt.close('all') except Exception: pass @@ -73,7 +73,7 @@ def test_shear(site): if 0: plt.plot(ws, z, '.-') plt.show() - plt.close() + plt.close('all') # linear interpolation npt.assert_array_almost_equal(ws, [6.240589, np.mean([6.240589, 8.932919]), 8.932919]) @@ -273,7 +273,7 @@ def test_plot_map(site): site.ds.ws_mean.sel(h=200, wd=0).plot() if 0: plt.show() - plt.close() + plt.close('all') def test_elevation_outside_map(site): @@ -288,7 +288,7 @@ def test_elevation_outside_map(site): if 0: plt.legend() plt.show() - plt.close() + plt.close('all') def test_plot_ws_distribution(site): @@ -304,7 +304,7 @@ def test_plot_ws_distribution(site): 0.0013, 0.0003, 0.0, 0.0, 0.0], 4) npt.assert_array_almost_equal(p2[-1, ::30], [0.0001, 0.0036, 0.0047, 0.0033, 0.0014, 0.0004, 0.0001, 0.0, 0.0, 0.0], 4) - plt.close() + plt.close('all') def test_plot_wd_distribution(site): @@ -314,7 +314,7 @@ def test_plot_wd_distribution(site): if 0: plt.show() - plt.close() + plt.close('all') npt.assert_array_almost_equal(p, [0.052, 0.043, 0.058, 0.085, 0.089, 0.061, 0.047, 0.083, 0.153, 0.152, 0.108, 0.068], 3) @@ -337,7 +337,7 @@ def test_plot_wd_distribution_with_ws_levels(site): [0.048, 0.074, 0.026, 0.003, 0.0], [0.044, 0.046, 0.015, 0.002, 0.0], [0.041, 0.023, 0.003, 0.0, 0.0]], 3) - plt.close() + plt.close('all') def test_additional_input(): diff --git a/py_wake/tests/test_sites/test_xrsite.py b/py_wake/tests/test_sites/test_xrsite.py index 50cc05c2722919ee51884ebb4837102cd6041c31..f095949b7698812b8131ec2fbf55bb222efdd5ad 100644 --- a/py_wake/tests/test_sites/test_xrsite.py +++ b/py_wake/tests/test_sites/test_xrsite.py @@ -31,7 +31,7 @@ ti = .1 def close_plots(): yield try: - plt.close() + plt.close('all') except Exception: pass @@ -241,7 +241,7 @@ def test_plot_wd_distribution(complex_ws_site): if 0: print(np.round(res.squeeze().values, 4).tolist()) plt.show() - plt.close() + plt.close('all') npt.assert_array_almost_equal(res.squeeze(), ref, 4) diff --git a/py_wake/tests/test_turbulence_models/test_turbulence_models.py b/py_wake/tests/test_turbulence_models/test_turbulence_models.py index 5b576ec610dd5e99e2f8c3cafa3138fcc9788fe1..0884a248019c6d40c8fa2bb7dd0f9a9613111d64 100644 --- a/py_wake/tests/test_turbulence_models/test_turbulence_models.py +++ b/py_wake/tests/test_turbulence_models/test_turbulence_models.py @@ -194,7 +194,7 @@ def test_RotorAvg_deficit(): if 0: plt.legend() plt.show() - plt.close() + plt.close('all') @pytest.mark.parametrize('WFM', [All2AllIterative, PropagateDownwind]) diff --git a/py_wake/tests/test_utils/test_gradients.py b/py_wake/tests/test_utils/test_gradients.py index 8ea9bc9ee4a50a104e0c26282a29a1f9d4f8634e..26a804539c58e9b317d0b698e13d01f53b2e10b8 100644 --- a/py_wake/tests/test_utils/test_gradients.py +++ b/py_wake/tests/test_utils/test_gradients.py @@ -217,4 +217,4 @@ def test_plot_gradients(): plot_gradients(1.5**2, 3, 1.5, "test", 1) if 0: plt.show() - plt.close() + plt.close('all') diff --git a/py_wake/tests/test_utils/test_grid_interpolator.py b/py_wake/tests/test_utils/test_grid_interpolator.py index 4c71b85dcc193b9636b788dbbc709472b39670d2..dc0e13dcd7e449a3b846fe4f8d3899d2fca74b41 100644 --- a/py_wake/tests/test_utils/test_grid_interpolator.py +++ b/py_wake/tests/test_utils/test_grid_interpolator.py @@ -69,7 +69,7 @@ def test_grid_interpolator_2d(): plt.colorbar(c) if 0: plt.show() - plt.close() + plt.close('all') def test_grid_interpolator_2d_plus_1d(): diff --git a/py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py b/py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py index f0fda5b0576b51ab61941a9a035af034950bdd41..08f0ade0ceadfa7ddd60d802674fb07e91cab397 100644 --- a/py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py +++ b/py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py @@ -246,7 +246,7 @@ def test_dAEP_2wt(): if 0: plt.legend() plt.show() - plt.close() + plt.close('all') def test_dAEPdx(): diff --git a/py_wake/tests/test_windturbines/test_windturbines.py b/py_wake/tests/test_windturbines/test_windturbines.py index e95e2f58ee4605e7ef72f3115328185277b9dd98..2a3ff9ee9c64be09f6e101cc77223f404cdb4bf8 100644 --- a/py_wake/tests/test_windturbines/test_windturbines.py +++ b/py_wake/tests/test_windturbines/test_windturbines.py @@ -218,7 +218,7 @@ def test_plot_yz(): plt.title("WD: %s" % wd) if 0: plt.show() - plt.close() + plt.close('all') def test_plot_yz2_types(): @@ -233,7 +233,7 @@ def test_plot_yz2_types(): plt.title("WD: %s" % wd) if 0: plt.show() - plt.close() + plt.close('all') def test_set_gradients():