Skip to content

Commit 176f511

Browse files
committed
Use data.dtype.numpy_dtype
1 parent c3471cb commit 176f511

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pygmt/clib/conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def _to_numpy(data: Any) -> np.ndarray:
187187
if hasattr(data, "isna") and data.isna().any():
188188
# Integer dtypes with missing values are cast to NumPy float dtypes and NaN
189189
# is used as missing value indicator.
190-
dtype = np.float64 if data.dtype.kind in "iu" else data.dtype.type
190+
dtype = np.float64 if data.dtype.kind in "iu" else data.dtype.numpy_dtype
191191
data = data.to_numpy(dtype=dtype, na_value=np.nan)
192192

193193
vec_dtype = str(getattr(data, "dtype", ""))

pygmt/tests/test_clib_to_numpy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ def test_to_numpy_pandas_series_pandas_dtypes_numeric_with_na(dtype, supported):
199199
# Integer dtypes with missing values are cast to NumPy float64 dtype, and Float
200200
# dtypes with missing values are cast to NumPy float32/float64 dtype.
201201
# np.NaN is used as missing value indicator.
202-
expected_dtype = np.float64 if series.dtype.kind in "iu" else series.dtype.type
202+
expected_dtype = (
203+
np.float64 if series.dtype.kind in "iu" else series.dtype.numpy_dtype
204+
)
203205
npt.assert_array_equal(
204206
result, np.array([1.0, np.nan, 3.0], dtype=expected_dtype), strict=True
205207
)

0 commit comments

Comments
 (0)