-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: DataFrame.(dot, __matmul__) #38765
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1157,6 +1157,14 @@ def __len__(self) -> int: | |
""" | ||
return len(self.index) | ||
|
||
@overload | ||
def dot(self, other: Series) -> Series: | ||
... | ||
|
||
@overload | ||
def dot(self, other: Union[DataFrame, Index, ArrayLike]) -> Optional[DataFrame]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the return Optional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a (likely misguided) attempt to please mypy. There's no return statement after the raise at the end so technically returns None, although ofc we never get there (I'm honestly not sure why what I have, without the optional return, isn't working - I think it should be right) |
||
... | ||
|
||
def dot(self, other): | ||
""" | ||
Compute the matrix multiplication between the DataFrame and other. | ||
|
@@ -1267,6 +1275,16 @@ def dot(self, other): | |
else: # pragma: no cover | ||
raise TypeError(f"unsupported type: {type(other)}") | ||
|
||
@overload | ||
def __matmul__(self, other: Series) -> Series: | ||
... | ||
|
||
@overload | ||
def __matmul__( | ||
self, other: Union[DataFrame, Index, ArrayLike] | ||
) -> Optional[DataFrame]: | ||
... | ||
|
||
def __matmul__(self, other): | ||
""" | ||
Matrix multiplication using binary `@` operator in Python>=3.5. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this ignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see your comment, can you make this the actual type error as a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done