@@ -1866,7 +1866,7 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1866
1866
return element
1867
1867
raise LossySetitemError
1868
1868
1869
- elif is_integer (element ) or (is_float (element ) and element .is_integer ()):
1869
+ if is_integer (element ) or (is_float (element ) and element .is_integer ()):
1870
1870
# e.g. test_setitem_series_int8 if we have a python int 1
1871
1871
# tipo may be np.int32, despite the fact that it will fit
1872
1872
# in smaller int dtypes.
@@ -1893,7 +1893,7 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1893
1893
1894
1894
# Anything other than integer we cannot hold
1895
1895
raise LossySetitemError
1896
- elif (
1896
+ if (
1897
1897
dtype .kind == "u"
1898
1898
and isinstance (element , np .ndarray )
1899
1899
and element .dtype .kind == "i"
@@ -1905,9 +1905,9 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1905
1905
# itemsize issues there?
1906
1906
return casted
1907
1907
raise LossySetitemError
1908
- elif dtype .itemsize < tipo .itemsize :
1908
+ if dtype .itemsize < tipo .itemsize :
1909
1909
raise LossySetitemError
1910
- elif not isinstance (tipo , np .dtype ):
1910
+ if not isinstance (tipo , np .dtype ):
1911
1911
# i.e. nullable IntegerDtype; we can put this into an ndarray
1912
1912
# losslessly iff it has no NAs
1913
1913
if element ._hasna :
@@ -1918,7 +1918,7 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1918
1918
1919
1919
raise LossySetitemError
1920
1920
1921
- elif dtype .kind == "f" :
1921
+ if dtype .kind == "f" :
1922
1922
if lib .is_integer (element ) or lib .is_float (element ):
1923
1923
casted = dtype .type (element )
1924
1924
if np .isnan (casted ) or casted == element :
@@ -1931,7 +1931,7 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1931
1931
if tipo .kind not in ["f" , "i" , "u" ]:
1932
1932
# Anything other than float/integer we cannot hold
1933
1933
raise LossySetitemError
1934
- elif not isinstance (tipo , np .dtype ):
1934
+ if not isinstance (tipo , np .dtype ):
1935
1935
# i.e. nullable IntegerDtype or FloatingDtype;
1936
1936
# we can put this into an ndarray losslessly iff it has no NAs
1937
1937
if element ._hasna :
@@ -1950,7 +1950,7 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1950
1950
1951
1951
raise LossySetitemError
1952
1952
1953
- elif dtype .kind == "c" :
1953
+ if dtype .kind == "c" :
1954
1954
if lib .is_integer (element ) or lib .is_complex (element ) or lib .is_float (element ):
1955
1955
if np .isnan (element ):
1956
1956
# see test_where_complex GH#6345
@@ -1968,7 +1968,7 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1968
1968
raise LossySetitemError
1969
1969
raise LossySetitemError
1970
1970
1971
- elif dtype .kind == "b" :
1971
+ if dtype .kind == "b" :
1972
1972
if tipo is not None :
1973
1973
if tipo .kind == "b" :
1974
1974
if not isinstance (tipo , np .dtype ):
@@ -1982,7 +1982,7 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
1982
1982
return element
1983
1983
raise LossySetitemError
1984
1984
1985
- elif dtype .kind == "S" :
1985
+ if dtype .kind == "S" :
1986
1986
# TODO: test tests.frame.methods.test_replace tests get here,
1987
1987
# need more targeted tests. xref phofl has a PR about this
1988
1988
if tipo is not None :
0 commit comments