-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Addition of a Series[int] with a complex returns Series[unknown] #1098
Comments
Need to update the various operators to handle arguments that are |
Also another issue about the s = pd.Series([0, 1, -10])
s2 = pd.Series([7, -5, 10])
check(assert_type(s - s2, "pd.Series[int]"), pd.Series, np.integer)
check(assert_type(s * s2, "pd.Series[int]"), pd.Series, np.integer)
check(assert_type(s / s2, "pd.Series[float]"), pd.Series, np.float64) |
s1 = pd.Series([0, 1, 2, 3])
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) # should be float here as we don't know the type of the df |
Hey @Dr-Irv & @loicdiridollou I fixed this for add but, for mul
we cannot expect check(assert_type(s * s2, "pd.Series[int]"), pd.Series, np.integer) to pass without a type error because, as shown in pandas-stubs/tests/test_series.py Line 620 in 7328e89
the test verifies that the square of a Series returns a float. If both operands are treated as integers, this type mismatch will trigger an assertion failure. |
No, you can't. The But if we have 2 Getting this to work right is a big challenge.. @loicdiridollou was making progress in #1093, but we also have to make sure that we get the correct results when the subtype of |
Please complete the following information:
OS: Darwin
OS Version [e.g. 22]: 15.2
python version: 3.12.7
version of type checker: mypy latest
version of installed pandas-stubs: latest
Additional context
version of pandas: 2.2.3
mypy option: strict=False
The text was updated successfully, but these errors were encountered: