Skip to content

Commit 7c25db1

Browse files
Merge branch 'master' into test-coast-dvc
2 parents 2c27ee7 + 1ac4c59 commit 7c25db1

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

.github/workflows/ci_tests_dev.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# This workflow installs PyGMT dependencies, builds documentation and runs tests on GMT dev version
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
1+
# This workflow installs PyGMT and runs tests on GMT dev version
32

43
name: GMT Dev Tests
54

@@ -10,10 +9,13 @@ on:
109
types: [ready_for_review]
1110
paths-ignore:
1211
- 'doc/**'
12+
- 'examples/**'
1313
- '*.md'
1414
- '*.json'
1515
- 'README.rst'
1616
- 'LICENSE.txt'
17+
- '.gitignore'
18+
- '.pylintrc'
1719
repository_dispatch:
1820
types: [test-gmt-dev-command]
1921
# Schedule daily tests
@@ -28,7 +30,7 @@ jobs:
2830
fail-fast: false
2931
matrix:
3032
python-version: [3.9]
31-
os: [ubuntu-20.04, macOS-10.15, windows-latest]
33+
os: [ubuntu-latest, macOS-11.0, windows-latest]
3234
gmt_git_ref: [master]
3335
defaults:
3436
run:
@@ -73,6 +75,7 @@ jobs:
7375
- name: Setup Miniconda
7476
uses: conda-incubator/setup-miniconda@v2.0.1
7577
with:
78+
activate-environment: pygmt
7679
python-version: ${{ matrix.python-version }}
7780
channels: conda-forge
7881
miniconda-version: "latest"
@@ -81,8 +84,9 @@ jobs:
8184
- name: Install dependencies
8285
run: |
8386
conda install ninja cmake libblas libcblas liblapack fftw gdal \
84-
ghostscript libnetcdf hdf5 zlib curl pcre ipython \
85-
dvc pytest pytest-cov pytest-mpl
87+
ghostscript libnetcdf hdf5 zlib curl pcre make dvc
88+
pip install --pre numpy pandas xarray netCDF4 packaging \
89+
ipython pytest-cov pytest-mpl pytest>=6.0 sphinx-gallery
8690
8791
# Build and install latest GMT from GitHub
8892
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Linux/macOS)

CONTRIBUTING.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -369,35 +369,13 @@ or run tests which contain names that match a specific keyword expression:
369369
Writing an image-based test is only slightly more difficult than a simple test.
370370
The main consideration is that you must specify the "baseline" or reference
371371
image, and compare it with a "generated" or test image. This is handled using
372-
the *decorator* functions `@check_figures_equal` and
373-
`@pytest.mark.mpl_image_compare` whose usage are further described below.
374-
375-
#### Using check_figures_equal
376-
377-
This approach draws the same figure using two different methods (the reference
378-
method and the tested method), and checks that both of them are the same.
379-
It takes two `pygmt.Figure` objects ('fig_ref' and 'fig_test'), generates a png
380-
image, and checks for the Root Mean Square (RMS) error between the two.
381-
Here's an example:
382-
383-
```python
384-
@check_figures_equal()
385-
def test_my_plotting_case():
386-
"Test that my plotting function works"
387-
fig_ref, fig_test = Figure(), Figure()
388-
fig_ref.grdimage("@earth_relief_01d_g", projection="W120/15c", cmap="geo")
389-
fig_test.grdimage(grid, projection="W120/15c", cmap="geo")
390-
return fig_ref, fig_test
391-
```
392-
393-
Note: This is the recommended way to test plots whenever possible, such as when
394-
we want to compare a reference GMT plot created from NetCDF files with one
395-
generated by PyGMT that passes through several layers of virtualfile machinery.
396-
Using this method will help save space in the git repository by not having to
397-
store baseline images as with the other method below.
372+
the *decorator* functions `@pytest.mark.mpl_image_compare` and `@check_figures_equal`
373+
whose usage are further described below.
398374

399375
#### Using mpl_image_compare
400376

377+
> **This is the preferred way to test plots whenever possible.**
378+
401379
This method uses the [pytest-mpl](https://github.com/matplotlib/pytest-mpl)
402380
plug-in to test plot generating code.
403381
Every time the tests are run, `pytest-mpl` compares the generated plots with known
@@ -502,6 +480,24 @@ summarized as follows:
502480
git push
503481
dvc push
504482

483+
#### Using check_figures_equal
484+
485+
This approach draws the same figure using two different methods (the reference
486+
method and the tested method), and checks that both of them are the same.
487+
It takes two `pygmt.Figure` objects ('fig_ref' and 'fig_test'), generates a png
488+
image, and checks for the Root Mean Square (RMS) error between the two.
489+
Here's an example:
490+
491+
```python
492+
@check_figures_equal()
493+
def test_my_plotting_case():
494+
"Test that my plotting function works"
495+
fig_ref, fig_test = Figure(), Figure()
496+
fig_ref.grdimage("@earth_relief_01d_g", projection="W120/15c", cmap="geo")
497+
fig_test.grdimage(grid, projection="W120/15c", cmap="geo")
498+
return fig_ref, fig_test
499+
```
500+
505501
### Documentation
506502

507503
#### Building the documentation

pygmt/datasets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Load sample data included with GMT (downloaded from the GMT cache server).
44

55
from pygmt.datasets.earth_relief import load_earth_relief
6-
from pygmt.datasets.tutorial import (
6+
from pygmt.datasets.samples import (
77
load_japan_quakes,
88
load_ocean_ridge_points,
99
load_sample_bathymetry,

pygmt/datasets/tutorial.py renamed to pygmt/datasets/samples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Functions to load sample data from the GMT tutorials.
2+
Functions to load sample data.
33
"""
44
import pandas as pd
55
from pygmt.src import which

pygmt/tests/test_datasets_tutorial.py renamed to pygmt/tests/test_datasets_samples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Test basic functionality for loading datasets for tutorials.
2+
Test basic functionality for loading sample datasets.
33
"""
44
from pygmt.datasets import (
55
load_japan_quakes,

0 commit comments

Comments
 (0)