Skip to content

Commit c550f83

Browse files
authored
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
1 parent 3076ddc commit c550f83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+59
-2
lines changed

.github/workflows/benchmarks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
echo $CONDA/bin >> $GITHUB_PATH
6262
conda install --solver=libmamba gmt=6.4.0 python=3.12 \
6363
numpy pandas xarray netCDF4 packaging \
64-
pytest pytest-benchmark pytest-mpl
64+
geopandas pytest pytest-benchmark pytest-mpl
6565
python -m pip install -U pytest-codspeed setuptools
6666
6767
# Install the package that we want to test

pygmt/tests/test_geopandas.py

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def fixture_gdf_ridge():
6161
return gdf
6262

6363

64+
@pytest.mark.benchmark
6465
def test_geopandas_info_geodataframe(gdf):
6566
"""
6667
Check that info can return the bounding box region from a

pygmt/tests/test_grd2cpt.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def fixture_grid():
1818
return load_static_earth_relief()
1919

2020

21+
@pytest.mark.benchmark
2122
@pytest.mark.mpl_image_compare
2223
def test_grd2cpt(grid):
2324
"""

pygmt/tests/test_grd2xyz.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def fixture_grid():
2020
return load_static_earth_relief()
2121

2222

23+
@pytest.mark.benchmark
2324
def test_grd2xyz(grid):
2425
"""
2526
Make sure grd2xyz works as expected.

pygmt/tests/test_grdclip.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def test_grdclip_outgrid(grid, expected_grid):
5555
xr.testing.assert_allclose(a=temp_grid, b=expected_grid)
5656

5757

58+
@pytest.mark.benchmark
5859
def test_grdclip_no_outgrid(grid, expected_grid):
5960
"""
6061
Test the below and above parameters for grdclip with no set outgrid.

pygmt/tests/test_grdcontour.py

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def test_grdcontour(grid):
3333
return fig
3434

3535

36+
@pytest.mark.benchmark
3637
@pytest.mark.mpl_image_compare
3738
def test_grdcontour_labels(grid):
3839
"""

pygmt/tests/test_grdcut.py

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_grdcut_dataarray_in_file_out(grid, expected_grid, region):
5353
xr.testing.assert_allclose(a=temp_grid, b=expected_grid)
5454

5555

56+
@pytest.mark.benchmark
5657
def test_grdcut_dataarray_in_dataarray_out(grid, expected_grid, region):
5758
"""
5859
Test grdcut on an input DataArray, and output as DataArray.

pygmt/tests/test_grdfill.py

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def fixture_expected_grid():
7171
)
7272

7373

74+
@pytest.mark.benchmark
7475
def test_grdfill_dataarray_out(grid, expected_grid):
7576
"""
7677
Test grdfill with a DataArray output.

pygmt/tests/test_grdfilter.py

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def fixture_expected_grid():
3939
)
4040

4141

42+
@pytest.mark.benchmark
4243
def test_grdfilter_dataarray_in_dataarray_out(grid, expected_grid):
4344
"""
4445
Test grdfilter with an input DataArray, and output as DataArray.

pygmt/tests/test_grdgradient.py

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_grdgradient_outgrid(grid, expected_grid):
5353
xr.testing.assert_allclose(a=temp_grid, b=expected_grid)
5454

5555

56+
@pytest.mark.benchmark
5657
def test_grdgradient_no_outgrid(grid, expected_grid):
5758
"""
5859
Test the azimuth and direction parameters for grdgradient with no set

pygmt/tests/test_grdhisteq.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def test_equalize_grid_outgrid_file(grid, expected_grid, region):
6969
xr.testing.assert_allclose(a=temp_grid, b=expected_grid)
7070

7171

72-
def test_equalize_grid_outgrid(grid, expected_grid, region):
72+
@pytest.mark.benchmark
73+
def test_equalize_grid_no_outgrid(grid, expected_grid, region):
7374
"""
7475
Test grdhisteq.equalize_grid with ``outgrid=None``.
7576
"""
@@ -81,6 +82,7 @@ def test_equalize_grid_outgrid(grid, expected_grid, region):
8182
xr.testing.assert_allclose(a=temp_grid, b=expected_grid)
8283

8384

85+
@pytest.mark.benchmark
8486
def test_compute_bins_no_outfile(grid, expected_df, region):
8587
"""
8688
Test grdhisteq.compute_bins with no ``outfile``.

pygmt/tests/test_grdimage.py

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def test_grdimage_shading_xarray(grid, shading):
131131
return fig_ref, fig_test
132132

133133

134+
@pytest.mark.benchmark
134135
@check_figures_equal()
135136
def test_grdimage_grid_and_shading_with_xarray(grid, xrgrid):
136137
"""

pygmt/tests/test_grdimage_image.py

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_grdimage_image():
5353
return fig
5454

5555

56+
@pytest.mark.benchmark
5657
@pytest.mark.mpl_image_compare(filename="test_grdimage_image.png")
5758
def test_grdimage_image_dataarray(xr_image):
5859
"""

pygmt/tests/test_grdinfo.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def fixture_grid():
1616
return load_static_earth_relief()
1717

