@@ -1723,7 +1723,7 @@ def form_blocks(arrays, names: Index, axes) -> List[Block]:
1723
1723
return blocks
1724
1724
1725
1725
1726
- def _simple_blockify (tuples , dtype ):
1726
+ def _simple_blockify (tuples , dtype ) -> List [ Block ] :
1727
1727
"""
1728
1728
return a single array of a block that has a single dtype; if dtype is
1729
1729
not None, coerce to this dtype
@@ -1846,7 +1846,7 @@ def _merge_blocks(
1846
1846
1847
1847
1848
1848
def _compare_or_regex_search (
1849
- a : Union [ ArrayLike , Scalar ], b : Union [ ArrayLike , Scalar ] , regex : bool = False
1849
+ a : ArrayLike , b : Scalar , regex : bool = False
1850
1850
) -> Union [ArrayLike , bool ]:
1851
1851
"""
1852
1852
Compare two array_like inputs of the same shape or two scalar values
@@ -1856,8 +1856,8 @@ def _compare_or_regex_search(
1856
1856
1857
1857
Parameters
1858
1858
----------
1859
- a : array_like or scalar
1860
- b : array_like or scalar
1859
+ a : array_like
1860
+ b : scalar
1861
1861
regex : bool, default False
1862
1862
1863
1863
Returns
@@ -1866,29 +1866,21 @@ def _compare_or_regex_search(
1866
1866
"""
1867
1867
1868
1868
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
+ ):
1873
1871
"""
1874
1872
Raises an error if the two arrays (a,b) cannot be compared.
1875
1873
Otherwise, returns the comparison result as expected.
1876
1874
"""
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 ):
1880
1876
type_names = [type (a ).__name__ , type (b ).__name__ ]
1881
1877
1882
1878
if isinstance (a , np .ndarray ):
1883
1879
type_names [0 ] = f"ndarray(dtype={ a .dtype } )"
1884
1880
1885
- if isinstance (b , np .ndarray ):
1886
- type_names [1 ] = f"ndarray(dtype={ b .dtype } )"
1887
-
1888
1881
raise TypeError (
1889
1882
f"Cannot compare types { repr (type_names [0 ])} and { repr (type_names [1 ])} "
1890
1883
)
1891
- return result
1892
1884
1893
1885
if not regex :
1894
1886
op = lambda x : operator .eq (x , b )
@@ -1902,18 +1894,13 @@ def _check_comparison_types(
1902
1894
# GH#32621 use mask to avoid comparing to NAs
1903
1895
if isinstance (a , np .ndarray ) and not isinstance (b , np .ndarray ):
1904
1896
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 ))
1909
1897
if isinstance (a , np .ndarray ):
1910
1898
a = a [mask ]
1911
- if isinstance (b , np .ndarray ):
1912
- b = b [mask ]
1913
1899
1914
1900
if is_datetimelike_v_numeric (a , b ) or is_numeric_v_string_like (a , b ):
1915
1901
# 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
1917
1904
1918
1905
result = op (a )
1919
1906
@@ -1924,7 +1911,8 @@ def _check_comparison_types(
1924
1911
tmp [mask ] = result
1925
1912
result = tmp
1926
1913
1927
- return _check_comparison_types (result , a , b )
1914
+ _check_comparison_types (result , a , b )
1915
+ return result
1928
1916
1929
1917
1930
1918
def _fast_count_smallints (arr : np .ndarray ) -> np .ndarray :
0 commit comments