|
18 | 18 | import pandas as pd |
19 | 19 | import xarray as xr |
20 | 20 | from pygmt.clib.conversion import ( |
21 | | - array_to_datetime, |
22 | 21 | dataarray_to_matrix, |
23 | 22 | sequence_to_ctypes_array, |
24 | 23 | strings_to_ctypes_array, |
@@ -854,22 +853,13 @@ def _check_dtype_and_dim(self, array, ndim): |
854 | 853 | """ |
855 | 854 | # Check that the array has the given number of dimensions |
856 | 855 | if array.ndim != ndim: |
857 | | - raise GMTInvalidInput( |
858 | | - f"Expected a numpy {ndim}-D array, got {array.ndim}-D." |
859 | | - ) |
| 856 | + msg = f"Expected a numpy {ndim}-D array, got {array.ndim}-D." |
| 857 | + raise GMTInvalidInput(msg) |
860 | 858 |
|
861 | 859 | # Check that the array has a valid/known data type |
862 | 860 | if array.dtype.type not in DTYPES: |
863 | | - try: |
864 | | - if array.dtype.type is np.object_: |
865 | | - # Try to convert unknown object type to np.datetime64 |
866 | | - array = array_to_datetime(array) |
867 | | - else: |
868 | | - raise ValueError |
869 | | - except ValueError as e: |
870 | | - raise GMTInvalidInput( |
871 | | - f"Unsupported numpy data type '{array.dtype.type}'." |
872 | | - ) from e |
| 861 | + msg = f"Unsupported numpy data type '{array.dtype.type}'." |
| 862 | + raise GMTInvalidInput(msg) |
873 | 863 | return self[DTYPES[array.dtype.type]] |
874 | 864 |
|
875 | 865 | def put_vector(self, dataset, column, vector): |
@@ -917,7 +907,7 @@ def put_vector(self, dataset, column, vector): |
917 | 907 | gmt_type = self._check_dtype_and_dim(vector, ndim=1) |
918 | 908 | if gmt_type in {self["GMT_TEXT"], self["GMT_DATETIME"]}: |
919 | 909 | if gmt_type == self["GMT_DATETIME"]: |
920 | | - vector = np.datetime_as_string(array_to_datetime(vector)) |
| 910 | + vector = np.datetime_as_string(vector) |
921 | 911 | vector_pointer = strings_to_ctypes_array(vector) |
922 | 912 | else: |
923 | 913 | vector_pointer = vector.ctypes.data_as(ctp.c_void_p) |
|
0 commit comments