-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Lint] Pylint #330
[Lint] Pylint #330
Conversation
@ylfdq1118 and @BarclayII could you have a look at the changes in frame.py? Other changes are mainly style fixes. |
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.
The changes look good.
slc = idx.slice_data() | ||
part1 = F.narrow_row(self.data, 0, slc.start) | ||
part2 = feats | ||
part3 = F.narrow_row(self.data, slc.stop, len(self)) |
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.
Not sure if this works for mxnet...
For mxnet, F.narrow_row is
def narrow_row(data, start, stop):
return nd.slice(data, begin=start, end=stop)
If start = stop = 0, it would return the whole ndarray instead of an empty one. And if start = stop = len(self), it would throw out exception.
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.
Yeah I noticed that as well. In fact this problem exists in the old code as well. I fixed it on my unified test branch but maybe you can fix that as well and I merge later?
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.
@BarclayII I will leave it to you.
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.
Also, is this a problem of MX or ours?
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.
My feeling is this is a problem with MX. And actually, MXNet's behavior looks weird to me. For nd.slice
, as long as begin=end
, nd.slice
will return a tensor with the same shape of the original tensor.
For example, if we have a=nd.normal(shape=(10, 5))
, then nd.slice(a, begin=0, end=0)
will return a
, but nd.slice(a, begin=2, end=2)
will start slicing from the 2nd row and takes out 10 rows, which goes out boundary without any errors. So the last two rows of return tensor has random values... And if argument begin
goes out of range, e.g. begin=10
, it throws out exception.
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.
But if we use data[start:stop]
instead of nd.slice
then the begin == end
case works correctly though. Also fixed that in my branch.
@zheng-da
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.
Raise an issue in mx? @zheng-da please help in tracking it.
Description
This PR enables pylint check for our python codes. Related to #290 .
Checklist
Please feel free to remove inapplicable items for your PR.
or have been fixed to be compatible with this change
Changes
utils.Index
now supports slice data. @BarclayII is there any model using slice on the frame?Following codes are not enabled for lint check.
dgl.backend
: TBD.dgl.contrib
: @zheng-da could you help?dgl.data
: need help from the owner.dgl.nn
: this is likely to be changed in the future.One could check the lint results offline by (requires cpplint and pylint):
We also need to put this in a developer guide in our doc.