-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
DOC: allow np as a module for documentation #11344
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
Conversation
hmm, segfault when building the documentation. |
Yeah, that is strange. Maybe a sphinx related library? |
See PR #11377, there is a bug in calling |
Does the following work better: aliases = {}
for name, module in sys.modules.items():
parts = name.split('.', 1)
if parts[0] == 'numpy':
parts[0] = 'np'
aliases[name] = module
sys.modules.update(aliases) |
It still may fail if new numpy c-extension imports are needed past this point, which should not be the case in documentation. |
parts = name.split('.', 1) | ||
if parts[0] == 'numpy': | ||
parts[0] = 'np' | ||
aliases[name] = module |
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 missed a line, sorry: name = '.'.join(parts)
Turns out that Closing this, it is the wrong approach. |
I think this approach would work if you then also told sphinx to generate docs for things under This might actually be a good idea from the perspective of matching source code, but worse from a search engine perspective. |
Add
np
to sys.modules so that documentation can use`np.dtype`
instead of`numpy.dtype`
or ``np.dtype <numpy.dtype>