5656 np .uint64 : "GMT_ULONG" ,
5757 np .uint32 : "GMT_UINT" ,
5858 np .datetime64 : "GMT_DATETIME" ,
59- np .str_ : "GMT_TEXT" ,
6059}
6160
6261
@@ -792,15 +791,15 @@ def put_vector(self, dataset, column, vector):
792791 )
793792 )
794793
795- def put_strings (self , dataset , strings ):
794+ def put_strings (self , dataset , family , strings ):
796795 """
797796 Attach a numpy 1D array of dtype str as a column on a GMT dataset.
798797
799798 Use this function to attach string type numpy array data to a GMT
800799 dataset and pass it to GMT modules. Wraps ``GMT_Put_Strings``.
801800
802801 The dataset must be created by :meth:`~gmt.clib.Session.create_data`
803- first. Use ``family='GMT_IS_DATASET|GMT_VIA_VECTOR'``.
802+ first.
804803
805804 .. warning::
806805 The numpy array must be C contiguous in memory. If it comes from a
@@ -813,6 +812,9 @@ def put_strings(self, dataset, strings):
813812 dataset : :class:`ctypes.c_void_p`
814813 The ctypes void pointer to a ``GMT_Dataset``. Create it with
815814 :meth:`~gmt.clib.Session.create_data`.
815+ family : str
816+ The family type of the dataset. Can be either ``GMT_IS_VECTOR`` or
817+ ``GMT_IS_MATRIX``.
816818 strings : numpy 1d-array
817819 The array that will be attached to the dataset. Must be a 1d C
818820 contiguous array.
@@ -830,9 +832,10 @@ def put_strings(self, dataset, strings):
830832 restype = ctp .c_int ,
831833 )
832834
833- gmt_type = self ._check_dtype_and_dim (strings , ndim = 1 )
834- strings_pointer = strings .ctypes .data_as (ctp .c_void_p )
835- status = c_put_strings (self .session_pointer , dataset , gmt_type , strings_pointer )
835+ strings_pointer = strings .ctypes .data_as (ctp .c_char_p )
836+ status = c_put_strings (
837+ self .session_pointer , self [family ], dataset , strings_pointer
838+ )
836839 if status != 0 :
837840 raise GMTCLibError (
838841 f"Failed to put strings of type { strings .dtype } into dataset"
0 commit comments