From cdc8b25f467f91f52feaa92dca0ccfb8cbbf79ed Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 15 Sep 2025 12:39:41 +1200 Subject: [PATCH 1/5] Try using skipna=True in min() for test_binstats_quantile --- pygmt/tests/test_binstats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygmt/tests/test_binstats.py b/pygmt/tests/test_binstats.py index 9d633aebf3e..44db657a50c 100644 --- a/pygmt/tests/test_binstats.py +++ b/pygmt/tests/test_binstats.py @@ -67,7 +67,8 @@ def test_binstats_quantile(): assert temp_grid.dims == ("y", "x") assert temp_grid.gmt.gtype is GridType.CARTESIAN assert temp_grid.gmt.registration is GridRegistration.GRIDLINE + assert temp_grid.dtype == "float32" npt.assert_allclose(temp_grid.max(), 15047685) - npt.assert_allclose(temp_grid.min(), 53) + npt.assert_allclose(temp_grid.min(skipna=True), 53) npt.assert_allclose(temp_grid.median(), 543664.5) npt.assert_allclose(temp_grid.mean(), 1661363.6) From b37898b3087f5e78d1c181f386259fac66483c12 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 15 Sep 2025 12:45:12 +1200 Subject: [PATCH 2/5] Temporarily trigger ci_tests_legacy --- .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 b5fa4860af5..992096627b3 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -12,7 +12,7 @@ on: # push: # branches: [ main ] # Uncomment the 'pull_request' line below to trigger the workflow in PR - # pull_request: + pull_request: # types: [ready_for_review] # paths: # - 'pygmt/**' From dd5abb4a2932a23e688e06f626c7f2ef8beba30c Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 15 Sep 2025 13:06:09 +1200 Subject: [PATCH 3/5] Specify different min/median/mean values for GMT 6.4 --- pygmt/tests/test_binstats.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pygmt/tests/test_binstats.py b/pygmt/tests/test_binstats.py index 44db657a50c..9b7bf4942b1 100644 --- a/pygmt/tests/test_binstats.py +++ b/pygmt/tests/test_binstats.py @@ -6,7 +6,9 @@ import numpy.testing as npt import pytest +from packaging.version import Version from pygmt import binstats +from pygmt.clib import __gmt_version__ from pygmt.enums import GridRegistration, GridType from pygmt.helpers import GMTTempFile @@ -69,6 +71,11 @@ def test_binstats_quantile(): assert temp_grid.gmt.registration is GridRegistration.GRIDLINE assert temp_grid.dtype == "float32" npt.assert_allclose(temp_grid.max(), 15047685) - npt.assert_allclose(temp_grid.min(skipna=True), 53) - npt.assert_allclose(temp_grid.median(), 543664.5) - npt.assert_allclose(temp_grid.mean(), 1661363.6) + if Version(__gmt_version__) > Version("6.4.0"): + npt.assert_allclose(temp_grid.min(), 53) + npt.assert_allclose(temp_grid.median(), 543664.5) + npt.assert_allclose(temp_grid.mean(), 1661363.6) + else: # TODO(GMT>=6.5.0): Remove if-condition with different min/median/mean values + npt.assert_allclose(temp_grid.min(), 0) + npt.assert_allclose(temp_grid.median(), 330700.0) + npt.assert_allclose(temp_grid.mean(), 1459889.1) From 1dc2e4223e9183cfa7d037c72c928b74bca6c7d8 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 16 Sep 2025 15:43:34 +1200 Subject: [PATCH 4/5] Mark test_binstats_quantile as xfail on GMT<6.5 Xref https://github.com/GenericMappingTools/gmt/pull/8243 --- pygmt/tests/test_binstats.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pygmt/tests/test_binstats.py b/pygmt/tests/test_binstats.py index 9b7bf4942b1..53626f16364 100644 --- a/pygmt/tests/test_binstats.py +++ b/pygmt/tests/test_binstats.py @@ -53,6 +53,11 @@ def test_binstats_no_outgrid(): npt.assert_allclose(temp_grid.mean(), 4227489) +# TODO(GMT>=6.5.0): Remove the xfail marker for the upstream bug fixed in GMT 6.5.0. +@pytest.mark.xfail( + condition=Version(__gmt_version__) < Version("6.5.0"), + reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8243", +) def test_binstats_quantile(): """ Test binstats quantile statistic functionality. @@ -71,11 +76,6 @@ def test_binstats_quantile(): assert temp_grid.gmt.registration is GridRegistration.GRIDLINE assert temp_grid.dtype == "float32" npt.assert_allclose(temp_grid.max(), 15047685) - if Version(__gmt_version__) > Version("6.4.0"): - npt.assert_allclose(temp_grid.min(), 53) - npt.assert_allclose(temp_grid.median(), 543664.5) - npt.assert_allclose(temp_grid.mean(), 1661363.6) - else: # TODO(GMT>=6.5.0): Remove if-condition with different min/median/mean values - npt.assert_allclose(temp_grid.min(), 0) - npt.assert_allclose(temp_grid.median(), 330700.0) - npt.assert_allclose(temp_grid.mean(), 1459889.1) + npt.assert_allclose(temp_grid.min(), 53) + npt.assert_allclose(temp_grid.median(), 543664.5) + npt.assert_allclose(temp_grid.mean(), 1661363.6) From bf228bd9dcf8f569923f73f8015f146d58a256cb Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 16 Sep 2025 15:47:50 +1200 Subject: [PATCH 5/5] Revert "Temporarily trigger ci_tests_legacy" This reverts commit b37898b3087f5e78d1c181f386259fac66483c12. --- .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 992096627b3..b5fa4860af5 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -12,7 +12,7 @@ on: # push: # branches: [ main ] # Uncomment the 'pull_request' line below to trigger the workflow in PR - pull_request: + # pull_request: # types: [ready_for_review] # paths: # - 'pygmt/**'