Skip to content

Commit a88e9db

Browse files
committed
Update velo
1 parent 30a27af commit a88e9db

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pygmt/src/velo.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pandas as pd
77
from pygmt._typing import PathLike, TableLike
88
from pygmt.clib import Session
9-
from pygmt.exceptions import GMTInvalidInput
9+
from pygmt.exceptions import GMTInvalidInput, GMTTypeError
1010
from pygmt.helpers import (
1111
build_arg_list,
1212
fmt_docstring,
@@ -248,11 +248,13 @@ def velo(self, data: PathLike | TableLike | None = None, **kwargs):
248248
raise GMTInvalidInput(msg)
249249

250250
if isinstance(data, np.ndarray) and not pd.api.types.is_numeric_dtype(data):
251-
msg = (
252-
"Text columns are not supported with numpy.ndarray type inputs. "
253-
"They are only supported with file or pandas.DataFrame inputs."
251+
raise GMTTypeError(
252+
type(data),
253+
reason=(
254+
"Text columns are not supported with numpy.ndarray type inputs. "
255+
"They are only supported with file or pandas.DataFrame inputs."
256+
),
254257
)
255-
raise GMTInvalidInput(msg)
256258

257259
with Session() as lib:
258260
with lib.virtualfile_in(check_kind="vector", data=data) as vintbl:

pygmt/tests/test_velo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pandas as pd
66
import pytest
77
from pygmt import Figure
8-
from pygmt.exceptions import GMTInvalidInput
8+
from pygmt.exceptions import GMTInvalidInput, GMTTypeError
99

1010

1111
@pytest.fixture(scope="module", name="dataframe")
@@ -47,7 +47,7 @@ def test_velo_numpy_array_text_column(dataframe):
4747
Check that velo fails when plotting a numpy.ndarray with a text column.
4848
"""
4949
fig = Figure()
50-
with pytest.raises(GMTInvalidInput):
50+
with pytest.raises(GMTTypeError):
5151
fig.velo(
5252
data=dataframe.to_numpy(),
5353
spec="e0.2/0.39/18",

0 commit comments

Comments
 (0)