diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index ffe675e1bc4..8db686812c1 100644 --- a/pygmt/clib/session.py +++ b/pygmt/clib/session.py @@ -1291,9 +1291,7 @@ def virtualfile_from_vectors(self, *vectors): if len(string_arrays) == 1: strings = string_arrays[0] elif len(string_arrays) > 1: - strings = np.apply_along_axis( - func1d=" ".join, axis=0, arr=string_arrays - ) + strings = np.array([" ".join(vals) for vals in zip(*string_arrays)]) strings = np.asanyarray(a=strings, dtype=str) self.put_strings( dataset, family="GMT_IS_VECTOR|GMT_IS_DUPLICATE", strings=strings diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index 38a77f5f064..9f2c73857cd 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -556,7 +556,8 @@ def test_virtualfile_from_vectors_two_string_or_object_columns(dtype): size = 5 x = np.arange(size, dtype=np.int32) y = np.arange(size, size * 2, 1, dtype=np.int32) - strings1 = np.array(["a", "bc", "def", "ghij", "klmno"], dtype=dtype) + # Catch bug in https://github.com/GenericMappingTools/pygmt/pull/2719 + strings1 = np.array(["a", "bc", "def", "ghij", "klmnolooong"], dtype=dtype) strings2 = np.array(["pqrst", "uvwx", "yz!", "@#", "$"], dtype=dtype) with clib.Session() as lib: with lib.virtualfile_from_vectors(x, y, strings1, strings2) as vfile: