From ae99d158b9a361682f80da197cd10633791b6f27 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 28 Dec 2022 15:58:47 -0500 Subject: [PATCH 01/13] Install ipython in GMT Legacy Tests CI environment To fix errors like `pygmt.exceptions.GMTError: Notebook display is selected, but IPython is not available. Make sure you have IPython installed, or run the script in a Jupyter notebook`. --- .github/workflows/ci_tests_legacy.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 47ac45f2375..7cd266b10ea 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -65,7 +65,8 @@ jobs: - name: Install dependencies run: | mamba install gmt=${{ matrix.gmt_version }} numpy \ - pandas xarray netCDF4 packaging geopandas \ + pandas xarray netCDF4 packaging \ + geopandas ipython \ build dvc make 'pytest>=6.0' \ pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery From 718af824a04d67299391f2dfee6a8785b7ec2bdb Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 28 Dec 2022 15:59:34 -0500 Subject: [PATCH 02/13] Temporarily enable tests with GMT 6.3 --- .github/workflows/ci_tests_legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 7cd266b10ea..245c2fb5418 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -5,7 +5,7 @@ name: GMT Legacy Tests on: # push: # branches: [ main ] - # pull_request: + pull_request: # types: [ready_for_review] # paths-ignore: # - 'doc/**' From eb2a42c10b85271e53638f940f8001bfc7a177b6 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 28 Dec 2022 20:18:17 -0500 Subject: [PATCH 03/13] Use doctest-plus in make test_no_images to skip some inline doctests Xref https://github.com/GenericMappingTools/pygmt/pull/1790. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 45aaf4fff4a..6db8469ef4b 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ test_no_images: # use -o to override the addopts in pyproject.toml file cd $(TESTDIR); \ PYGMT_USE_EXTERNAL_DISPLAY="false" \ - pytest -o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-modules" \ + pytest -o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-plus --doctest-modules" \ $(PYTEST_COV_ARGS) $(PROJECT) rm -r $(TESTDIR) From 118f57b3f268115a466c5588b79eed8ba89251f5 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 28 Dec 2022 20:36:42 -0500 Subject: [PATCH 04/13] Just use doctest-plus without doctest-modules Using both `--doctest-plus` and `--doctest-modules` is redundant as only `--doctest-plus` will be used, see https://github.com/astropy/pytest-doctestplus/tree/v0.12.1#setup-and-configuration. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6db8469ef4b..4cc15b0d957 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ test_no_images: # use -o to override the addopts in pyproject.toml file cd $(TESTDIR); \ PYGMT_USE_EXTERNAL_DISPLAY="false" \ - pytest -o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-plus --doctest-modules" \ + pytest -o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-plus" \ $(PYTEST_COV_ARGS) $(PROJECT) rm -r $(TESTDIR) From d803c6e4923d259707b1faf25e2d6493b707049d Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 28 Dec 2022 15:58:47 -0500 Subject: [PATCH 05/13] Revert "Install ipython in GMT Legacy Tests CI environment" This reverts commit ae99d158b9a361682f80da197cd10633791b6f27. --- .github/workflows/ci_tests_legacy.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 245c2fb5418..0e50c83f7bb 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -65,8 +65,7 @@ jobs: - name: Install dependencies run: | mamba install gmt=${{ matrix.gmt_version }} numpy \ - pandas xarray netCDF4 packaging \ - geopandas ipython \ + pandas xarray netCDF4 packaging geopandas \ build dvc make 'pytest>=6.0' \ pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery From a5fbe5ac5a45b76954329c920a9bc98f688a39cb Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 29 Dec 2022 17:02:29 +0800 Subject: [PATCH 06/13] Revert the doctest-modules to doctest-plus change to run inline doctests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4cc15b0d957..45aaf4fff4a 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ test_no_images: # use -o to override the addopts in pyproject.toml file cd $(TESTDIR); \ PYGMT_USE_EXTERNAL_DISPLAY="false" \ - pytest -o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-plus" \ + pytest -o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-modules" \ $(PYTEST_COV_ARGS) $(PROJECT) rm -r $(TESTDIR) From 5e170ac87bcb6408132f8b7bb93e0869f6fbf606 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 28 Dec 2022 15:58:47 -0500 Subject: [PATCH 07/13] Install ipython in GMT Legacy Tests CI environment To fix errors like `pygmt.exceptions.GMTError: Notebook display is selected, but IPython is not available. Make sure you have IPython installed, or run the script in a Jupyter notebook`. --- .github/workflows/ci_tests_legacy.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 0e50c83f7bb..245c2fb5418 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -65,7 +65,8 @@ jobs: - name: Install dependencies run: | mamba install gmt=${{ matrix.gmt_version }} numpy \ - pandas xarray netCDF4 packaging geopandas \ + pandas xarray netCDF4 packaging \ + geopandas ipython \ build dvc make 'pytest>=6.0' \ pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery From 2901e3681bc52983d62c1753f356114ff4bb09b2 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 30 Dec 2022 08:44:46 -0500 Subject: [PATCH 08/13] Add IPython.core.display.Image object output to 5 doctests --- pygmt/src/coast.py | 1 + pygmt/src/grd2cpt.py | 1 + pygmt/src/grdcontour.py | 1 + pygmt/src/grdimage.py | 1 + pygmt/src/solar.py | 1 + 5 files changed, 5 insertions(+) diff --git a/pygmt/src/coast.py b/pygmt/src/coast.py index 5c727d61529..014c951eddc 100644 --- a/pygmt/src/coast.py +++ b/pygmt/src/coast.py @@ -202,6 +202,7 @@ def coast(self, **kwargs): ... ) >>> # Show the plot >>> fig.show() + """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access if not args_in_kwargs(args=["C", "G", "S", "I", "N", "E", "Q", "W"], kwargs=kwargs): diff --git a/pygmt/src/grd2cpt.py b/pygmt/src/grd2cpt.py index c3b04e8317f..dd847a5fcbb 100644 --- a/pygmt/src/grd2cpt.py +++ b/pygmt/src/grd2cpt.py @@ -175,6 +175,7 @@ def grd2cpt(grid, **kwargs): >>> fig.grdimage(grid=grid) >>> # show the plot >>> fig.show() + """ if kwargs.get("W") is not None and kwargs.get("Ww") is not None: raise GMTInvalidInput("Set only categorical or cyclic to True, not both.") diff --git a/pygmt/src/grdcontour.py b/pygmt/src/grdcontour.py index 170e4cbb832..45689968f5b 100644 --- a/pygmt/src/grdcontour.py +++ b/pygmt/src/grdcontour.py @@ -122,6 +122,7 @@ def grdcontour(self, grid, **kwargs): ... ) >>> # show the plot >>> fig.show() + """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access with Session() as lib: diff --git a/pygmt/src/grdimage.py b/pygmt/src/grdimage.py index fbaa3cf144a..0b88e26088f 100644 --- a/pygmt/src/grdimage.py +++ b/pygmt/src/grdimage.py @@ -173,6 +173,7 @@ def grdimage(self, grid, **kwargs): >>> fig.grdimage(grid=grid, cmap="geo", projection="W10c", frame="ag") >>> # show the plot >>> fig.show() + """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access with Session() as lib: diff --git a/pygmt/src/solar.py b/pygmt/src/solar.py index 86c6194630b..c2aa188c47f 100644 --- a/pygmt/src/solar.py +++ b/pygmt/src/solar.py @@ -89,6 +89,7 @@ def solar(self, terminator="d", terminator_datetime=None, **kwargs): ... ) >>> # show the plot >>> fig.show() + """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access From 0bf561fd707da85aa7a1f4e4108cc2b1042f3b72 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 30 Dec 2022 09:09:41 -0500 Subject: [PATCH 09/13] Use endswith to pick up scheduled full tests on Wednesday Ref https://docs.github.com/en/actions/learn-github-actions/expressions#endswith. --- .github/workflows/ci_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 4a980ee0565..b7d189a7281 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -135,7 +135,7 @@ jobs: # Run full tests including doctests on Wednesday - name: Run full tests - if: github.event_name == 'schedule' && github.event.schedule == '0 0 * * 3' + if: github.event_name == 'schedule' && endswith(github.event.schedule, '3') run: make fulltest PYTEST_EXTRA="-r P" # Upload diff images on test failure From 21cfbff31885370e91416f3efb3821d7cf037e68 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 30 Dec 2022 10:03:16 -0500 Subject: [PATCH 10/13] Run regular tests on non-scheduled events not falling on Wednesday Hopefully this is the correct syntax/logic. --- .github/workflows/ci_tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index b7d189a7281..7cf091c9396 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -130,12 +130,12 @@ jobs: # Run the regular tests - name: Run tests - if: github.event.schedule != '0 0 * * 3' + if: ${{ !endsWith(github.event.schedule, '3') }} run: make test PYTEST_EXTRA="-r P" # Run full tests including doctests on Wednesday - name: Run full tests - if: github.event_name == 'schedule' && endswith(github.event.schedule, '3') + if: github.event_name == 'schedule' && endsWith(github.event.schedule, '3') run: make fulltest PYTEST_EXTRA="-r P" # Upload diff images on test failure From fea7f2f5a5c9aa62656cc6752e25866ae08ac90b Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 30 Dec 2022 10:03:16 -0500 Subject: [PATCH 11/13] Revert "Run regular tests on non-scheduled events not falling on Wednesday" This reverts commit 21cfbff31885370e91416f3efb3821d7cf037e68. --- .github/workflows/ci_tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 7cf091c9396..b7d189a7281 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -130,12 +130,12 @@ jobs: # Run the regular tests - name: Run tests - if: ${{ !endsWith(github.event.schedule, '3') }} + if: github.event.schedule != '0 0 * * 3' run: make test PYTEST_EXTRA="-r P" # Run full tests including doctests on Wednesday - name: Run full tests - if: github.event_name == 'schedule' && endsWith(github.event.schedule, '3') + if: github.event_name == 'schedule' && endswith(github.event.schedule, '3') run: make fulltest PYTEST_EXTRA="-r P" # Upload diff images on test failure From 7585859272fcd624eee5b2e58ac8a141ac396720 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 30 Dec 2022 09:09:41 -0500 Subject: [PATCH 12/13] Revert "Use endswith to pick up scheduled full tests on Wednesday" This reverts commit 0bf561fd707da85aa7a1f4e4108cc2b1042f3b72. --- .github/workflows/ci_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index b7d189a7281..4a980ee0565 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -135,7 +135,7 @@ jobs: # Run full tests including doctests on Wednesday - name: Run full tests - if: github.event_name == 'schedule' && endswith(github.event.schedule, '3') + if: github.event_name == 'schedule' && github.event.schedule == '0 0 * * 3' run: make fulltest PYTEST_EXTRA="-r P" # Upload diff images on test failure From a491019bc37f652fea84a62c0e0a707940c2333e Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 28 Dec 2022 15:59:34 -0500 Subject: [PATCH 13/13] Revert "Temporarily enable tests with GMT 6.3" This reverts commit 718af824a04d67299391f2dfee6a8785b7ec2bdb. --- .github/workflows/ci_tests_legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 245c2fb5418..7cd266b10ea 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -5,7 +5,7 @@ name: GMT Legacy Tests on: # push: # branches: [ main ] - pull_request: + # pull_request: # types: [ready_for_review] # paths-ignore: # - 'doc/**'