Skip to content

Remove xfail on grdtrack tests for GMT 6.2.0 - #1304

Merged
seisman merged 3 commits into
masterfrom
xfail/grdtrack
Jun 6, 2021
Merged

seisman merged 3 commits into
masterfrom
xfail/grdtrack

Conversation

@seisman

@seisman seisman commented May 27, 2021 •

Copy link
Copy Markdown
Member

Description of proposed changes

See #1309 for the issue report of an upstream bug. The bug was partially fixed in GenericMappingTools/gmt#5283, by restricting bilinear interpolation when grdtrack is applied to an xarray.DataArray.

Now the two tests pass for GMT 6.2.0.

Fixes #1309

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels May 27, 2021
@seisman seisman added this to the 0.4.0 milestone May 27, 2021
@seisman

seisman commented May 27, 2021

Copy link
Copy Markdown
Member Author

Weird. These two tests are "xpass" on master branch.

@weiji14

weiji14 commented May 27, 2021 •

Copy link
Copy Markdown
Member

Weird. These two tests are "xpass" on master branch.

These two tests pass only on Linux. If you want, you can set a condition to xfail only on macOS/Windows. Or debug to see what's going on (the diff is only on the z/elevation value).

Edit: For reference, this is the error on macOS Python 3.9/NumPy 1.20 (https://github.com/GenericMappingTools/pygmt/pull/1304/checks?check_run_id=2686875657#step:11:481)

_________________ test_grdtrack_input_dataframe_and_dataarray __________________

dataarray = <xarray.DataArray 'elevation' (lat: 8, lon: 12)>
array([[-3385. , -3201.5, -3104. , -2953. , -2754. , -2782. , -2957.5...elevation relative to the geoid
    units:             meters
    vertical_datum:    EMG96
    horizontal_datum:  WGS84

    def test_grdtrack_input_dataframe_and_dataarray(dataarray):
        """
        Run grdtrack by passing in a pandas.DataFrame and xarray.DataArray as
        inputs.
        """
        dataframe = load_ocean_ridge_points()
    
        output = grdtrack(points=dataframe, grid=dataarray, newcolname="bathymetry")
        assert isinstance(output, pd.DataFrame)
        assert output.columns.to_list() == ["longitude", "latitude", "bathymetry"]
>       npt.assert_allclose(output.iloc[0], [-110.9536, -42.2489, -2974.656296])
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 1 / 3 (33.3%)
E       Max absolute difference: 3.70371641e+28
E       Max relative difference: 1.24509054e+25
E        x: array([-1.109536e+02, -4.224890e+01, -3.703716e+28])
E        y: array([ -110.9536  ,   -42.2489  , -2974.656296])

../../../../miniconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/tests/test_grdtrack.py:38: AssertionError
----------------------------- Captured stderr call -----------------------------
Warning: [WARNING]: Some input points were outside the grid domain(s).
__________________ test_grdtrack_input_csvfile_and_dataarray ___________________

dataarray = <xarray.DataArray 'elevation' (lat: 8, lon: 12)>
array([[-3385. , -3201.5, -3104. , -2953. , -2754. , -2782. , -2957.5...elevation relative to the geoid
    units:             meters
    vertical_datum:    EMG96
    horizontal_datum:  WGS84

    def test_grdtrack_input_csvfile_and_dataarray(dataarray):
        """
        Run grdtrack by passing in a csvfile and xarray.DataArray as inputs.
        """
        csvfile = which("@ridge.txt", download="c")
    
        try:
            output = grdtrack(points=csvfile, grid=dataarray, outfile=TEMP_TRACK)
            assert output is None  # check that output is None since outfile is set
            assert os.path.exists(path=TEMP_TRACK)  # check that outfile exists at path
    
            track = pd.read_csv(TEMP_TRACK, sep="\t", header=None, comment=">")
>           npt.assert_allclose(track.iloc[0], [-110.9536, -42.2489, -2974.656296])
E           AssertionError: 
E           Not equal to tolerance rtol=1e-07, atol=0
E           
E           Mismatched elements: 1 / 3 (33.3%)
E           Max absolute difference: 2.50459628e+26
E           Max relative difference: 8.41978376e+22
E            x: array([-1.109536e+02, -4.224890e+01,  2.504596e+26])
E            y: array([ -110.9536  ,   -42.2489  , -2974.656296])

../../../../miniconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/tests/test_grdtrack.py:55: AssertionError

@seisman
seisman marked this pull request as draft May 27, 2021 22:21
@weiji14 weiji14 mentioned this pull request Jun 2, 2021
12 of 13 tasks
@weiji14 weiji14 mentioned this pull request Jun 6, 2021
7 tasks done
@seisman seisman changed the title Remove xfail on grdtrack tests for GMT 6.2.0rc2 Remove xfail on grdtrack tests for GMT 6.2.0 Jun 6, 2021
@seisman
seisman marked this pull request as ready for review June 6, 2021 03:21

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@seisman
seisman merged commit 638adab into master Jun 6, 2021
@seisman
seisman deleted the xfail/grdtrack branch June 6, 2021 04:35
seisman added a commit that referenced this pull request Jun 8, 2021
* Remove xfail on grdtrack tests for GMT 6.2.0
* Update the grdtrack tests so that it pass for GMT 6.2.0
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
* Remove xfail on grdtrack tests for GMT 6.2.0
* Update the grdtrack tests so that it pass for GMT 6.2.0

This branch was previously deployed

1 inactive deployment
Preview — 23377f86 Deployed Jun 6, 2021 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

grdtrack produces incorrect results for xarray.DataArray grid

2 participants