1818

19+
@pytest.mark.benchmark
1920
def test_grdinfo(grid):
2021
"""
2122
Make sure grdinfo works as expected.

pygmt/tests/test_grdlandmask.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def test_grdlandmask_outgrid(expected_grid):
4444
xr.testing.assert_allclose(a=temp_grid, b=expected_grid)
4545

4646

47+
@pytest.mark.benchmark
4748
def test_grdlandmask_no_outgrid(expected_grid):
4849
"""
4950
Test grdlandmask with no set outgrid.

pygmt/tests/test_grdproject.py

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def test_grdproject_file_out(grid, expected_grid):
5858
xr.testing.assert_allclose(a=temp_grid, b=expected_grid)
5959

6060

61+
@pytest.mark.benchmark
6162
@pytest.mark.parametrize(
6263
"projection",
6364
["M10c", "EPSG:3395 +width=10", "+proj=merc +ellps=WGS84 +units=m +width=10"],

pygmt/tests/test_grdsample.py

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_grdsample_file_out(grid, expected_grid, region, spacing):
6969
xr.testing.assert_allclose(a=temp_grid, b=expected_grid)
7070

7171

72+
@pytest.mark.benchmark
7273
def test_grdsample_dataarray_out(grid, expected_grid, region, spacing):
7374
"""
7475
Test grdsample with no outgrid set and the spacing is changed.

pygmt/tests/test_grdtrack.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def fixture_dataframe():
5555
)
5656

5757

58+
@pytest.mark.benchmark
5859
def test_grdtrack_input_dataframe_and_dataarray(dataarray, dataframe, expected_array):
5960
"""
6061
Run grdtrack by passing in a pandas.DataFrame and xarray.DataArray as

pygmt/tests/test_grdview.py

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def test_grdview_on_a_plane_styled_with_facadepen(xrgrid):
214214
return fig
215215

216216

217+
@pytest.mark.benchmark
217218
@pytest.mark.mpl_image_compare
218219
def test_grdview_drapegrid_dataarray(xrgrid):
219220
"""

pygmt/tests/test_grdvolume.py

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def test_grdvolume_no_outfile(grid):
7575
grdvolume(grid=grid, output_type="file")
7676

7777

78+
@pytest.mark.benchmark
7879
def test_grdvolume_no_outgrid(grid, data, region):
7980
"""
8081
Test the expected output of grdvolume with no output file set.

pygmt/tests/test_histogram.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def fixture_data(request):
1515
return request.param(data)
1616

1717

18+
@pytest.mark.benchmark
1819
@pytest.mark.mpl_image_compare(filename="test_histogram.png")
1920
def test_histogram(data):
2021
"""

pygmt/tests/test_info.py

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def test_info_numpy_array_time_column():
119119
assert output == expected_output
120120

121121

122+
@pytest.mark.benchmark
122123
@pytest.mark.parametrize(
123124
"dtype",
124125
[
@@ -144,6 +145,7 @@ def test_info_pandas_dataframe_date_column(dtype):
144145
assert output == expected_output
145146

146147

148+
@pytest.mark.benchmark
147149
def test_info_xarray_dataset_time_column():
148150
"""
149151
Make sure info works on xarray.Dataset 1-D inputs with a time column.

pygmt/tests/test_inset.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pygmt import Figure
66

77

8+
@pytest.mark.benchmark
89
@pytest.mark.mpl_image_compare
910
def test_inset_aliases():
1011
"""

pygmt/tests/test_io.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pygmt.io import load_dataarray
99

1010

11+
@pytest.mark.benchmark
1112
def test_io_load_dataarray():
1213
"""
1314
Check that load_dataarray works to read a netCDF grid with

pygmt/tests/test_legend.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_legend_default_position():
3838
return fig
3939

4040

41+
@pytest.mark.benchmark
4142
@pytest.mark.mpl_image_compare
4243
def test_legend_entries():
4344
"""

pygmt/tests/test_logo.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pygmt import Figure
66

77

8+
@pytest.mark.benchmark
89
@pytest.mark.mpl_image_compare
910
def test_logo():
1011
"""

pygmt/tests/test_makecpt.py

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def test_makecpt_plot_colorbar_scaled_with_series(position):
7171
return fig
7272

7373

74+
@pytest.mark.benchmark
7475
def test_makecpt_output_cpt_file():
7576
"""
7677
Save the generated static color palette table to a .cpt file.

pygmt/tests/test_meca.py

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def test_meca_spec_single_focalmecha_file():
8181
return fig
8282

8383

84+
@pytest.mark.benchmark
8485
@pytest.mark.mpl_image_compare(filename="test_meca_spec_multiple_focalmecha.png")
8586
@pytest.mark.parametrize(
8687
"inputtype", ["dict_mecha", "dict_mecha_mixed", "dataframe", "array2d"]

pygmt/tests/test_nearneighbor.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_nearneighbor_input_data(array_func, ship_data):
3737
npt.assert_allclose(output.mean(), -2378.2385)
3838

3939

40+
@pytest.mark.benchmark
4041
def test_nearneighbor_input_xyz(ship_data):
4142
"""
4243
Run nearneighbor by passing in x, y, z numpy.ndarrays individually.

pygmt/tests/test_plot.py

+1
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def test_plot_from_file(region):
352352
return fig
353353

354354

355+
@pytest.mark.benchmark
355356
@pytest.mark.mpl_image_compare
356357
def test_plot_vectors():
357358
"""

pygmt/tests/test_plot3d.py

+1
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ def test_plot3d_from_file(region):
378378
return fig
379379

380380

381+
@pytest.mark.benchmark
381382
@pytest.mark.mpl_image_compare
382383
def test_plot3d_vectors():
383384
"""

pygmt/tests/test_project.py

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_project_generate():
3434
)
3535

