Skip to content

Commit c14067d

Browse files
Fix the error message in the _check_dtype_and_dim function (#2297)
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
1 parent dcee301 commit c14067d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

pygmt/clib/session.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -677,15 +677,15 @@ def _parse_constant(self, constant, valid, valid_modifiers=None):
677677

678678
def _check_dtype_and_dim(self, array, ndim):
679679
"""
680-
Check that a numpy array has the given dimensions and is a valid data
681-
type.
680+
Check that a numpy array has the given number of dimensions and is a
681+
valid data type.
682682
683683
Parameters
684684
----------
685-
array : numpy array
685+
array : numpy.ndarray
686686
The array to be tested.
687687
ndim : int
688-
The desired dimension of the array.
688+
The desired number of array dimensions.
689689
690690
Returns
691691
-------
@@ -694,9 +694,9 @@ def _check_dtype_and_dim(self, array, ndim):
694694
695695
Raises
696696
------
697-
GMTCLibError
698-
If the array has the wrong dimensions or is an unsupported data
699-
type.
697+
GMTInvalidInput
698+
If the array has the wrong number of dimensions or
699+
is an unsupported data type.
700700
701701
Examples
702702
--------
@@ -715,11 +715,13 @@ def _check_dtype_and_dim(self, array, ndim):
715715
...
716716
True
717717
"""
718-
# check the array has the given dimension
718+
# Check that the array has the given number of dimensions
719719
if array.ndim != ndim:
720-
raise GMTInvalidInput(f"Expected a numpy 1-D array, got {array.ndim}-D.")
720+
raise GMTInvalidInput(
721+
f"Expected a numpy {ndim}-D array, got {array.ndim}-D."
722+
)
721723

722-
# check the array has a valid/known data type
724+
# Check that the array has a valid/known data type
723725
if array.dtype.type not in DTYPES:
724726
try:
725727
# Try to convert any unknown numpy data types to np.datetime64

0 commit comments

Comments
 (0)