|
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:
|
@@ -915,7 +918,7 @@ def _check_dtype_and_dim(self, array: np.ndarray, ndim: int) -> int:
|
915 | 918 | ------
|
916 | 919 | GMTValueError
|
917 | 920 | If the array has the wrong number of dimensions.
|
918 |
| - GMTInvalidInput |
| 921 | + GMTTypeError |
919 | 922 | If the array is an unsupported data type.
|
920 | 923 |
|
921 | 924 | Examples
|
@@ -943,8 +946,7 @@ def _check_dtype_and_dim(self, array: np.ndarray, ndim: int) -> int:
|
943 | 946 | # 1-D arrays can be numeric or text, 2-D arrays can only be numeric.
|
944 | 947 | valid_dtypes = DTYPES if ndim == 1 else DTYPES_NUMERIC
|
945 | 948 | if (dtype := array.dtype.type) not in valid_dtypes:
|
946 |
| - msg = f"Unsupported numpy data type '{dtype}'." |
947 |
| - raise GMTInvalidInput(msg) |
| 949 | + raise GMTTypeError(dtype) |
948 | 950 | return self[DTYPES[dtype]]
|
949 | 951 |
|
950 | 952 | def put_vector(
|
@@ -1871,8 +1873,10 @@ def virtualfile_in( # noqa: PLR0912
|
1871 | 1873 | elif check_kind == "vector":
|
1872 | 1874 | valid_kinds += ("empty", "matrix", "vectors", "geojson")
|
1873 | 1875 | if kind not in valid_kinds:
|
1874 |
| - msg = f"Unrecognized data type for {check_kind}: {type(data)}." |
1875 |
| - raise GMTInvalidInput(msg) |
| 1876 | + raise GMTTypeError( |
| 1877 | + type(data), |
| 1878 | + reason=f"Unrecognized data type for {check_kind!r} kind.", |
| 1879 | + ) |
1876 | 1880 |
|
1877 | 1881 | # Decide which virtualfile_from_ function to use
|
1878 | 1882 | _virtualfile_from = {
|
|
0 commit comments