From fccedae79ab73fdbf9ca617ac2d09dc7f73970e8 Mon Sep 17 00:00:00 2001 From: Wei Ji Date: Tue, 14 Jul 2020 14:43:33 +1200 Subject: [PATCH] Try using GMT_TEXT for numpy string types --- pygmt/clib/session.py | 5 +++-- pygmt/tests/test_clib_put.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index 4571d2db9e6..2ab82623b23 100644 --- a/pygmt/clib/session.py +++ b/pygmt/clib/session.py @@ -56,6 +56,7 @@ np.uint64: "GMT_ULONG", np.uint32: "GMT_UINT", np.datetime64: "GMT_DATETIME", + np.str_: "GMT_TEXT", } @@ -235,7 +236,7 @@ def __getitem__(self, name): value = c_get_enum(session, name.encode()) if value is None or value == -99999: - raise GMTCLibError("Constant '{}' doesn't exits in libgmt.".format(name)) + raise GMTCLibError(f"Constant '{name}' doesn't exist in libgmt.") return value @@ -827,7 +828,7 @@ def put_strings(self, dataset, column, strings): """ c_put_strings = self.get_libgmt_func( "GMT_Put_Strings", - argtypes=[ctp.c_void_p, ctp.c_uint, ctp.c_void_p, ctp.c_wchar_p], + argtypes=[ctp.c_void_p, ctp.c_uint, ctp.c_void_p, ctp.c_uint], restype=ctp.c_int, ) diff --git a/pygmt/tests/test_clib_put.py b/pygmt/tests/test_clib_put.py index d2a2268d1b6..07642b7e980 100644 --- a/pygmt/tests/test_clib_put.py +++ b/pygmt/tests/test_clib_put.py @@ -21,7 +21,7 @@ def test_put_strings(): dim=[1, 5, 1, 0], # columns, rows, layers, dtype ) s = np.array(["a", "b", "c", "d", "e"], dtype=np.str) - lib.put_strings(dataset, column=lib["GMT_S"], strings=s) + lib.put_strings(dataset, column=lib["GMT_TEXT"], strings=s) # Turns out wesn doesn't matter for Datasets wesn = [0] * 6 # Save the data to a file to see if it's being accessed correctly