Skip to content

Commit

Permalink
Test passing event names via pandas.DataFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Jun 22, 2023
1 parent 3c9fe8e commit c1228c0
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions pygmt/tests/test_meca.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import numpy as np
import pandas as pd
import pytest
from pygmt import Figure
from packaging.version import Version
from pygmt import Figure, __gmt_version__
from pygmt.helpers import GMTTempFile


Expand Down Expand Up @@ -179,20 +180,52 @@ def test_meca_offset(inputtype):
return fig


# Passing event names via pandas doesn't work for GMT<=6.4, thus marked as
# xfail. See https://github.com/GenericMappingTools/pygmt/issues/2524.
@pytest.mark.mpl_image_compare(filename="test_meca_eventname.png")
@pytest.mark.parametrize("inputtype", ["eventname_args"])
@pytest.mark.parametrize(
"inputtype",
[
"args",
pytest.param(
"pandas",
marks=pytest.mark.xfail(
condition=Version(__gmt_version__) < Version("6.5.0"),
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/7557",
),
),
],
)
def test_meca_eventname(inputtype):
"""
Test passing event names.
"""
if inputtype == "eventname_args":
if inputtype == "args":
args = {
"spec": {"strike": 330, "dip": 30, "rake": 90, "magnitude": 3},
"longitude": -124,
"latitude": 48,
"depth": 12.0,
"event_name": "Event20220311",
}
elif inputtype == "pandas":
# Test pandas input. Requires GMT>=6.5.
# See https://github.com/GenericMappingTools/pygmt/issues/2524.
# The numeric columns must be in float type to trigger the bug.
args = {
"spec": pd.DataFrame(
{
"longitude": [-124.0],
"latitude": [48.0],
"depth": [12.0],
"strike": [330.0],
"dip": [30.0],
"rake": [90.0],
"magnitude": [3.0],
"event_name": ["Event20220311"],
}
)
}
fig = Figure()
fig.basemap(region=[-125, -122, 47, 49], projection="M6c", frame=True)
fig.meca(scale="1c", **args)
Expand Down

0 comments on commit c1228c0

Please sign in to comment.