-
Notifications
You must be signed in to change notification settings - Fork 279
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
Update docstrings to be consistent with function signature #3310
Conversation
yt/loaders.py
Outdated
length_unit=None, | ||
bbox=None, | ||
sim_time=0.0, | ||
length_unit=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.
If you're worried about order consistency, please sort the docstring, not the signature itself. Specifically positional arguments (keyword-only arguments can be safely reordered without breaking backwards compatibility however)
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.
thank's for doing this, here are a couple suggestions
@@ -222,7 +222,7 @@ def from_lines( | |||
figure_size : int or two-element iterable of ints | |||
Size in inches of the image. | |||
Default: 5 (5x5) | |||
fontsize : int | |||
font_size : 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 agree with the annotated type, but the default value's type should also reflect it, can you fix it too ?
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.
Should be good now!
Co-authored-by: Clément Robert <cr52@protonmail.com>
@@ -222,7 +222,7 @@ def from_lines( | |||
figure_size : int or two-element iterable of ints | |||
Size in inches of the image. | |||
Default: 5 (5x5) | |||
fontsize : int | |||
font_size : 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.
Should be good now!
filt.__doc__ = FilterMaker.__doc__ | ||
self.__dict__["apply_" + filtername] = types.MethodType(filt, self) | ||
|
||
# We need to wrap to create a closure so that |
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 have updated the PR description to explain why this is required.
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 happy to have this go in as is given the fact we have a freshly opened issue to remind us that this code is due for a deeper refactor. Thanks again !
PR Summary
With time, many docstrings have grown out of sync with their actual function. This PR attemps to fix as many as possible.
This PR fixes as many as possible:
* ds : Dataset
should beds : Dataset
)The mismatches have been found using https://gist.github.com/cphyc/afc1a143943220ec3a1c5ca16e14cd13 which allows to compare the list of argument parsed from the docstring to the actual signature of the function.
Currently on main
On main (
center
is missing from the signature):With this PR:
Note on the signature issue
The origin of the signature mismatch is due to the weird structure we are using to register plot annotation callbacks. Each callback is a class which constructor we were binding to the caller PlotWindow instance using
types.MethodType
. This function alters the displayed signature by dropping the first argument which is assumed to beself
. In our case, because we are binding a constructor method rather than a function, the first argument in the signature is actually the first argument afterself
in the__init__
method.Here's a simple example: