Created
August 23, 2021 01:12
-
-
Save geniusnhu/6ee2711c65435b728a758b77c749ea84 to your computer and use it in GitHub Desktop.
Example of code annotation for a function and class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example of code annotation for a function | |
def your_function(X): | |
""" Explanation of what the function does | |
Parameters | |
---------- | |
X: dtype | |
explanation of X | |
y: dtype | |
explanation of y | |
Returns | |
------- | |
result: dtype | |
explanation of result | |
""" | |
X = y**2 | |
return X | |
# ============================================================================== | |
### Example of code annotation for a class and its parameter, attribute & method | |
class YourClass(): | |
""" Explanation of what the class does | |
Parameters | |
---------- | |
data: dtype | |
explanation of data | |
""" | |
def __init__(self, data): | |
self.data = data | |
def inside_method(self): | |
""" Explanation of what the function does | |
Parameters: -- | |
Returns: | |
------- | |
result: dtype | |
explanation of result | |
""" | |
result = self.data + 2 | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment