Skip to content

Commit 03bb52f

Browse files
committed
review comments
1 parent afc2ea6 commit 03bb52f

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

asv_bench/benchmarks/dtypes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
numeric_dtypes, datetime_dtypes, string_dtypes, extension_dtypes)
66

77

8-
_numpy_dtypes = list(map(np.dtype, (numeric_dtypes +
9-
datetime_dtypes +
10-
string_dtypes)))
8+
_numpy_dtypes = [np.dtype(dtype)
9+
for dtype in (numeric_dtypes +
10+
datetime_dtypes +
11+
string_dtypes)]
1112
_dtypes = _numpy_dtypes + extension_dtypes
1213

1314

pandas/core/dtypes/common.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,11 +1719,11 @@ def is_complex_dtype(arr_or_dtype):
17191719

17201720
def _is_dtype(arr_or_dtype, condition):
17211721
"""
1722-
Return a boolean if the the condition is satisfied for the arr_or_dtype.
1722+
Return a boolean if the condition is satisfied for the arr_or_dtype.
17231723
17241724
Parameters
17251725
----------
1726-
arr_or_dtype : array-like
1726+
arr_or_dtype : array-like, str, np.dtype, or ExtensionArrayType
17271727
The array-like or dtype object whose dtype we want to extract.
17281728
condition : callable[Union[np.dtype, ExtensionDtype]]
17291729
@@ -1780,7 +1780,7 @@ def _get_dtype(arr_or_dtype):
17801780

17811781
def _is_dtype_type(arr_or_dtype, condition):
17821782
"""
1783-
Return a boolean if the the condition is satisfied for the arr_or_dtype.
1783+
Return a boolean if the condition is satisfied for the arr_or_dtype.
17841784
17851785
Parameters
17861786
----------
@@ -1790,15 +1790,16 @@ def _is_dtype_type(arr_or_dtype, condition):
17901790
17911791
Returns
17921792
-------
1793-
bool
1793+
bool : if the condition is satisifed for the arr_or_dtype
17941794
17951795
"""
17961796

17971797
if arr_or_dtype is None:
17981798
return condition(type(None))
17991799

18001800
# fastpath
1801-
if isinstance(arr_or_dtype, np.dtype):
1801+
if isinstance(arr_or_dtype, (
1802+
np.dtype, PandasExtensionDtype, ExtensionDtype)):
18021803
return condition(arr_or_dtype.type)
18031804
elif isinstance(arr_or_dtype, type):
18041805
return condition(np.dtype(arr_or_dtype).type)
@@ -1815,7 +1816,7 @@ def _is_dtype_type(arr_or_dtype, condition):
18151816

18161817
try:
18171818
tipo = pandas_dtype(arr_or_dtype).type
1818-
except (TypeError, ValueError, SyntaxError, UnicodeEncodeError):
1819+
except (TypeError, ValueError, UnicodeEncodeError):
18191820
if is_scalar(arr_or_dtype):
18201821
return condition(type(None))
18211822

0 commit comments

Comments
 (0)