-
Notifications
You must be signed in to change notification settings - Fork 7
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 note about get_video
convention to ImagingExtractor
#244
Conversation
for more information, see https://pre-commit.ci
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.
In general, get_video
only returns 3D numpy ndarrays (frames, height, width). Depth is handled only for some extractors, so they should override their get_video
docstring to specify how it is treated.
Every method needs to override the whole function and therefore also the docstring as this is an abstract method. In other words, this is not user facing documentation misguiding the users but documentation for developers with instructions of a common pitfall when they overide the method. In that sense, I think it is better served if it has the more general case, more information is better than less in this case. |
Most of the current
More information can be helpful for devs, but let's at least mention that the return |
Maybe you have a plan that I don't understand. How are you going to inherit the docstring of the abstract method? This seems like a non-standard trick, is that something that you guys have discussed, @CodyCBakerPhD ? |
The child class inherits the docstrings of the parent methods automatically even if it overrides the body of the method -- as long as it doesn't define its own docstring. |
It does not seem that this is true to me, can you reference this or show me this behavior? If it is, what's missing in the code below? from abc import ABC, abstractmethod
class AbstractClass(ABC):
"""
This is the AbstractClass's docstring.
"""
@abstractmethod
def abstract_method(self):
"""
This is the abstract_method's docstring.
"""
pass
@abstract_method
def another_abstract_method(self):
"""
This is the another_abstract_method's docstring.
"""
pass
def a_normal_method(self):
"""Parent docstring"""
class ChildClass(AbstractClass):
def abstract_method(self):
return "Implemented in ChildClass"
def another_abstract_method(self):
"""This one has a docstring"""
return "Implemented in ChildClass"
def a_normal_method(self):
return "Do I override the parent's docstring?"
# Test
child = ChildClass()
print(child.abstract_method())
print(child.abstract_method.__doc__)
print(child.another_abstract_method.__doc__)
print(child.a_normal_method())
print(child.a_normal_method.__doc__)``` Output:
|
It would be nice to get a response for this, @pauladkisson. I think that you are wrong in your claim above. |
@h-mayorquin Note that directly accessing the Check out our recommended ways
This discrepancy is still good for all of us to take note of |
@h-mayorquin, sorry for the delayed response. Basically, as Cody pointed out, dynamic docstring look-up via |
That's fine, this was useful to me. I was not aware that python performs attribute lookup even for attributes of the class' methods when using the help builtin. At the beginning I thought that this was ipython / jupyter behavior but I also tried on the python REPL and is the same behavior. |
Changed this. |
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.
One formatting change otherwise LGTM
Co-authored-by: Paul Adkisson <paul.wesley.adkisson@gmail.com>
Related to #156
The ideal will be to add this in a section of the read the docs but we are far from it. The standard should be written somewhere and this is a place.