3636

37+
@pytest.mark.benchmark
3738
@pytest.mark.parametrize("array_func", [np.array, pd.DataFrame, xr.Dataset])
3839
def test_project_input_matrix(array_func, dataframe):
3940
"""

pygmt/tests/test_psconvert.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pygmt.exceptions import GMTInvalidInput
99

1010

11+
@pytest.mark.benchmark
1112
def test_psconvert():
1213
"""
1314
Check that psconvert creates a figure in the current directory.

pygmt/tests/test_rose.py

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def test_rose_2d_array_multiple(data):
9191
return fig
9292

9393

94+
@pytest.mark.benchmark
9495
@pytest.mark.mpl_image_compare
9596
def test_rose_plot_data_using_cpt(data):
9697
"""

pygmt/tests/test_select.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def fixture_dataframe():
1919
return load_sample_data(name="bathymetry")
2020

2121

22+
@pytest.mark.benchmark
2223
def test_select_input_dataframe(dataframe):
2324
"""
2425
Run select by passing in a pandas.DataFrame as input.

pygmt/tests/test_session_management.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
"""
44
import os
55

6+
import pytest
67
from pygmt.clib import Session
78
from pygmt.session_management import begin, end
89

910

11+
@pytest.mark.benchmark
1012
def test_begin_end():
1113
"""
1214
Run a command inside a begin-end modern mode block.

pygmt/tests/test_solar.py

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def test_solar_terminators():
3939
return fig
4040

4141

42+
@pytest.mark.benchmark
4243
@pytest.mark.mpl_image_compare(filename="test_solar_set_terminator_datetime.png")
4344
@pytest.mark.parametrize(
4445
"terminator_datetime",

pygmt/tests/test_sph2grd.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pathlib import Path
55

66
import numpy.testing as npt
7+
import pytest
78
from pygmt import sph2grd
89
from pygmt.helpers import GMTTempFile
910

@@ -20,6 +21,7 @@ def test_sph2grd_outgrid():
2021
assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists
2122

2223

24+
@pytest.mark.benchmark
2325
def test_sph2grd_no_outgrid():
2426
"""
2527
Test sph2grd with no set outgrid.

pygmt/tests/test_sphdistance.py

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def test_sphdistance_outgrid(array):
4848
assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists
4949

5050

51+
@pytest.mark.benchmark
5152
def test_sphdistance_no_outgrid(array):
5253
"""
5354
Test sphdistance with no set outgrid.

pygmt/tests/test_sphinterpolate.py

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_sphinterpolate_outgrid(mars):
2828
assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists
2929

3030

31+
@pytest.mark.benchmark
3132
def test_sphinterpolate_no_outgrid(mars):
3233
"""
3334
Test sphinterpolate with no set outgrid.

pygmt/tests/test_subplot.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pygmt.exceptions import GMTInvalidInput
77

88

9+
@pytest.mark.benchmark
910
@pytest.mark.mpl_image_compare
1011
def test_subplot_basic_frame():
1112
"""

pygmt/tests/test_surface.py

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def test_surface_input_data_array(data, region, spacing, expected_grid):
103103
check_values(output, expected_grid)
104104

105105

106+
@pytest.mark.benchmark
106107
def test_surface_input_xyz(data, region, spacing, expected_grid):
107108
"""
108109
Run surface by passing in x, y, z numpy.ndarrays individually.

pygmt/tests/test_ternary.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def test_ternary(array):
6464
return fig
6565

6666

67+
@pytest.mark.benchmark
6768
@pytest.mark.mpl_image_compare
6869
def test_ternary_3_labels(array):
6970
"""

pygmt/tests/test_text.py

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def test_text_single_line_of_text(region, projection):
4646
return fig
4747

4848

49+
@pytest.mark.benchmark
4950
@pytest.mark.mpl_image_compare
5051
def test_text_multiple_lines_of_text(region, projection):
5152
"""

pygmt/tests/test_tilemap.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def test_tilemap_web_mercator():
2424
return fig
2525

2626

27+
@pytest.mark.benchmark
2728
@pytest.mark.mpl_image_compare
2829
def test_tilemap_ogc_wgs84():
2930
"""

pygmt/tests/test_timestamp.py

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_timestamp_offset():
6161
return fig
6262

6363

64+
@pytest.mark.benchmark
6465
@pytest.mark.mpl_image_compare
6566
def test_timestamp_font(faketime):
6667
"""

0 commit comments

Comments
 (0)