Skip to content

Commit ae61783

Browse files
committed
move test location, add some TYPE_CHECKING_INVALID_USAGE
1 parent 98d35d7 commit ae61783

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

tests/frame/test_frame.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3959,26 +3959,3 @@ def test_frame_index_setter() -> None:
39593959
check(assert_type(df.index, pd.Index), pd.Index)
39603960
df.index = [2, 3]
39613961
check(assert_type(df.index, pd.Index), pd.Index)
3962-
3963-
3964-
def test_frame_at() -> None:
3965-
df = pd.DataFrame(data={"col1": [1.6, 2], "col2": [3, 4]})
3966-
3967-
check(assert_type(df.at[0, "col1"], Scalar), float)
3968-
df.at[0, "col1"] = 999
3969-
df.at[0, "col1"] = float("nan")
3970-
3971-
mi = pd.MultiIndex.from_arrays([[2, 3], [4, 5]])
3972-
df = pd.DataFrame(data={"col1": [1.6, 2], "col2": [3, 4]}, index=mi)
3973-
3974-
check(assert_type(df.at[(2, 4), "col1"], Scalar), float)
3975-
df.at[(2, 4), "col1"] = 999
3976-
df.at[(2, 4), "col1"] = float("nan")
3977-
3978-
3979-
def test_frame_iat() -> None:
3980-
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
3981-
3982-
check(assert_type(df.iat[0, 0], Scalar), np.integer)
3983-
df.iat[0, 0] = 999
3984-
df.iat[0, 0] = float("nan")

tests/frame/test_indexing.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626

2727
from pandas._typing import Scalar
2828

29-
from tests import check
29+
from tests import (
30+
TYPE_CHECKING_INVALID_USAGE,
31+
check,
32+
)
3033

3134

3235
def test_types_getitem() -> None:
@@ -592,3 +595,28 @@ def test_frame_ndarray_assignmment() -> None:
592595

593596
df_b = pd.DataFrame({"a": [0.0] * 10, "b": [1.0] * 10})
594597
df_b.iloc[:, :] = np.array([[-1.0, np.inf]] * 10)
598+
599+
600+
def test_frame_at() -> None:
601+
df = pd.DataFrame(data={"col1": [1.6, 2], "col2": [3, 4]})
602+
603+
check(assert_type(df.at[0, "col1"], Scalar), float)
604+
df.at[0, "col1"] = 999
605+
df.at[0, "col1"] = float("nan")
606+
607+
mi = pd.MultiIndex.from_arrays([[2, 3], [4, 5]])
608+
df = pd.DataFrame(data={"col1": [1.6, 2], "col2": [3, 4]}, index=mi)
609+
610+
check(assert_type(df.at[(2, 4), "col1"], Scalar), float)
611+
df.at[(2, 4), "col1"] = 999
612+
df.at[(2, 4), "col1"] = float("nan")
613+
614+
615+
def test_frame_iat() -> None:
616+
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
617+
618+
check(assert_type(df.iat[0, 0], Scalar), np.integer)
619+
df.iat[0, 0] = 999
620+
df.iat[0, 0] = float("nan")
621+
if TYPE_CHECKING_INVALID_USAGE:
622+
df.iat[(0,), 0] = 999 # type: ignore[index] # pyright: ignore[reportArgumentType]

tests/series/test_indexing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from tests import (
1010
PD_LTE_23,
11+
TYPE_CHECKING_INVALID_USAGE,
1112
check,
1213
pytest_warns_bounded,
1314
)
@@ -36,6 +37,9 @@ def test_types_iloc_iat() -> None:
3637
s2.iat[0]
3738
s2.iat[0] = None
3839

40+
if TYPE_CHECKING_INVALID_USAGE:
41+
s.iat[0, 0] # type: ignore[index] # pyright: ignore[reportArgumentType]
42+
3943

4044
def test_types_loc_at() -> None:
4145
s = pd.Series(data={"row1": 1, "row2": 2})

0 commit comments

Comments
 (0)