Skip to content

Commit 0ed8eb4

Browse files
committed
Fix test values and truncate docstrings to 79 char
Make tests pass again, by fixing the test bathymetry values, and cutting our docstrings to 79 characters instead of 88.
1 parent fb8bb46 commit 0ed8eb4

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

pygmt/datasets/tutorial.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def load_japan_quakes():
4040

4141
def load_ocean_ridge_points():
4242
"""
43-
Load a table of ocean ridge points for the entire world as a pandas.DataFrame.
43+
Load a table of ocean ridge points for the entire world as a
44+
pandas.DataFrame.
4445
4546
This is the ``@ridge.txt`` dataset used in the GMT tutorials.
4647

pygmt/sampling.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,39 @@ def grdtrack(points, grid, newcolname=None, outfile=None, **kwargs):
2020
Sample grids at specified (x,y) locations.
2121
2222
Grdtrack reads one or more grid files and a table with (x,y) [or (lon,lat)]
23-
positions in the first two columns (more columns may be present). It interpolates
24-
the grid(s) at the positions in the table and writes out the table with the
25-
interpolated values added as (one or more) new columns. A bicubic [Default],
26-
bilinear, B-spline or nearest-neighbor (see -n) interpolation is used, requiring
27-
boundary conditions at the limits of the region.
23+
positions in the first two columns (more columns may be present). It
24+
interpolates the grid(s) at the positions in the table and writes out the
25+
table with the interpolated values added as (one or more) new columns. A
26+
bicubic [Default], bilinear, B-spline or nearest-neighbor (see -n)
27+
interpolation is used, requiring boundary conditions at the limits of the
28+
region.
2829
2930
Full option list at :gmt-docs:`grdtrack.html`
3031
3132
Parameters
3233
----------
3334
points: pandas.DataFrame or file (csv, txt, etc)
34-
Either a table with (x, y) or (lon, lat) values in the first two columns,
35-
or a data file name. More columns may be present.
35+
Either a table with (x, y) or (lon, lat) values in the first two
36+
columns, or a data file name. More columns may be present.
3637
3738
grid: xarray.DataArray or file (netcdf)
3839
Gridded array from which to sample values from.
3940
4041
newcolname: str
41-
Required if 'points' is a pandas.DataFrame. The name for the new column in the
42-
track pandas.DataFrame table where the sampled values will be placed.
42+
Required if 'points' is a pandas.DataFrame. The name for the new column
43+
in the track pandas.DataFrame table where the sampled values will be
44+
placed.
4345
4446
outfile: str
45-
Required if 'points' is a file. The file name for the output ASCII file.
47+
Required if 'points' is a file. The file name for the output ASCII
48+
file.
4649
4750
Returns
4851
-------
4952
track: pandas.DataFrame or None
5053
Return type depends on whether the outfile parameter is set:
51-
- pandas.DataFrame table with (x, y, ..., newcolname) if outfile is not set
54+
- pandas.DataFrame table with (x, y, ..., newcolname) if outfile is not
55+
set
5256
- None if outfile is set (track output will be stored in outfile)
5357
5458
"""
@@ -75,7 +79,8 @@ def grdtrack(points, grid, newcolname=None, outfile=None, **kwargs):
7579
else:
7680
raise GMTInvalidInput(f"Unrecognized data type {type(grid)}")
7781

78-
# Run grdtrack on the temp (csv) points table and (netcdf) grid virtualfiles
82+
# Run grdtrack on the temporary (csv) points table
83+
# and (netcdf) grid virtualfile
7984
with table_context as csvfile:
8085
with grid_context as grdfile:
8186
kwargs.update({"G": grdfile})

pygmt/tests/test_grdtrack.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919

2020
def test_grdtrack_input_dataframe_and_dataarray():
2121
"""
22-
Run grdtrack by passing in a pandas.DataFrame and xarray.DataArray as inputs
22+
Run grdtrack by passing in a pandas.DataFrame and xarray.DataArray as
23+
inputs
2324
"""
2425
dataframe = load_ocean_ridge_points()
2526
dataarray = load_earth_relief().sel(lat=slice(-49, -42), lon=slice(-118, -107))
2627

2728
output = grdtrack(points=dataframe, grid=dataarray, newcolname="bathymetry")
2829
assert isinstance(output, pd.DataFrame)
2930
assert output.columns.to_list() == ["longitude", "latitude", "bathymetry"]
30-
npt.assert_allclose(output.iloc[0], [-110.9536, -42.2489, -2799.085897])
31+
npt.assert_allclose(output.iloc[0], [-110.9536, -42.2489, -2797.482959])
3132

3233
return output
3334

@@ -45,7 +46,7 @@ def test_grdtrack_input_csvfile_and_dataarray():
4546
assert os.path.exists(path=TEMP_TRACK) # check that outfile exists at path
4647

4748
track = pd.read_csv(TEMP_TRACK, sep="\t", header=None, comment=">")
48-
npt.assert_allclose(track.iloc[0], [-110.9536, -42.2489, -2799.085897])
49+
npt.assert_allclose(track.iloc[0], [-110.9536, -42.2489, -2797.482959])
4950
finally:
5051
os.remove(path=TEMP_TRACK)
5152

@@ -62,7 +63,7 @@ def test_grdtrack_input_dataframe_and_ncfile():
6263
output = grdtrack(points=dataframe, grid=ncfile, newcolname="bathymetry")
6364
assert isinstance(output, pd.DataFrame)
6465
assert output.columns.to_list() == ["longitude", "latitude", "bathymetry"]
65-
npt.assert_allclose(output.iloc[0], [-32.2971, 37.4118, -1685.745884])
66+
npt.assert_allclose(output.iloc[0], [-32.2971, 37.4118, -1686.692142])
6667

6768
return output
6869

@@ -80,7 +81,7 @@ def test_grdtrack_input_csvfile_and_ncfile():
8081
assert os.path.exists(path=TEMP_TRACK) # check that outfile exists at path
8182

8283
track = pd.read_csv(TEMP_TRACK, sep="\t", header=None, comment=">")
83-
npt.assert_allclose(track.iloc[0], [-32.2971, 37.4118, -1685.745884])
84+
npt.assert_allclose(track.iloc[0], [-32.2971, 37.4118, -1686.692142])
8485
finally:
8586
os.remove(path=TEMP_TRACK)
8687

@@ -89,7 +90,8 @@ def test_grdtrack_input_csvfile_and_ncfile():
8990

9091
def test_grdtrack_wrong_kind_of_points_input():
9192
"""
92-
Run grdtrack using points input that is not a pandas.DataFrame (matrix) or file
93+
Run grdtrack using points input that is not a pandas.DataFrame (matrix) or
94+
file
9395
"""
9496
dataframe = load_ocean_ridge_points()
9597
invalid_points = dataframe.longitude.to_xarray()
@@ -102,7 +104,8 @@ def test_grdtrack_wrong_kind_of_points_input():
102104

103105
def test_grdtrack_wrong_kind_of_grid_input():
104106
"""
105-
Run grdtrack using grid input that is not as xarray.DataArray (grid) or file
107+
Run grdtrack using grid input that is not as xarray.DataArray (grid) or
108+
file
106109
"""
107110
dataframe = load_ocean_ridge_points()
108111
dataarray = load_earth_relief().sel(lat=slice(-49, -42), lon=slice(-118, -107))

0 commit comments

Comments
 (0)