DOC: Misc fixes.#11590
Conversation
Add Space before section for proper parsing by numpydoc. Mostly cosmetic, but spaces in around colon in parameters are necessary for numpydoc to properly parsed name vs type. Also remove one non-existing parameter
There was a problem hiding this comment.
Welcome to Astropy 👋 and congratulations on your first pull request! 🎉
A project member will respond to you as soon as possible; in the meantime, please have a look over the Checklist for Contributed Code and make sure you've addressed as many of the questions there as possible.
If you feel that this pull request has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail feedback@astropy.org.
|
Sure, most of this is autogenerated by velin I'm currently working on, so I can even run it against your branch to find fixes there. |
|
See nstarman#2 with a few changes against your branch. |
|
(converted to draft to make sure that does not get merged first) |
| * 'convolve_fft' : use `~astropy.convolution.convolve_fft` function. | ||
| * 'convolve' : use `~astropy.convolution.convolve`. | ||
| kwargs : dict | ||
| **kwargs : dict |
There was a problem hiding this comment.
I am not sure about the **. Is this officially required by numpydoc standards? I mean, kwargs itself is a dict, but you use ** to indicate you want to pass the dict in as key=value pairs. 🤷
There was a problem hiding this comment.
This comment also applies to all other similar changes to both args and kwargs.
There was a problem hiding this comment.
There is no official language in numpydoc itself, though it's the convention used in the example they give and in the test suite.
I'm on the fence, slightly leaning toward having *, and **, as there are cases in scipy where some functions actually take options as a dict.
Here as just options
And here as **unknown_options
There was a problem hiding this comment.
I think I'd lean towards **kwargs as well, though it wouldn't seem to make much sense to then add that it is a dict (which it isn't really any more with the **), even though that is in the example too.
In any case, best to at least standardize!
There was a problem hiding this comment.
@mhvk Agreed! I treat this exactly as typing does, where *args and **kwargs are annotated by the type of the component objects.
| these will contain arrays following the appropriate `numpy` broadcasting rules. | ||
| 0 <= lon < 2pi. | ||
|
|
||
| Notes |
There was a problem hiding this comment.
This comment also applies to all other similar changes.
There was a problem hiding this comment.
That just seems a copy & paste mistake... Or maybe the talk about the way the offset was done was meant to be added. For this clean-up PR, it makes sense to just delete it!
Note that the two in solar_system.py should be kept, though!
|
|
||
| Parameters | ||
| ---------- | ||
| filename : str |
There was a problem hiding this comment.
Yeah, that's also one of the advantage of using *args, and **kwargs in docs, my tool will automatically fix typo and remove non existed documented parameter when it found some.
|
As noted before, I can easily redo this, so please feel free to make #11118 the priority. |
mhvk
left a comment
There was a problem hiding this comment.
Nice clean-up! Looks mostly good except the two cases in solar_system.py, which should keep their "empty" Notes section, as the docstring is amended afterwards.
| * 'convolve_fft' : use `~astropy.convolution.convolve_fft` function. | ||
| * 'convolve' : use `~astropy.convolution.convolve`. | ||
| kwargs : dict | ||
| **kwargs : dict |
There was a problem hiding this comment.
I think I'd lean towards **kwargs as well, though it wouldn't seem to make much sense to then add that it is a dict (which it isn't really any more with the **), even though that is in the example too.
In any case, best to at least standardize!
| these will contain arrays following the appropriate `numpy` broadcasting rules. | ||
| 0 <= lon < 2pi. | ||
|
|
||
| Notes |
There was a problem hiding this comment.
That just seems a copy & paste mistake... Or maybe the talk about the way the offset was done was meant to be added. For this clean-up PR, it makes sense to just delete it!
Note that the two in solar_system.py should be kept, though!
| GCRS Coordinate for the Moon | ||
|
|
||
| Notes | ||
| ----- |
There was a problem hiding this comment.
This one should stay - here the EPHEMERIS_NOTE is added after the fact.
| get_body_barycentric_posvel : to calculate both position and velocity. | ||
|
|
||
| Notes | ||
| ----- |
There was a problem hiding this comment.
This one should stay (see below)
|
Copying from #11118, as it seems most appropriate here.
@Carreau Those both seem like really cool tools! Many of us, and affiliate packages, and 🤞 astropy, use pre-commit. Velin seems well suited for that (if it can be run on diffs) as part of a good development workflow. Additionally / alternatively (@pllim), this might be useful in the daily or weekly cron jobs. |
|
Yeah, th goal is to make it a precomit once its stable enough. I don't think pre commit needs diffs. For now it looks like what's needed is the ability to ignore some objects docstrings in the general case, and/or keep some sections of those docstrings as-is because of further dynamic manipulations. Feel free to keep this as a discussion; as noted it is relatively easy for me to redo this PR, so please put your efforts on #11118 and let me know if you have any ideas of things for which you'd like automatic fixes, or other projects you want me to try this on. |
|
Re: Using tools to make code pretty (git hooks) -- If it works for you, great, but keep in mind that this code base is over 10 years old. Whatever you introduce should not retroactively try to clean up things that have been there for 10 years. It is fine if we want to enforce for new code, but we don't have time or energy to go clean up all the existing code. FYI. |
|
I think that you might be misunderstanding. This is not purely esthetical formatting, In numpydoc Will be parsed as while Will be parsed as For example it found a few documented parameters that don't exists, and can autorename a few like: Without the space before the colon it can't fix that... Same for incorrect sections names, bad underline that throw off parsing. I've been also maintaining 20+ years codebase for about a decade now so understand that sweeping can be tough. |
|
@Carreau , sorry, I edited my comment. I was specifically meaning adding git hooks. Your changes here are fine. |
Ah, ok, thanks for the precision. Just in that case I'll suggest to have a look at https://pypi.org/project/darker/; it tries to apply changes only on already modified lines (+/- some delta); which I find a good intermediate approach – it does work with black, pyupgrade and isort at least. I found it to be a nice compromise that I actually have activate as save hook for my editor. |
|
@Carreau, is this still a draft? It looks like the major points have all been addressed. |
|
I think this has been replaced by #11596, it's easier to rerun velin that update this one. Closing, I will try to find some time to run it on more files later. |
Add Space before section for proper parsing by numpydoc.
Mostly cosmetic, but spaces in around colon in parameters are necessary
for numpydoc to properly parsed name vs type.
Also remove one non-existing parameter