-
Notifications
You must be signed in to change notification settings - Fork 323
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
Add Type Annotations to pl_bolts/utils/* #455
Add Type Annotations to pl_bolts/utils/* #455
Conversation
Codecov Report
@@ Coverage Diff @@
## master #455 +/- ##
===========================================
- Coverage 80.91% 25.07% -55.85%
===========================================
Files 101 101
Lines 5676 5671 -5
===========================================
- Hits 4593 1422 -3171
- Misses 1083 4249 +3166
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@akihironitta, need help with the below two errors. I am not sure how to fix them.
|
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.
@hassiahk Thank you for your contribution! I left some comments on the changes. Could you have a look? As for your comment below, I'll look into it later...
@akihironitta, need help with the below two errors. I am not sure how to fix them.
Cannot access "__init__" directly
Module has no attribute "_empty"
@akihironitta, I took care of your requested changes but I also had to change
Another workaround would be to annotate |
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.
@hassiahk Thank you very much for your work!
For Module has no attribute "_empty"
, let's replace inspect._empty
with inspect.Parameter.empty
because both should be equivalent which is defined in inspect
. The same issue was also discussed in allenai/allennlp#1191 (comment).
For Cannot access "__init__" directly
, I couldn't find any existing solution, so shall we just skip the line with # type: ignore
...?
@akihironitta, made requested changes. Kindly review it once again. Annotated |
def balance_classes( | ||
X: Union[Tensor, np.ndarray], | ||
Y: Union[Tensor, np.ndarray, Sequence[int]], |
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'm still concerned about if the annotated types include all the possibility, but I think these are fine for now.
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 will use this balance_classes
and see if we can use other types as well.
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.
@hassiahk Thank you for your work! LGTM :]
pl_bolts/utils/semi_supervised.py
Outdated
final_batches_x: List[Any] = [[] for i in range(nb_batches)] | ||
final_batches_y: List[Any] = [[] for i in range(nb_batches)] |
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.
Since these variables are the output of the function, I think they should match with the return type of the function balance_classes()
:
) -> Tuple[np.ndarray, np.ndarray]:
but in order to do that, you might need to change/define other variables, too. We can tighten these types later in another PR, but it'd be nice to do it in this PR. Do you think you can improve typing here?
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.
Sure, I will see what I can do. :)
What does this PR do?
Part of #434. This PR adds type annotations to
pl_bolts.utils.*
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