Skip to content

Commit 3100302

Browse files
authored
BREAKING: Raise GMTValueError if input arrays don't have the same size (#4377)
1 parent 6a580bf commit 3100302

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

pygmt/clib/session.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from pygmt.exceptions import (
2828
GMTCLibError,
2929
GMTCLibNoSessionError,
30-
GMTInvalidInput,
3130
GMTTypeError,
3231
GMTValueError,
3332
)
@@ -1465,8 +1464,7 @@ def virtualfile_from_vectors(self, vectors: Sequence) -> Generator[str, None, No
14651464

14661465
rows = len(arrays[0])
14671466
if not all(len(i) == rows for i in arrays):
1468-
msg = "All arrays must have same size."
1469-
raise GMTInvalidInput(msg)
1467+
raise GMTValueError(arrays, reason="All arrays must have same size.")
14701468

14711469
family = "GMT_IS_DATASET|GMT_VIA_VECTOR"
14721470
geometry = "GMT_IS_POINT"

pygmt/tests/test_clib_virtualfile_from_vectors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010
from pygmt import clib
1111
from pygmt.clib.session import DTYPES_NUMERIC
12-
from pygmt.exceptions import GMTInvalidInput
12+
from pygmt.exceptions import GMTValueError
1313
from pygmt.helpers import GMTTempFile
1414
from pygmt.helpers.testing import skip_if_no
1515

@@ -141,7 +141,7 @@ def test_virtualfile_from_vectors_diff_size():
141141
x = np.arange(5)
142142
y = np.arange(6)
143143
with clib.Session() as lib:
144-
with pytest.raises(GMTInvalidInput):
144+
with pytest.raises(GMTValueError):
145145
with lib.virtualfile_from_vectors((x, y)):
146146
pass
147147

0 commit comments

Comments
 (0)