@@ -1723,7 +1723,7 @@ def form_blocks(arrays, names: Index, axes) -> List[Block]:
17231723 return blocks
17241724
17251725
1726- def _simple_blockify (tuples , dtype ):
1726+ def _simple_blockify (tuples , dtype ) -> List [ Block ] :
17271727 """
17281728 return a single array of a block that has a single dtype; if dtype is
17291729 not None, coerce to this dtype
@@ -1846,7 +1846,7 @@ def _merge_blocks(
18461846
18471847
18481848def _compare_or_regex_search (
1849- a : Union [ ArrayLike , Scalar ], b : Union [ ArrayLike , Scalar ] , regex : bool = False
1849+ a : ArrayLike , b : Scalar , regex : bool = False
18501850) -> Union [ArrayLike , bool ]:
18511851 """
18521852 Compare two array_like inputs of the same shape or two scalar values
@@ -1856,8 +1856,8 @@ def _compare_or_regex_search(
18561856
18571857 Parameters
18581858 ----------
1859- a : array_like or scalar
1860- b : array_like or scalar
1859+ a : array_like
1860+ b : scalar
18611861 regex : bool, default False
18621862
18631863 Returns
@@ -1866,29 +1866,21 @@ def _compare_or_regex_search(
18661866 """
18671867
18681868 def _check_comparison_types (
1869- result : Union [ArrayLike , bool ],
1870- a : Union [ArrayLike , Scalar ],
1871- b : Union [ArrayLike , Scalar ],
1872- ) -> Union [ArrayLike , bool ]:
1869+ result : Union [ArrayLike , bool ], a : ArrayLike , b : Scalar ,
1870+ ):
18731871 """
18741872 Raises an error if the two arrays (a,b) cannot be compared.
18751873 Otherwise, returns the comparison result as expected.
18761874 """
1877- if is_scalar (result ) and (
1878- isinstance (a , np .ndarray ) or isinstance (b , np .ndarray )
1879- ):
1875+ if is_scalar (result ) and isinstance (a , np .ndarray ):
18801876 type_names = [type (a ).__name__ , type (b ).__name__ ]
18811877
18821878 if isinstance (a , np .ndarray ):
18831879 type_names [0 ] = f"ndarray(dtype={ a .dtype } )"
18841880
1885- if isinstance (b , np .ndarray ):
1886- type_names [1 ] = f"ndarray(dtype={ b .dtype } )"
1887-
18881881 raise TypeError (
18891882 f"Cannot compare types { repr (type_names [0 ])} and { repr (type_names [1 ])} "
18901883 )
1891- return result
18921884
18931885 if not regex :
18941886 op = lambda x : operator .eq (x , b )
@@ -1902,18 +1894,13 @@ def _check_comparison_types(
19021894 # GH#32621 use mask to avoid comparing to NAs
19031895 if isinstance (a , np .ndarray ) and not isinstance (b , np .ndarray ):
19041896 mask = np .reshape (~ (isna (a )), a .shape )
1905- elif isinstance (b , np .ndarray ) and not isinstance (a , np .ndarray ):
1906- mask = np .reshape (~ (isna (b )), b .shape )
1907- elif isinstance (a , np .ndarray ) and isinstance (b , np .ndarray ):
1908- mask = ~ (isna (a ) | isna (b ))
19091897 if isinstance (a , np .ndarray ):
19101898 a = a [mask ]
1911- if isinstance (b , np .ndarray ):
1912- b = b [mask ]
19131899
19141900 if is_datetimelike_v_numeric (a , b ) or is_numeric_v_string_like (a , b ):
19151901 # GH#29553 avoid deprecation warnings from numpy
1916- return _check_comparison_types (False , a , b )
1902+ _check_comparison_types (False , a , b )
1903+ return False
19171904
19181905 result = op (a )
19191906
@@ -1924,7 +1911,8 @@ def _check_comparison_types(
19241911 tmp [mask ] = result
19251912 result = tmp
19261913
1927- return _check_comparison_types (result , a , b )
1914+ _check_comparison_types (result , a , b )
1915+ return result
19281916
19291917
19301918def _fast_count_smallints (arr : np .ndarray ) -> np .ndarray :
0 commit comments