-
Notifications
You must be signed in to change notification settings - Fork 53
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
转换规则 No.16/17/18 #142
转换规则 No.16/17/18 #142
Conversation
Thanks for your contribution! |
@Vooolta ,CI已全通过,本地测试pytest成功,麻烦有空的时候审核一下,谢谢! |
paconvert/api_matcher.py
Outdated
class SearchsortedMatcher(BaseMatcher): | ||
def generate_code(self, kwargs): | ||
|
||
if "side" in kwargs and kwargs["side"] is not None: |
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.
side应该不能传入None吧,只能是 'left' 和 'right'
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.
是的,经测试这里的kwargs
是用户给定的kwargs
, 即当用户没有显示设置side
参数时,'side' no in kwargs
是True的。
def test_case_1():
pytorch_code = textwrap.dedent(
"""
import torch
x = torch.tensor([[ 1, 3, 5, 7, 9],
[ 2, 4, 6, 8, 10]])
values = torch.tensor([[3, 6, 9],
[3, 6, 9]])
result = torch.searchsorted(x, values)
"""
)
obj.run(pytorch_code, ["result"])
如这里的测试案例1,kwargs = {'sorted_sequence':x, 'values':values}
。
我不太清楚我这样的理解正不正确?但是在去除kwargs['side']
的判断之后,test_case_1
会报KeyError: 'side'
的错误。
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.
这里应该不用判断None,只需判断if "side" in kwargs就行了
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.
好的
paconvert/api_matcher.py
Outdated
class SearchsortedMatcher(BaseMatcher): | ||
def generate_code(self, kwargs): | ||
|
||
if "side" in kwargs and kwargs["side"] is not None: |
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.
这里应该不用判断None,只需判断if "side" in kwargs就行了
Done |
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.
LGTM
PR Docs
PaddlePaddle/docs#5955
PR APIs