28
28
GMTCLibError ,
29
29
GMTCLibNoSessionError ,
30
30
GMTInvalidInput ,
31
+ GMTTypeError ,
31
32
GMTValueError ,
32
33
)
33
34
from pygmt .helpers import (
@@ -629,7 +630,7 @@ def call_module(self, module: str, args: str | list[str]) -> None:
629
630
630
631
Raises
631
632
------
632
- GMTInvalidInput
633
+ GMTTypeError
633
634
If the ``args`` argument is not a string or a list of strings.
634
635
GMTCLibError
635
636
If the returned status code of the function is non-zero.
@@ -658,8 +659,10 @@ def call_module(self, module: str, args: str | list[str]) -> None:
658
659
mode = self ["GMT_MODULE_CMD" ]
659
660
argv = args .encode ()
660
661
else :
661
- msg = "'args' must either be a list of strings (recommended) or a string."
662
- raise GMTInvalidInput (msg )
662
+ raise GMTTypeError (
663
+ type (args ),
664
+ reason = "Parameter 'args' must either be a list of strings (recommended) or a string." ,
665
+ )
663
666
664
667
status = c_call_module (self .session_pointer , module .encode (), mode , argv )
665
668
if status != 0 :
@@ -913,9 +916,8 @@ def _check_dtype_and_dim(self, array: np.ndarray, ndim: int) -> int:
913
916
914
917
Raises
915
918
------
916
- GMTInvalidInput
917
- If the array has the wrong number of dimensions or is an unsupported data
918
- type.
919
+ GMTTypeError
920
+ If the array is an unsupported data type.
919
921
920
922
Examples
921
923
--------
@@ -939,8 +941,7 @@ def _check_dtype_and_dim(self, array: np.ndarray, ndim: int) -> int:
939
941
# 1-D arrays can be numeric or text, 2-D arrays can only be numeric.
940
942
valid_dtypes = DTYPES if ndim == 1 else DTYPES_NUMERIC
941
943
if (dtype := array .dtype .type ) not in valid_dtypes :
942
- msg = f"Unsupported numpy data type '{ dtype } '."
943
- raise GMTInvalidInput (msg )
944
+ raise GMTTypeError (dtype )
944
945
return self [DTYPES [dtype ]]
945
946
946
947
def put_vector (
@@ -1867,8 +1868,9 @@ def virtualfile_in( # noqa: PLR0912
1867
1868
elif check_kind == "vector" :
1868
1869
valid_kinds += ("empty" , "matrix" , "vectors" , "geojson" )
1869
1870
if kind not in valid_kinds :
1870
- msg = f"Unrecognized data type for { check_kind } : { type (data )} ."
1871
- raise GMTInvalidInput (msg )
1871
+ raise GMTTypeError (
1872
+ type (data ), reason = "Unrecognized for {check_kind!r} kind."
1873
+ )
1872
1874
1873
1875
# Decide which virtualfile_from_ function to use
1874
1876
_virtualfile_from = {
0 commit comments