From c550f838463707391d313ae45b5bcc85dbb6f4e0 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 27 Dec 2023 15:59:00 +1300 Subject: [PATCH] Mark unit tests with @pytest.mark.benchmark part 1 (#2911) * Benchmark test_geopandas_info_geodataframe * Benchmark test_select_input_dataframe * Benchmark test_grdfill_dataarray * Benchmark test_grdimage_image_dataarray * Benchmark test_meca_spec_multiple_focalmecha * Benchmark test_grdimage_grid_and_shading_with_xarray * Benchmark test_grdinfo * Benchmark test_x2sys_cross_input_dataframe_output_dataframe * Benchmark test_grdview_drapegrid_dataarray * Benchmark test_solar_set_terminator_datetime * Benchmark test_tilemap_ogc_wgs84 * Benchmark test_grd2cpt * Benchmark test_grd2xyz * Benchmark test_grdclip_no_outgrid * Benchmark test_grdcontour_labels * Benchmark test_grdcut_dataarray_in_dataarray_out * Benchmark test_grdfilter_dataarray_in_dataarray_out * Benchmark test_grdgradient_no_outgrid * Benchmark test_equalize_grid_no_outgrid and test_compute_bins_no_outfile * Benchmark test_grdlandmask_no_outgrid * Benchmark test_grdproject_no_outgrid * Benchmark test_grdsample_dataarray_out * Benchmark test_grdtrack_input_dataframe_and_dataarray * Benchmark test_grdvolume_no_outgrid * Benchmark test_histogram * Benchmark test_info_pandas_dataframe_date_column and test_info_xarray_dataset_time_column * Benchmark test_inset_aliases * Benchmark test_io_load_dataarray * Benchmark test_legend_entries * Benchmark test_logo * Benchmark test_makecpt_output_cpt_file * Benchmark test_nearneighbor_input_xyz * Benchmark test_plot_vectors * Benchmark test_plot3d_vectors * Benchmark test_project_input_matrix * Benchmark test_psconvert * Benchmark test_rose_plot_data_using_cpt * Benchmark test_begin_end * Benchmark test_sph2grd_no_outgrid * Benchmark test_sphdistance_no_outgrid * Benchmark test_sphinterpolate_no_outgrid * Benchmark test_subplot_basic_frame * Benchmark test_surface_input_xyz * Benchmark test_ternary_3_labels * Benchmark test_text_multiple_lines_of_text * Benchmark test_timestamp_font * Benchmark test_delaunay_triples_input_xyz and test_regular_grid_no_outgrid * Benchmark test_velo_pandas_dataframe * Benchmark test_which_multiple * Benchmark test_wiggle_data_incols * Benchmark test_x2sys_init_units_gap * Benchmark test_xyz2grd_input_array --- .github/workflows/benchmarks.yml | 2 +- pygmt/tests/test_geopandas.py | 1 + pygmt/tests/test_grd2cpt.py | 1 + pygmt/tests/test_grd2xyz.py | 1 + pygmt/tests/test_grdclip.py | 1 + pygmt/tests/test_grdcontour.py | 1 + pygmt/tests/test_grdcut.py | 1 + pygmt/tests/test_grdfill.py | 1 + pygmt/tests/test_grdfilter.py | 1 + pygmt/tests/test_grdgradient.py | 1 + pygmt/tests/test_grdhisteq.py | 4 +++- pygmt/tests/test_grdimage.py | 1 + pygmt/tests/test_grdimage_image.py | 1 + pygmt/tests/test_grdinfo.py | 1 + pygmt/tests/test_grdlandmask.py | 1 + pygmt/tests/test_grdproject.py | 1 + pygmt/tests/test_grdsample.py | 1 + pygmt/tests/test_grdtrack.py | 1 + pygmt/tests/test_grdview.py | 1 + pygmt/tests/test_grdvolume.py | 1 + pygmt/tests/test_histogram.py | 1 + pygmt/tests/test_info.py | 2 ++ pygmt/tests/test_inset.py | 1 + pygmt/tests/test_io.py | 1 + pygmt/tests/test_legend.py | 1 + pygmt/tests/test_logo.py | 1 + pygmt/tests/test_makecpt.py | 1 + pygmt/tests/test_meca.py | 1 + pygmt/tests/test_nearneighbor.py | 1 + pygmt/tests/test_plot.py | 1 + pygmt/tests/test_plot3d.py | 1 + pygmt/tests/test_project.py | 1 + pygmt/tests/test_psconvert.py | 1 + pygmt/tests/test_rose.py | 1 + pygmt/tests/test_select.py | 1 + pygmt/tests/test_session_management.py | 2 ++ pygmt/tests/test_solar.py | 1 + pygmt/tests/test_sph2grd.py | 2 ++ pygmt/tests/test_sphdistance.py | 1 + pygmt/tests/test_sphinterpolate.py | 1 + pygmt/tests/test_subplot.py | 1 + pygmt/tests/test_surface.py | 1 + pygmt/tests/test_ternary.py | 1 + pygmt/tests/test_text.py | 1 + pygmt/tests/test_tilemap.py | 1 + pygmt/tests/test_timestamp.py | 1 + pygmt/tests/test_triangulate.py | 2 ++ pygmt/tests/test_velo.py | 1 + pygmt/tests/test_which.py | 1 + pygmt/tests/test_wiggle.py | 1 + pygmt/tests/test_x2sys_cross.py | 1 + pygmt/tests/test_x2sys_init.py | 1 + pygmt/tests/test_xyz2grd.py | 1 + 53 files changed, 59 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 2b562e9aa46..701f6fffacc 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -61,7 +61,7 @@ jobs: echo $CONDA/bin >> $GITHUB_PATH conda install --solver=libmamba gmt=6.4.0 python=3.12 \ numpy pandas xarray netCDF4 packaging \ - pytest pytest-benchmark pytest-mpl + geopandas pytest pytest-benchmark pytest-mpl python -m pip install -U pytest-codspeed setuptools # Install the package that we want to test diff --git a/pygmt/tests/test_geopandas.py b/pygmt/tests/test_geopandas.py index 14731e4e756..14e2a996a7c 100644 --- a/pygmt/tests/test_geopandas.py +++ b/pygmt/tests/test_geopandas.py @@ -61,6 +61,7 @@ def fixture_gdf_ridge(): return gdf +@pytest.mark.benchmark def test_geopandas_info_geodataframe(gdf): """ Check that info can return the bounding box region from a diff --git a/pygmt/tests/test_grd2cpt.py b/pygmt/tests/test_grd2cpt.py index b66c11eb81c..2357b2e7d2e 100644 --- a/pygmt/tests/test_grd2cpt.py +++ b/pygmt/tests/test_grd2cpt.py @@ -18,6 +18,7 @@ def fixture_grid(): return load_static_earth_relief() +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_grd2cpt(grid): """ diff --git a/pygmt/tests/test_grd2xyz.py b/pygmt/tests/test_grd2xyz.py index d53993388c2..2cd555d6d5f 100644 --- a/pygmt/tests/test_grd2xyz.py +++ b/pygmt/tests/test_grd2xyz.py @@ -20,6 +20,7 @@ def fixture_grid(): return load_static_earth_relief() +@pytest.mark.benchmark def test_grd2xyz(grid): """ Make sure grd2xyz works as expected. diff --git a/pygmt/tests/test_grdclip.py b/pygmt/tests/test_grdclip.py index c08f1e69744..997a789ee8b 100644 --- a/pygmt/tests/test_grdclip.py +++ b/pygmt/tests/test_grdclip.py @@ -55,6 +55,7 @@ def test_grdclip_outgrid(grid, expected_grid): xr.testing.assert_allclose(a=temp_grid, b=expected_grid) +@pytest.mark.benchmark def test_grdclip_no_outgrid(grid, expected_grid): """ Test the below and above parameters for grdclip with no set outgrid. diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index 9163dd96f31..fbdbcf8c45c 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -33,6 +33,7 @@ def test_grdcontour(grid): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_grdcontour_labels(grid): """ diff --git a/pygmt/tests/test_grdcut.py b/pygmt/tests/test_grdcut.py index b24403321fa..c71ef7c4d1e 100644 --- a/pygmt/tests/test_grdcut.py +++ b/pygmt/tests/test_grdcut.py @@ -53,6 +53,7 @@ def test_grdcut_dataarray_in_file_out(grid, expected_grid, region): xr.testing.assert_allclose(a=temp_grid, b=expected_grid) +@pytest.mark.benchmark def test_grdcut_dataarray_in_dataarray_out(grid, expected_grid, region): """ Test grdcut on an input DataArray, and output as DataArray. diff --git a/pygmt/tests/test_grdfill.py b/pygmt/tests/test_grdfill.py index f0ba5fe9563..6333d63471c 100644 --- a/pygmt/tests/test_grdfill.py +++ b/pygmt/tests/test_grdfill.py @@ -71,6 +71,7 @@ def fixture_expected_grid(): ) +@pytest.mark.benchmark def test_grdfill_dataarray_out(grid, expected_grid): """ Test grdfill with a DataArray output. diff --git a/pygmt/tests/test_grdfilter.py b/pygmt/tests/test_grdfilter.py index e21aa214100..7d87dc6fe51 100644 --- a/pygmt/tests/test_grdfilter.py +++ b/pygmt/tests/test_grdfilter.py @@ -39,6 +39,7 @@ def fixture_expected_grid(): ) +@pytest.mark.benchmark def test_grdfilter_dataarray_in_dataarray_out(grid, expected_grid): """ Test grdfilter with an input DataArray, and output as DataArray. diff --git a/pygmt/tests/test_grdgradient.py b/pygmt/tests/test_grdgradient.py index e419fdc7516..4e0506a2b9f 100644 --- a/pygmt/tests/test_grdgradient.py +++ b/pygmt/tests/test_grdgradient.py @@ -53,6 +53,7 @@ def test_grdgradient_outgrid(grid, expected_grid): xr.testing.assert_allclose(a=temp_grid, b=expected_grid) +@pytest.mark.benchmark def test_grdgradient_no_outgrid(grid, expected_grid): """ Test the azimuth and direction parameters for grdgradient with no set diff --git a/pygmt/tests/test_grdhisteq.py b/pygmt/tests/test_grdhisteq.py index 9ce6941f9e6..e2fb5b41d18 100644 --- a/pygmt/tests/test_grdhisteq.py +++ b/pygmt/tests/test_grdhisteq.py @@ -69,7 +69,8 @@ def test_equalize_grid_outgrid_file(grid, expected_grid, region): xr.testing.assert_allclose(a=temp_grid, b=expected_grid) -def test_equalize_grid_outgrid(grid, expected_grid, region): +@pytest.mark.benchmark +def test_equalize_grid_no_outgrid(grid, expected_grid, region): """ Test grdhisteq.equalize_grid with ``outgrid=None``. """ @@ -81,6 +82,7 @@ def test_equalize_grid_outgrid(grid, expected_grid, region): xr.testing.assert_allclose(a=temp_grid, b=expected_grid) +@pytest.mark.benchmark def test_compute_bins_no_outfile(grid, expected_df, region): """ Test grdhisteq.compute_bins with no ``outfile``. diff --git a/pygmt/tests/test_grdimage.py b/pygmt/tests/test_grdimage.py index 68924c0a5ae..2dbe3508457 100644 --- a/pygmt/tests/test_grdimage.py +++ b/pygmt/tests/test_grdimage.py @@ -131,6 +131,7 @@ def test_grdimage_shading_xarray(grid, shading): return fig_ref, fig_test +@pytest.mark.benchmark @check_figures_equal() def test_grdimage_grid_and_shading_with_xarray(grid, xrgrid): """ diff --git a/pygmt/tests/test_grdimage_image.py b/pygmt/tests/test_grdimage_image.py index ade642605df..157bfd991df 100644 --- a/pygmt/tests/test_grdimage_image.py +++ b/pygmt/tests/test_grdimage_image.py @@ -53,6 +53,7 @@ def test_grdimage_image(): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare(filename="test_grdimage_image.png") def test_grdimage_image_dataarray(xr_image): """ diff --git a/pygmt/tests/test_grdinfo.py b/pygmt/tests/test_grdinfo.py index ebecbf54eb8..2825b96d4be 100644 --- a/pygmt/tests/test_grdinfo.py +++ b/pygmt/tests/test_grdinfo.py @@ -16,6 +16,7 @@ def fixture_grid(): return load_static_earth_relief() +@pytest.mark.benchmark def test_grdinfo(grid): """ Make sure grdinfo works as expected. diff --git a/pygmt/tests/test_grdlandmask.py b/pygmt/tests/test_grdlandmask.py index b37d9851346..8e8243c8544 100644 --- a/pygmt/tests/test_grdlandmask.py +++ b/pygmt/tests/test_grdlandmask.py @@ -44,6 +44,7 @@ def test_grdlandmask_outgrid(expected_grid): xr.testing.assert_allclose(a=temp_grid, b=expected_grid) +@pytest.mark.benchmark def test_grdlandmask_no_outgrid(expected_grid): """ Test grdlandmask with no set outgrid. diff --git a/pygmt/tests/test_grdproject.py b/pygmt/tests/test_grdproject.py index 2d734aadca5..4eb073c88d8 100644 --- a/pygmt/tests/test_grdproject.py +++ b/pygmt/tests/test_grdproject.py @@ -58,6 +58,7 @@ def test_grdproject_file_out(grid, expected_grid): xr.testing.assert_allclose(a=temp_grid, b=expected_grid) +@pytest.mark.benchmark @pytest.mark.parametrize( "projection", ["M10c", "EPSG:3395 +width=10", "+proj=merc +ellps=WGS84 +units=m +width=10"], diff --git a/pygmt/tests/test_grdsample.py b/pygmt/tests/test_grdsample.py index e23cd269921..06897d1ab28 100644 --- a/pygmt/tests/test_grdsample.py +++ b/pygmt/tests/test_grdsample.py @@ -69,6 +69,7 @@ def test_grdsample_file_out(grid, expected_grid, region, spacing): xr.testing.assert_allclose(a=temp_grid, b=expected_grid) +@pytest.mark.benchmark def test_grdsample_dataarray_out(grid, expected_grid, region, spacing): """ Test grdsample with no outgrid set and the spacing is changed. diff --git a/pygmt/tests/test_grdtrack.py b/pygmt/tests/test_grdtrack.py index 2447c37c849..f51c2023bb2 100644 --- a/pygmt/tests/test_grdtrack.py +++ b/pygmt/tests/test_grdtrack.py @@ -55,6 +55,7 @@ def fixture_dataframe(): ) +@pytest.mark.benchmark def test_grdtrack_input_dataframe_and_dataarray(dataarray, dataframe, expected_array): """ Run grdtrack by passing in a pandas.DataFrame and xarray.DataArray as diff --git a/pygmt/tests/test_grdview.py b/pygmt/tests/test_grdview.py index 5ddd395e8fe..c0c22b8f88b 100644 --- a/pygmt/tests/test_grdview.py +++ b/pygmt/tests/test_grdview.py @@ -214,6 +214,7 @@ def test_grdview_on_a_plane_styled_with_facadepen(xrgrid): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_grdview_drapegrid_dataarray(xrgrid): """ diff --git a/pygmt/tests/test_grdvolume.py b/pygmt/tests/test_grdvolume.py index 1facffd4639..6860ff0fe3a 100644 --- a/pygmt/tests/test_grdvolume.py +++ b/pygmt/tests/test_grdvolume.py @@ -75,6 +75,7 @@ def test_grdvolume_no_outfile(grid): grdvolume(grid=grid, output_type="file") +@pytest.mark.benchmark def test_grdvolume_no_outgrid(grid, data, region): """ Test the expected output of grdvolume with no output file set. diff --git a/pygmt/tests/test_histogram.py b/pygmt/tests/test_histogram.py index 251cd3047ca..1c5f56a329f 100644 --- a/pygmt/tests/test_histogram.py +++ b/pygmt/tests/test_histogram.py @@ -15,6 +15,7 @@ def fixture_data(request): return request.param(data) +@pytest.mark.benchmark @pytest.mark.mpl_image_compare(filename="test_histogram.png") def test_histogram(data): """ diff --git a/pygmt/tests/test_info.py b/pygmt/tests/test_info.py index b853789ad85..ddd5b805def 100644 --- a/pygmt/tests/test_info.py +++ b/pygmt/tests/test_info.py @@ -119,6 +119,7 @@ def test_info_numpy_array_time_column(): assert output == expected_output +@pytest.mark.benchmark @pytest.mark.parametrize( "dtype", [ @@ -144,6 +145,7 @@ def test_info_pandas_dataframe_date_column(dtype): assert output == expected_output +@pytest.mark.benchmark def test_info_xarray_dataset_time_column(): """ Make sure info works on xarray.Dataset 1-D inputs with a time column. diff --git a/pygmt/tests/test_inset.py b/pygmt/tests/test_inset.py index e7a367b6993..a5ce7e89c13 100644 --- a/pygmt/tests/test_inset.py +++ b/pygmt/tests/test_inset.py @@ -5,6 +5,7 @@ from pygmt import Figure +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_inset_aliases(): """ diff --git a/pygmt/tests/test_io.py b/pygmt/tests/test_io.py index 333fbda0f3d..ee7fdc50792 100644 --- a/pygmt/tests/test_io.py +++ b/pygmt/tests/test_io.py @@ -8,6 +8,7 @@ from pygmt.io import load_dataarray +@pytest.mark.benchmark def test_io_load_dataarray(): """ Check that load_dataarray works to read a netCDF grid with diff --git a/pygmt/tests/test_legend.py b/pygmt/tests/test_legend.py index b7cf01ad048..290b6bf1a6e 100644 --- a/pygmt/tests/test_legend.py +++ b/pygmt/tests/test_legend.py @@ -38,6 +38,7 @@ def test_legend_default_position(): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_legend_entries(): """ diff --git a/pygmt/tests/test_logo.py b/pygmt/tests/test_logo.py index 69d54b54df8..7a405289202 100644 --- a/pygmt/tests/test_logo.py +++ b/pygmt/tests/test_logo.py @@ -5,6 +5,7 @@ from pygmt import Figure +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_logo(): """ diff --git a/pygmt/tests/test_makecpt.py b/pygmt/tests/test_makecpt.py index 56c016b7879..781c578ef0e 100644 --- a/pygmt/tests/test_makecpt.py +++ b/pygmt/tests/test_makecpt.py @@ -71,6 +71,7 @@ def test_makecpt_plot_colorbar_scaled_with_series(position): return fig +@pytest.mark.benchmark def test_makecpt_output_cpt_file(): """ Save the generated static color palette table to a .cpt file. diff --git a/pygmt/tests/test_meca.py b/pygmt/tests/test_meca.py index ea360d3cac1..ded2b20a418 100644 --- a/pygmt/tests/test_meca.py +++ b/pygmt/tests/test_meca.py @@ -81,6 +81,7 @@ def test_meca_spec_single_focalmecha_file(): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare(filename="test_meca_spec_multiple_focalmecha.png") @pytest.mark.parametrize( "inputtype", ["dict_mecha", "dict_mecha_mixed", "dataframe", "array2d"] diff --git a/pygmt/tests/test_nearneighbor.py b/pygmt/tests/test_nearneighbor.py index 6ea7034d84e..3dad7a7c471 100644 --- a/pygmt/tests/test_nearneighbor.py +++ b/pygmt/tests/test_nearneighbor.py @@ -37,6 +37,7 @@ def test_nearneighbor_input_data(array_func, ship_data): npt.assert_allclose(output.mean(), -2378.2385) +@pytest.mark.benchmark def test_nearneighbor_input_xyz(ship_data): """ Run nearneighbor by passing in x, y, z numpy.ndarrays individually. diff --git a/pygmt/tests/test_plot.py b/pygmt/tests/test_plot.py index 31d2c51326e..83228c1cc3f 100644 --- a/pygmt/tests/test_plot.py +++ b/pygmt/tests/test_plot.py @@ -352,6 +352,7 @@ def test_plot_from_file(region): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_plot_vectors(): """ diff --git a/pygmt/tests/test_plot3d.py b/pygmt/tests/test_plot3d.py index 1a99198a55c..1e5ac60d3ab 100644 --- a/pygmt/tests/test_plot3d.py +++ b/pygmt/tests/test_plot3d.py @@ -378,6 +378,7 @@ def test_plot3d_from_file(region): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_plot3d_vectors(): """ diff --git a/pygmt/tests/test_project.py b/pygmt/tests/test_project.py index c7185a0be44..6cd818948db 100644 --- a/pygmt/tests/test_project.py +++ b/pygmt/tests/test_project.py @@ -34,6 +34,7 @@ def test_project_generate(): ) +@pytest.mark.benchmark @pytest.mark.parametrize("array_func", [np.array, pd.DataFrame, xr.Dataset]) def test_project_input_matrix(array_func, dataframe): """ diff --git a/pygmt/tests/test_psconvert.py b/pygmt/tests/test_psconvert.py index 73fae958de4..025a5d46f75 100644 --- a/pygmt/tests/test_psconvert.py +++ b/pygmt/tests/test_psconvert.py @@ -8,6 +8,7 @@ from pygmt.exceptions import GMTInvalidInput +@pytest.mark.benchmark def test_psconvert(): """ Check that psconvert creates a figure in the current directory. diff --git a/pygmt/tests/test_rose.py b/pygmt/tests/test_rose.py index f6a86010f44..e6de1077c55 100644 --- a/pygmt/tests/test_rose.py +++ b/pygmt/tests/test_rose.py @@ -91,6 +91,7 @@ def test_rose_2d_array_multiple(data): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_rose_plot_data_using_cpt(data): """ diff --git a/pygmt/tests/test_select.py b/pygmt/tests/test_select.py index 849cfcd743c..48cb136b0dd 100644 --- a/pygmt/tests/test_select.py +++ b/pygmt/tests/test_select.py @@ -19,6 +19,7 @@ def fixture_dataframe(): return load_sample_data(name="bathymetry") +@pytest.mark.benchmark def test_select_input_dataframe(dataframe): """ Run select by passing in a pandas.DataFrame as input. diff --git a/pygmt/tests/test_session_management.py b/pygmt/tests/test_session_management.py index 4db93dc968b..079c2c4e02c 100644 --- a/pygmt/tests/test_session_management.py +++ b/pygmt/tests/test_session_management.py @@ -3,10 +3,12 @@ """ import os +import pytest from pygmt.clib import Session from pygmt.session_management import begin, end +@pytest.mark.benchmark def test_begin_end(): """ Run a command inside a begin-end modern mode block. diff --git a/pygmt/tests/test_solar.py b/pygmt/tests/test_solar.py index 56f3101f430..6b22375246b 100644 --- a/pygmt/tests/test_solar.py +++ b/pygmt/tests/test_solar.py @@ -39,6 +39,7 @@ def test_solar_terminators(): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare(filename="test_solar_set_terminator_datetime.png") @pytest.mark.parametrize( "terminator_datetime", diff --git a/pygmt/tests/test_sph2grd.py b/pygmt/tests/test_sph2grd.py index 7839978cd14..1876be96454 100644 --- a/pygmt/tests/test_sph2grd.py +++ b/pygmt/tests/test_sph2grd.py @@ -4,6 +4,7 @@ from pathlib import Path import numpy.testing as npt +import pytest from pygmt import sph2grd from pygmt.helpers import GMTTempFile @@ -20,6 +21,7 @@ def test_sph2grd_outgrid(): assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists +@pytest.mark.benchmark def test_sph2grd_no_outgrid(): """ Test sph2grd with no set outgrid. diff --git a/pygmt/tests/test_sphdistance.py b/pygmt/tests/test_sphdistance.py index 7a48cb19cd7..4964db77e3d 100644 --- a/pygmt/tests/test_sphdistance.py +++ b/pygmt/tests/test_sphdistance.py @@ -48,6 +48,7 @@ def test_sphdistance_outgrid(array): assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists +@pytest.mark.benchmark def test_sphdistance_no_outgrid(array): """ Test sphdistance with no set outgrid. diff --git a/pygmt/tests/test_sphinterpolate.py b/pygmt/tests/test_sphinterpolate.py index 069c6e19454..9de868968a8 100644 --- a/pygmt/tests/test_sphinterpolate.py +++ b/pygmt/tests/test_sphinterpolate.py @@ -28,6 +28,7 @@ def test_sphinterpolate_outgrid(mars): assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists +@pytest.mark.benchmark def test_sphinterpolate_no_outgrid(mars): """ Test sphinterpolate with no set outgrid. diff --git a/pygmt/tests/test_subplot.py b/pygmt/tests/test_subplot.py index 4aad9e6375c..5d4654064ce 100644 --- a/pygmt/tests/test_subplot.py +++ b/pygmt/tests/test_subplot.py @@ -6,6 +6,7 @@ from pygmt.exceptions import GMTInvalidInput +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_subplot_basic_frame(): """ diff --git a/pygmt/tests/test_surface.py b/pygmt/tests/test_surface.py index 040da015faf..3a92a8adbaf 100644 --- a/pygmt/tests/test_surface.py +++ b/pygmt/tests/test_surface.py @@ -103,6 +103,7 @@ def test_surface_input_data_array(data, region, spacing, expected_grid): check_values(output, expected_grid) +@pytest.mark.benchmark def test_surface_input_xyz(data, region, spacing, expected_grid): """ Run surface by passing in x, y, z numpy.ndarrays individually. diff --git a/pygmt/tests/test_ternary.py b/pygmt/tests/test_ternary.py index 713ed4396d4..7f6116e6092 100644 --- a/pygmt/tests/test_ternary.py +++ b/pygmt/tests/test_ternary.py @@ -64,6 +64,7 @@ def test_ternary(array): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_ternary_3_labels(array): """ diff --git a/pygmt/tests/test_text.py b/pygmt/tests/test_text.py index ac99f73083a..509dcd75cb1 100644 --- a/pygmt/tests/test_text.py +++ b/pygmt/tests/test_text.py @@ -46,6 +46,7 @@ def test_text_single_line_of_text(region, projection): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_text_multiple_lines_of_text(region, projection): """ diff --git a/pygmt/tests/test_tilemap.py b/pygmt/tests/test_tilemap.py index 31b7314fab2..891a76021ee 100644 --- a/pygmt/tests/test_tilemap.py +++ b/pygmt/tests/test_tilemap.py @@ -24,6 +24,7 @@ def test_tilemap_web_mercator(): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_tilemap_ogc_wgs84(): """ diff --git a/pygmt/tests/test_timestamp.py b/pygmt/tests/test_timestamp.py index e748317857d..3dc848d8608 100644 --- a/pygmt/tests/test_timestamp.py +++ b/pygmt/tests/test_timestamp.py @@ -61,6 +61,7 @@ def test_timestamp_offset(): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_timestamp_font(faketime): """ diff --git a/pygmt/tests/test_triangulate.py b/pygmt/tests/test_triangulate.py index 5ba5de998c9..f475e39a9fa 100644 --- a/pygmt/tests/test_triangulate.py +++ b/pygmt/tests/test_triangulate.py @@ -70,6 +70,7 @@ def test_delaunay_triples_input_table_matrix(array_func, dataframe, expected_dat pd.testing.assert_frame_equal(left=output, right=expected_dataframe) +@pytest.mark.benchmark def test_delaunay_triples_input_xyz(dataframe, expected_dataframe): """ Run triangulate.delaunay_triples by passing in x, y, z numpy.ndarrays @@ -129,6 +130,7 @@ def test_delaunay_triples_invalid_format(dataframe): triangulate.delaunay_triples(data=dataframe, output_type=1) +@pytest.mark.benchmark def test_regular_grid_no_outgrid(dataframe, expected_grid): """ Run triangulate.regular_grid with no set outgrid and see it load into an diff --git a/pygmt/tests/test_velo.py b/pygmt/tests/test_velo.py index f5a879c37a7..4c88f2b481d 100644 --- a/pygmt/tests/test_velo.py +++ b/pygmt/tests/test_velo.py @@ -63,6 +63,7 @@ def test_velo_without_spec(dataframe): fig.velo(data=dataframe) +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_velo_pandas_dataframe(dataframe): """ diff --git a/pygmt/tests/test_which.py b/pygmt/tests/test_which.py index b482b247b4d..c9b835a207a 100644 --- a/pygmt/tests/test_which.py +++ b/pygmt/tests/test_which.py @@ -18,6 +18,7 @@ def test_which(): assert Path(cached_file).name == fname +@pytest.mark.benchmark def test_which_multiple(): """ Make sure `which` returns file paths for multiple @files correctly. diff --git a/pygmt/tests/test_wiggle.py b/pygmt/tests/test_wiggle.py index 89c46f8e42a..9b38911df0f 100644 --- a/pygmt/tests/test_wiggle.py +++ b/pygmt/tests/test_wiggle.py @@ -33,6 +33,7 @@ def test_wiggle(): return fig +@pytest.mark.benchmark @pytest.mark.mpl_image_compare(filename="test_wiggle.png") def test_wiggle_data_incols(): """ diff --git a/pygmt/tests/test_x2sys_cross.py b/pygmt/tests/test_x2sys_cross.py index 957066d677b..abdd91d45a1 100644 --- a/pygmt/tests/test_x2sys_cross.py +++ b/pygmt/tests/test_x2sys_cross.py @@ -71,6 +71,7 @@ def test_x2sys_cross_input_file_output_dataframe(): assert columns[6:] == ["head_1", "head_2", "vel_1", "vel_2", "z_X", "z_M"] +@pytest.mark.benchmark @pytest.mark.usefixtures("mock_x2sys_home") def test_x2sys_cross_input_dataframe_output_dataframe(tracks): """ diff --git a/pygmt/tests/test_x2sys_init.py b/pygmt/tests/test_x2sys_init.py index de0bdc41325..5197dd86cd8 100644 --- a/pygmt/tests/test_x2sys_init.py +++ b/pygmt/tests/test_x2sys_init.py @@ -35,6 +35,7 @@ def test_x2sys_init_region_spacing(): assert "-I5/5" in tail_line +@pytest.mark.benchmark @pytest.mark.usefixtures("mock_x2sys_home") def test_x2sys_init_units_gap(): """ diff --git a/pygmt/tests/test_xyz2grd.py b/pygmt/tests/test_xyz2grd.py index 5f11e2c0128..f15d2c7dc2d 100644 --- a/pygmt/tests/test_xyz2grd.py +++ b/pygmt/tests/test_xyz2grd.py @@ -39,6 +39,7 @@ def fixture_expected_grid(): ) +@pytest.mark.benchmark @pytest.mark.parametrize("array_func", [np.array, xr.Dataset]) def test_xyz2grd_input_array(array_func, ship_data, expected_grid): """