Skip to content

Commit

Permalink
Try using GMT_TEXT for numpy string types
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Jul 14, 2020
1 parent d7c3053 commit fccedae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
np.uint64: "GMT_ULONG",
np.uint32: "GMT_UINT",
np.datetime64: "GMT_DATETIME",
np.str_: "GMT_TEXT",
}


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
)

Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_clib_put.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fccedae

Please sign in to comment.