pygmt.exceptions.GMTValueError

exception pygmt.exceptions.GMTValueError(value, /, description='value', choices=None, reason=None)[source]

Raised when an invalid value is passed to a function/method.

Parameters:
  • value (Any) – The invalid value.

  • description (str, default: 'value') – The description of the value.

  • choices (Iterable[Any] | None, default: None) – The valid choices for the value.

  • reason (str | None, default: None) – The detailed reason why the value is invalid.

Examples

>>> raise GMTValueError("invalid")
Traceback (most recent call last):
    ...
pygmt.exceptions.GMTValueError: Invalid value: 'invalid'.
>>> raise GMTValueError("invalid", description="constant name")
Traceback (most recent call last):
...
pygmt.exceptions.GMTValueError: Invalid constant name: 'invalid'.
>>> raise GMTValueError("invalid", choices=["a", "b", 1, 2])
Traceback (most recent call last):
    ...
pygmt.exceptions.GMTValueError: Invalid value: 'invalid'. Expected one of: 'a', 'b', 1, 2.
>>> raise GMTValueError("invalid", choices=["a", 0, True, False, None])
Traceback (most recent call last):
    ...
pygmt.exceptions.GMTValueError: Invalid value: 'invalid'. Expected one of: 'a', 0, True, False, None.
>>> from pygmt.enums import GridType
>>> raise GMTValueError("invalid", choices=GridType)
Traceback (most recent call last):
    ...
pygmt.exceptions.GMTValueError: Invalid value: 'invalid'. Expected one of: <GridType.CARTESIAN: 0>, <GridType.GEOGRAPHIC: 1>.
>>> raise GMTValueError("invalid", reason="Explain why it's invalid.")
Traceback (most recent call last):
    ...
pygmt.exceptions.GMTValueError: Invalid value: 'invalid'. Explain why it's invalid.