Skip to content

DOC: interpolate: deduplicate docstrings in _fitpack_py and _fitpack_impl #18387

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

Merged
merged 2 commits into from
May 5, 2023

Conversation

ev-br
Copy link
Member

@ev-br ev-br commented Apr 30, 2023

What does this implement/fix?

Functions in _fitpack_py are nothing but thin wrappers which dispatch to either BSpline methods or _fitpack_impl FITPACK Fortran wrappers. Previously, the docstrings were duplicated, and were slightly diverging over time.

So merge the docstrings and deduplicate: move all docstrings to _fitpack_impl/* and attach to _fitpack_py/*.

@ev-br ev-br added scipy.interpolate Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org maintenance Items related to regular maintenance tasks labels Apr 30, 2023
@ev-br ev-br closed this Apr 30, 2023
@ev-br ev-br reopened this Apr 30, 2023
@ev-br
Copy link
Member Author

ev-br commented Apr 30, 2023

Close/reopen to rerun tests

Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ev-br.

In general I am not sure though about dynamic docs. It does not play well with IDEs usually at it would just present an empty box and not follow the redefinition of __doc__.

e.g.
Screenshot 2023-05-01 at 20 02 58

vs
Screenshot 2023-05-01 at 20 03 46

@ev-br
Copy link
Member Author

ev-br commented May 1, 2023

Hmmmm. This is baffling, I've to admit. The manipulation basically happens on import, so should be safe. Anyway.
Do you know how work make it easier for these IDEs? This certainly is not the only place in scipy we construct docstrings at import time, e.g. in stats.distributions. Does your IDE follow what's done over there?

@ilayn
Copy link
Member

ilayn commented May 1, 2023

IDEs do the analysis on the source code. If you import something then they go and fetch the imported func docstring. So this is an annoyance only if you are directly working on the SciPy codebase itself with bare functions. Otherwise users will see the full docstring.

@tupui
Copy link
Member

tupui commented May 2, 2023

I am not sure about that. E.g. with stats distributions, it does not render more than what's in the actual docstrings:

Screenshot 2023-05-02 at 11 45 48

This is with PyCharm, maybe some other IDEs behave differently.

@rgommers rgommers added this to the 1.11.0 milestone May 3, 2023
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM once CI is green(er). The IDE issue is an unrelated generic problem and shouldn't block merging this - best to move that to a separate follow-up issue. Probably not much that can be done about that within SciPy though, so it's probably a wontfix.

@ev-br ev-br closed this May 3, 2023
@ev-br ev-br reopened this May 3, 2023
@ev-br ev-br force-pushed the fitpack_docstrings branch from a14154b to 13aa1b4 Compare May 3, 2023 09:37
@tupui
Copy link
Member

tupui commented May 3, 2023

This LGTM once CI is green(er). The IDE issue is an unrelated generic problem and shouldn't block merging this - best to move that to a separate follow-up issue.

I am not blocking the PR. Just pointing out that this has consequences for IDE users.

Probably not much that can be done about that within SciPy though, so it's probably a wontfix.

I don't think we have made a public decision about going one route or the other. Not using any overwrite for __doc__ would solve the issue (and other issues we have with our own machinery to do so.)

@ev-br
Copy link
Member Author

ev-br commented May 3, 2023

Just pointing out that this has consequences for IDE users.

This is unfortunate indeed. I guess I wouldn't be surprised if it's a wontfix for pycharm as well, importing stuff online is a big can of worms.

So, to proceed here there are three options:

  • keep the status quo. Some 400 lines of duplicated docstrings. Duplicating them was a bad decision (quite a while ago).
  • keep this PR as is
  • move the docstrings to the functions which end up in the public namespace, i.e. _fitpack_py.py + add code comments to point to where the docstrings are. This is IMO slightly worse than the current state of the PR but is likely OK.

@tupui
Copy link
Member

tupui commented May 4, 2023

My preference would be option 3 (moving the doc to the public facing API) as to me private functions can then have more maintainers' oriented docs.

@ev-br ev-br force-pushed the fitpack_docstrings branch from 20ea081 to bd64b56 Compare May 5, 2023 08:31
@ev-br
Copy link
Member Author

ev-br commented May 5, 2023

OK, updated to keep all docstrings in _fitpack_py.

Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Evgeni 😃 Diff is also simpler to parse, I don't see anything we should wait for in CI before we merge, I will go ahead.

@tupui tupui merged commit 6b7650a into scipy:main May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org maintenance Items related to regular maintenance tasks scipy.interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants