Skip to content

Commit

Permalink
Merge branch 'main' into improve-meca-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Dec 5, 2022
2 parents 7b1b17e + c5c404b commit 61c4f2a
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/cache_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
run-post: false
use-mamba: true

# Install GMT and other required dependencies from conda-forge
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
run-post: false
use-mamba: true

# Install GMT and other required dependencies from conda-forge
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
run-post: false
use-mamba: true

# Install GMT and other required dependencies from conda-forge
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci_tests_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
run-post: false
use-mamba: true

# Install dependencies from conda-forge
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci_tests_legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
run-post: false
use-mamba: true

# Install GMT and other required dependencies from conda-forge
Expand Down
24 changes: 23 additions & 1 deletion pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def list_sample_data():
"mars_shape": "Table of topographic signature of the hemispheric dichotomy of "
" Mars from Smith and Zuber (1996)",
"maunaloa_co2": "Table of CO2 readings from Mauna Loa",
"ocean_ridge_points": "Table of ocean ridge points for the entire world",
"notre_dame_topography": "Table 5.11 in Davis: Statistics and Data Analysis in Geology",
"ocean_ridge_points": "Table of ocean ridge points for the entire world",
"rock_compositions": "Table of rock sample compositions",
"usgs_quakes": "Table of global earthquakes from the USGS",
}
return names
Expand Down Expand Up @@ -80,6 +81,7 @@ def load_sample_data(name):

# Dictionary of private load functions
load_func = {
"rock_compositions": _load_rock_sample_compositions,
"earth_relief_holes": _load_earth_relief_holes,
"maunaloa_co2": _load_maunaloa_co2,
"notre_dame_topography": _load_notre_dame_topography,
Expand Down Expand Up @@ -360,6 +362,26 @@ def load_mars_shape(**kwargs):
return data


def _load_rock_sample_compositions():
"""
Loads a table of rock sample compositions.
Returns
-------
data : pandas.DataFrame
The data table with columns "water", "air", and "limestone".
"""

fname = which("@ternary.txt", download="c")
return pd.read_csv(
fname,
delim_whitespace=True,
header=None,
names=["water", "air", "limestone"],
usecols=(0, 1, 2),
)


def _load_notre_dame_topography():
"""
Load Table 5.11 in Davis: Statistics and Data Analysis in Geology.
Expand Down
15 changes: 15 additions & 0 deletions pygmt/tests/test_datasets_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,18 @@ def test_maunaloa_co2():
assert summary.loc["max", "date"] == 2019.3699
assert summary.loc["min", "co2_ppm"] == 313.2
assert summary.loc["max", "co2_ppm"] == 414.83


def test_rock_sample_compositions():
"""
Check that the @ternary.txt dataset loads without errors.
"""
data = load_sample_data(name="rock_compositions")
assert data.shape == (1000, 3)
summary = data.describe()
assert summary.loc["min", "water"] == 0
assert summary.loc["max", "water"] == 1
assert summary.loc["min", "air"] == 0
assert summary.loc["max", "air"] == 0.921
assert summary.loc["min", "limestone"] == 0
assert summary.loc["max", "limestone"] == 0.981

0 comments on commit 61c4f2a

Please sign in to comment.