Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH1089 Migrate frame/series tests to new framework #1093

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
GH1089 PR Feedback
loicdiridollou committed Jan 14, 2025
commit b8331c8d984e18ef47326f0e6f8614f69d1b3627
6 changes: 2 additions & 4 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
@@ -2453,8 +2453,7 @@ def test_sum_get_add() -> None:
def test_getset_untyped() -> None:
df = pd.DataFrame({"x": [1, 2, 3, 4, 5], "y": [10, 20, 30, 40, 50]})
# Tests that Dataframe.__getitem__ needs to return untyped series.
# TODO this typecheck is actually bogus as the right part is "Unknown"
result: pd.Series = df["x"].max()
check(assert_type(df["x"].max(), Any), np.integer)


def test_getmultiindex_columns() -> None:
@@ -2965,8 +2964,7 @@ def sum_mean(x: pd.DataFrame) -> float:
pd.Series,
)

def lfunc(x: pd.DataFrame) -> float:
return x.sum().mean()
lfunc: Callable[[pd.DataFrame], float] = lambda x: x.sum().mean()

with pytest_warns_bounded(
DeprecationWarning,
12 changes: 7 additions & 5 deletions tests/test_series.py
Original file line number Diff line number Diff line change
@@ -312,7 +312,7 @@ def test_types_drop_multilevel() -> None:
check(
assert_type(s.drop(labels="first", level=1), "pd.Series[int]"),
pd.Series,
np.int64,
np.integer,
)


@@ -389,7 +389,7 @@ def test_types_sort_index_with_key() -> None:
check(
assert_type(s.sort_index(key=lambda k: k.str.lower()), "pd.Series[int]"),
pd.Series,
np.int64,
np.integer,
)


@@ -1147,8 +1147,10 @@ def test_types_getitem() -> None:
s = pd.Series({"key": [0, 1, 2, 3]})
key: list[int] = s["key"]
s2 = pd.Series([0, 1, 2, 3])
check(assert_type(s[0], Any), np.integer)
check(assert_type(s2[0], int), np.integer)
check(assert_type(s[:2], pd.Series), pd.Series)
check(assert_type(s2[:2], "pd.Series[int]"), pd.Series, np.integer)


def test_types_getitem_by_timestamp() -> None:
@@ -1306,9 +1308,9 @@ def test_types_dot() -> None:
s2 = pd.Series([-1, 2, -3, 4])
df1 = pd.DataFrame([[0, 1], [-2, 3], [4, -5], [6, 7]])
n1 = np.array([[0, 1], [1, 2], [-1, -1], [2, 0]])
check(assert_type(s1.dot(s2), Scalar), np.int64)
check(assert_type(s1 @ s2, Scalar), np.int64)
check(assert_type(s1.dot(df1), "pd.Series[int]"), pd.Series, np.int64)
check(assert_type(s1.dot(s2), Scalar), np.integer)
check(assert_type(s1 @ s2, Scalar), np.integer)
check(assert_type(s1.dot(df1), "pd.Series[int]"), pd.Series, np.integer)
check(assert_type(s1 @ df1, pd.Series), pd.Series)
check(assert_type(s1.dot(n1), np.ndarray), np.ndarray)
check(assert_type(s1 @ n1, np.ndarray), np.ndarray)